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, выдается ошибка:

    ✘ u0_a268@localhost  ~  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
JLC2KICAD_lib is a python script that generate a component library for KiCad from the JLCPCB/easyEDA library.

JLC2KiCad_lib is a python script that generate a component library (schematic, footprint and 3D model) for KiCad from the JLCPCB/easyEDA library. This script requires Python 3.6 or higher.

Nicolas Toussaint 73 Dec 26, 2022
K2HASH Python library - NoSQL Key Value Store(KVS) library

k2hash_python Overview k2hash_python is an official python driver for k2hash. Install Firstly you must install the k2hash shared library: curl -o- htt

Yahoo! JAPAN 3 Oct 19, 2022
🔩 Like builtins, but boltons. 250+ constructs, recipes, and snippets which extend (and rely on nothing but) the Python standard library. Nothing like Michael Bolton.

Boltons boltons should be builtins. Boltons is a set of over 230 BSD-licensed, pure-Python utilities in the same spirit as — and yet conspicuously mis

Mahmoud Hashemi 6k Jan 6, 2023
A Python library to simulate a Zoom H6 recorder remote control

H6 A Python library to emulate a Zoom H6 recorder remote control Introduction This library allows you to control your Zoom H6 recorder from your compu

Matias Godoy 68 Nov 2, 2022
Integration of Hotwire's Turbo library with Flask.

turbo-flask Integration of Hotwire's Turbo library with Flask, to allow you to create applications that look and feel like single-page apps without us

Miguel Grinberg 240 Jan 6, 2023
Python library for creating PEG parsers

PyParsing -- A Python Parsing Module Introduction The pyparsing module is an alternative approach to creating and executing simple grammars, vs. the t

Pyparsing 1.7k Jan 3, 2023
Python library to natively send files to Trash (or Recycle bin) on all platforms.

Send2Trash -- Send files to trash on all platforms Send2Trash is a small package that sends files to the Trash (or Recycle Bin) natively and on all pl

Andrew Senetar 224 Jan 4, 2023
Python screenshot library, replacement for the Pillow ImageGrab module on Linux.

tldr: Use Pillow The pyscreenshot module is obsolete in most cases. It was created because PIL ImageGrab module worked on Windows only, but now Linux

null 455 Dec 24, 2022
📙 Super lightweight function registries for your library

catalogue: Super lightweight function registries for your library catalogue is a tiny, zero-dependencies library that makes it easy to add function (o

Explosion 139 Jan 2, 2023
A functional standard library for Python.

Toolz A set of utility functions for iterators, functions, and dictionaries. See the PyToolz documentation at https://toolz.readthedocs.io LICENSE New

null 4.1k Jan 4, 2023
🔩 Like builtins, but boltons. 250+ constructs, recipes, and snippets which extend (and rely on nothing but) the Python standard library. Nothing like Michael Bolton.

Boltons boltons should be builtins. Boltons is a set of over 230 BSD-licensed, pure-Python utilities in the same spirit as — and yet conspicuously mis

Mahmoud Hashemi 5.4k Feb 20, 2021
Retrying library for Python

Tenacity Tenacity is an Apache 2.0 licensed general-purpose retrying library, written in Python, to simplify the task of adding retry behavior to just

Julien Danjou 4.3k Jan 2, 2023
Retrying is an Apache 2.0 licensed general-purpose retrying library, written in Python, to simplify the task of adding retry behavior to just about anything.

Retrying Retrying is an Apache 2.0 licensed general-purpose retrying library, written in Python, to simplify the task of adding retry behavior to just

Ray Holder 1.9k Dec 29, 2022
Ikaros is a free financial library built in pure python that can be used to get information for single stocks, generate signals and build prortfolios

Ikaros is a free financial library built in pure python that can be used to get information for single stocks, generate signals and build prortfolios

Salma Saidane 64 Sep 28, 2022
Paprika is a python library that reduces boilerplate. Heavily inspired by Project Lombok.

Image courtesy of Anna Quaglia (Photographer) Paprika Paprika is a python library that reduces boilerplate. It is heavily inspired by Project Lombok.

Rayan Hatout 55 Dec 26, 2022
A Python library that helps data scientists to infer causation rather than observing correlation.

A Python library that helps data scientists to infer causation rather than observing correlation.

QuantumBlack Labs 1.7k Jan 4, 2023
GUI for the Gammu library.

Wammu GUI for the Gammu library. Homepage <https://wammu.eu/> License GNU GPL version 3 or later. First start On first start you will be asked for set

Gammu 60 Dec 14, 2022
Python library and cli util for https://www.zerochan.net/

Zerochan Library for Zerochan.net with pics parsing and downloader included! Features CLI utility for pics downloading from zerochan.net Library for c

kiriharu 10 Oct 11, 2022
An Advanced Wordlist Library Written In Python For Acm114

RBAPG ->RBAPG is the abbreviation of "Rule Based Attack Password Generator". ->This module is a wordlist generator module. ->You can generate randomly

Aziz Kaplan 11 Aug 28, 2022