Library for RadiaCode-101

Overview

RadiaCode

Библиотека для работы с дозиметром RadiaCode-101, находится в разработке - API не стабилен и возможны изменения.

Пример использования (backend, frontend): radiacode-webserver-example

Установка & запуск примера

# установка вместе с зависимостями для примеров, уберите [examples] если они вам не нужны
$ pip3 install 'radiacode[examples]' --upgrade

# Запуск вебсервера из скриншота выше
# bluetooth: замените на адрес вашего устройства
$ python3 -m radiacode-examples.webserver --bluetooth-mac 52:43:01:02:03:04

# или то же самое, но по usb
$ sudo python3 -m radiacode-examples.webserver

# простой пример с выводом информации в терминал, опции аналогичны webserver
$ python3 -m radiacode-examples.basic

# отправка показания в народный мониторинг narodmon.ru
$ python3 -m radiacode-examples.narodmon --bluetooth-mac 52:43:01:02:03:04

Разработка

  • Установить python poetry
  • Склонировать репозиторий, установить и запустить:
$ git clone https://github.com/cdump/radiacode.git
$ cd radiacode
$ poetry install
$ poetry run python3 radiacode-examples/basic.py --bluetooth-mac 52:43:01:02:03:04  # или без --bluetooth-mac для USB подключения
Comments
  • Не работает с прошивкой 1.15 (неизвестное сообщение 0.9)

    Не работает с прошивкой 1.15 (неизвестное сообщение 0.9)

    Пробую написать интеграцию с home assistant, но уперся в проблему с транспортом - не соединяется. Решил проверить примеры на десктопе, где бт точно свободен. Получил ошибку, из-за которой график счета не обновляется:

    $ python3 webserver.py --bluetooth-mac 52:43:06:50:06:a0
    will use Bluetooth connection
    Task exception was never retrieved
    future: <Task finished name='Task-2' coro=<process() done, defined at /home/vovan/src/smart-home/homeassistant/radiacode/radiacode-examples/webserver.py:42> exception=Exception('Uknown eid:0 gid:9')>
    Traceback (most recent call last):
      File "/home/vovan/src/smart-home/homeassistant/radiacode/radiacode-examples/webserver.py", line 46, in process
        databuf = app.rc_conn.data_buf()
      File "/home/vovan/src/smart-home/homeassistant/radiacode/radiacode/radiacode.py", line 123, in data_buf
        return decode_VS_DATA_BUF(r, self._base_time)
      File "/home/vovan/src/smart-home/homeassistant/radiacode/radiacode/decoders/databuf.py", line 79, in decode_VS_DATA_BUF
        raise Exception(f'Uknown eid:{eid} gid:{gid}')
    Exception: Uknown eid:0 gid:9
    ======== Running on http://0.0.0.0:8080 ========
    
    opened by vooon 6
  • English Docs

    English Docs

    Привет!

    I translated the documentation so this cool library might be found and used by more people. :) Please let me know of you want something changed.

    opened by medienlampe 2
  • Questions about how you created this

    Questions about how you created this

    Greetings! I just got my Radiacode-101 today and I absolutely love it. However, given I'm a Linux guy, I was curious to know how you went about reverse engineering this to work with the Radiacode? Do they have some open-source documentation somewhere describing how to access the data? Or did you just figure it out on your own?

    I'm asking cause I'd love to make my own app for Linux to interact with the Radiacode. But I'd definitely like to know if there is a good way to go about accessing the data on it. Any help you can provide is great appreciated! :)

    opened by JoshuaKimsey 1
  • Ubuntu USB

    Ubuntu USB

    Howdy do,

    I'm trying to run the code here, and this is the output.

    python3 -m radiacode-examples.basic will use USB connection Traceback (most recent call last): File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/rhandorf/code/radicode/radiacode/radiacode-examples/basic.py", line 39, in main() File "/home/rhandorf/code/radicode/radiacode/radiacode-examples/basic.py", line 17, in main rc = RadiaCode() File "/home/rhandorf/code/radicode/radiacode/radiacode/radiacode.py", line 29, in init self.execute(b'\x07\x00', b'\x01\xff\x12\xff') File "/home/rhandorf/code/radicode/radiacode/radiacode/radiacode.py", line 46, in execute response = self._connection.execute(full_request) File "/home/rhandorf/code/radicode/radiacode/radiacode/transports/usb.py", line 19, in execute self._device.write(0x1, request) File "/usr/local/lib/python3.8/dist-packages/usb/core.py", line 989, in write return fn( File "/usr/local/lib/python3.8/dist-packages/usb/backend/libusb1.py", line 837, in bulk_write return self.__write(self.lib.libusb_bulk_transfer, File "/usr/local/lib/python3.8/dist-packages/usb/backend/libusb1.py", line 938, in __write _check(retval) File "/usr/local/lib/python3.8/dist-packages/usb/backend/libusb1.py", line 602, in _check raise USBTimeoutError(_strerror(ret), ret, _libusb_errno[ret]) usb.core.USBTimeoutError: [Errno 110] Operation timed out

    I've gone and tried to write some additional code to read any command responses, but it also times out.

    The IO interface does appear to be there:

    DEVICE ID 0483:f123 on Bus 001 Address 016 ================= bLength : 0x12 (18 bytes) bDescriptorType : 0x1 Device bcdUSB : 0x201 USB 2.01 bDeviceClass : 0x0 Specified at interface bDeviceSubClass : 0x0 bDeviceProtocol : 0x0 bMaxPacketSize0 : 0x40 (64 bytes) idVendor : 0x0483 idProduct : 0xf123 bcdDevice : 0x200 Device 2.0 iManufacturer : 0x1 Scan Electronics iProduct : 0x2 RadiaCode-101 iSerialNumber : 0x3 RC-101-003337 bNumConfigurations : 0x1 CONFIGURATION 1: 400 mA ================================== bLength : 0x9 (9 bytes) bDescriptorType : 0x2 Configuration wTotalLength : 0x20 (32 bytes) bNumInterfaces : 0x1 bConfigurationValue : 0x1 iConfiguration : 0x4 Custom Config bmAttributes : 0xc0 Self Powered bMaxPower : 0xc8 (400 mA) INTERFACE 0: Vendor Specific =========================== bLength : 0x9 (9 bytes) bDescriptorType : 0x4 Interface bInterfaceNumber : 0x0 bAlternateSetting : 0x0 bNumEndpoints : 0x2 bInterfaceClass : 0xff Vendor Specific bInterfaceSubClass : 0xff bInterfaceProtocol : 0xff iInterface : 0x5 Custom Interface ENDPOINT 0x81: Bulk IN =============================== bLength : 0x7 (7 bytes) bDescriptorType : 0x5 Endpoint bEndpointAddress : 0x81 IN bmAttributes : 0x2 Bulk wMaxPacketSize : 0x40 (64 bytes) bInterval : 0x0 ENDPOINT 0x1: Bulk OUT =============================== bLength : 0x7 (7 bytes) bDescriptorType : 0x5 Endpoint bEndpointAddress : 0x1 OUT bmAttributes : 0x2 Bulk wMaxPacketSize : 0x40 (64 bytes) bInterval : 0x0

    opened by rhandorf 0
  • Exception when alarm goes off

    Exception when alarm goes off

    It seems if the dose rate alarms are configured then the device sends additional data that the webserver example is not designed to handle?

    I get a couple of different errors when I activate the alarm

    Rates updated, sending to 0 connected clients
    Task exception was never retrieved
    future: <Task finished coro=<process() done, defined at /usr/local/lib/python3.7/dist-packages/radiacode-examples/webserver.py:42> exception=Exception('BytesBuffer: 7 bytes required for <BBBi, but have only 6')>
    Traceback (most recent call last):
      File "/usr/local/lib/python3.7/dist-packages/radiacode-examples/webserver.py", line 46, in process
        databuf = app.rc_conn.data_buf()
      File "/usr/local/lib/python3.7/dist-packages/radiacode/radiacode.py", line 123, in data_buf
        return decode_VS_DATA_BUF(r, self._base_time)
      File "/usr/local/lib/python3.7/dist-packages/radiacode/decoders/databuf.py", line 14, in decode_VS_DATA_BUF
        seq, eid, gid, ts_offset = br.unpack('<BBBi')
      File "/usr/local/lib/python3.7/dist-packages/radiacode/bytes_buffer.py", line 18, in unpack
        raise Exception(f'BytesBuffer: {sz} bytes required for {fmt}, but have only {len(self._data) - self._pos}')
    Exception: BytesBuffer: 7 bytes required for <BBBi, but have only 6
    

    or sometimes I get

    Rates updated, sending to 0 connected clients
    Task exception was never retrieved
    future: <Task finished coro=<process() done, defined at /usr/local/lib/python3.7/dist-packages/radiacode-examples/webserver.py:42> exception=Exception('seq jump, expect:86, got:48')>
    Traceback (most recent call last):
      File "/usr/local/lib/python3.7/dist-packages/radiacode-examples/webserver.py", line 46, in process
        databuf = app.rc_conn.data_buf()
      File "/usr/local/lib/python3.7/dist-packages/radiacode/radiacode.py", line 123, in data_buf
        return decode_VS_DATA_BUF(r, self._base_time)
      File "/usr/local/lib/python3.7/dist-packages/radiacode/decoders/databuf.py", line 17, in decode_VS_DATA_BUF
        raise Exception(f'seq jump, expect:{next_seq}, got:{seq}')
    Exception: seq jump, expect:86, got:48
    
    opened by ninjas28 0
  • Запуск на android через termux. Radiacode подключен через USB.

    Запуск на android через termux. Radiacode подключен через USB.

    Radiacode подключен по USB к android. При попытке запуска python3 -m radiacode-examples.basic в приложении termux, выдается ошибка:

    [email protected]  ~  python3 -m radiacode-examples.basic
    will use USB connection
    Traceback (most recent call last):
      File "/data/data/com.termux/files/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "/data/data/com.termux/files/usr/lib/python3.9/runpy.py", line 87, in _run_code
        exec(code, run_globals)
      File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/radiacode-examples/basic.py", line 35, in <module>
        main()
      File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/radiacode-examples/basic.py", line 17, in main
        rc = RadiaCode()
      File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/radiacode/radiacode.py", line 26, in __init__
        self._connection = Usb()
      File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/radiacode/transports/usb.py", line 14, in __init__
        self._device = usb.core.find(idVendor=0x483, idProduct=0xF123)
      File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/usb/core.py", line 1299, in find
        raise NoBackendError('No backend available')
    usb.core.NoBackendError: No backend available
    
    opened by Am6er 1
Releases(0.1.6)
Owner
Maxim Andreev
Maxim Andreev
A python package template that can be adapted for RAP projects

Warning - this repository is a snapshot of a repository internal to NHS Digital. This means that links to videos and some URLs may not work. Repositor

NHS Digital 3 Nov 08, 2022
NFT generator for Solana!

Solseum NFT Generator for Solana! Check this guide here! Creating your randomized uniques NFTs, getting rarity information and displaying it on a webp

Solseum™ VR NFTs 145 Dec 30, 2022
Pokemon catch events project to demonstrate data pipeline on AWS

Pokemon Catches Data Pipeline This is a sample project to practice end-to-end data project; Terraform is used to deploy infrastructure; Kafka is the t

Vitor Carra 4 Sep 03, 2021
Localization and multifractal properties of the long-range Kitaev chain in the presence of an Aubry-André-Harper modulation

This repository contains the code for the paper Localization and multifractal properties of the long-range Kitaev chain in the presence of an Aubry-André-Harper modulation.

Joana Fraxanet 2 Apr 17, 2022
Fully coded Apps by Codex.

OpenAI-Codex-Code-Generation Fully coded Apps by Codex. How I use Codex in VSCode to generate multiple completions with autosorting by highest "mean p

nanowell 47 Jan 01, 2023
Explores the python bytecode, provides some tools to access it for fun and profit.

Pyasmtools - looking at the python bytecode for fun and profit. The pyasmtools library is made up of two parts A python bytecode disassembler . See Py

Michael Moser 299 Jan 04, 2023
Simple but maybe too simple config management through python data classes. We use it for machine learning.

👩‍✈️ Coqpit Simple, light-weight and no dependency config handling through python data classes with to/from JSON serialization/deserialization. Curre

coqui 67 Nov 29, 2022
A docker container (Docker Desktop) for a simple python Web app few unit tested

Short web app using Flask, tested with unittest on making massive requests, responses of the website, containerized

Omar 1 Dec 13, 2021
TickerRain is an open-source web app that stores and analysis Reddit posts in a transparent and semi-interactive manner.

TickerRain is an open-source web app that stores and analysis Reddit posts in a transparent and semi-interactive manner

GonVas 180 Oct 08, 2022
Aides to reduce a cheat file with a personal selection of the cheats you want to use.

Retroarch Cheat File Reducer Description Aides to reduce a cheat file with a personal selection of the cheats you want to use. Instructions Copy a sel

1 Jan 09, 2022
A tool to guide you for team selection based on mana and ruleset using your owned cards.

Splinterlands_Teams_Guide A tool to guide you for team selection based on mana and ruleset using your owned cards. Built With This project is built wi

Ruzaini Subri 3 Jul 30, 2022
The repository is about 100+ python programming exercise problem discussed, explained, and solved in different ways

Break The Ice With Python A journey of 100+ simple yet interesting problems which are explained, solved, discussed in different pythonic ways Introduc

Abdullah Al Masud Tushar 2.2k Jan 04, 2023
Choice Coin 633 Dec 23, 2022
NGEBUG is a tool that sends viruses to victims

Ngebug NGEBUG adalah tools pengirim virus ke korban NGEBUG adalah tools virus terbaru yang berasal dari rusia Informasi lengkap ada didalam tools Run

Profesor Acc 3 Dec 13, 2021
msImpersonate - User account impersonation written in pure Python3

msImpersonate v1.0 msImpersonate is a Python-native user impersonation tool that is capable of impersonating local or network user accounts with valid

Joe Helle 90 Dec 16, 2022
Download and process GOES-16 and GOES-17 data from NOAA's archive on AWS using Python.

Download and display GOES-East and GOES-West data GOES-East and GOES-West satellite data are made available on Amazon Web Services through NOAA's Big

Brian Blaylock 88 Dec 16, 2022
This is the repo for Uncertainty Quantification 360 Toolkit.

UQ360 The Uncertainty Quantification 360 (UQ360) toolkit is an open-source Python package that provides a diverse set of algorithms to quantify uncert

International Business Machines 207 Dec 30, 2022
Step by step development of a vending coffee machine project, including tkinter, sqlite3, simulation, etc.

Step by step development of a vending coffee machine project, including tkinter, sqlite3, simulation, etc.

Nikolaos Avouris 2 Dec 05, 2021
Student Enrollment Analysis System

SEAS Student Enrollment Analysis System Steps to start working: create a user name "seas", host name: local, password: seas, mark all checkbox - go C

Md. Zakaria Kabir 3 Jul 12, 2022
Lightweight Scheduled Blocks Checker for Current Epoch. No cardano-node Required, data is taken from blockfrost.io

ReLeaderLogs For Cardano Stakepool Operators: Lightweight Scheduled Blocks Checker for Current Epoch. No cardano-node Required, data is taken from blo

SNAKE (Cardano Stakepool) 2 Oct 19, 2021