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
HOWTO: Downgrade from nYNAB to YNAB4

HOWTO: Downgrade from nYNAB to YNAB4 This page explains how to move from nYNAB to YNAB4 while retaining as much information as possible. See Appendix

Tobias Kunze 10 Dec 29, 2022
solsim is the Solana complex systems simulator. It simulates behavior of dynamical systems—DeFi protocols, DAO governance, cryptocurrencies, and more—built on the Solana blockchain

solsim is the Solana complex systems simulator. It simulates behavior of dynamical systems—DeFi protocols, DAO governance, cryptocurrencies, and more—built on the Solana blockchain

William Wolf 12 Jul 13, 2022
Google Foobar challenge solutions from my experience and other's on the web.

Google Foobar challenge Google Foobar challenge solutions from my experience and other's on the web. Note: Problems indicated with "Mine" are tested a

Islam Ayman 6 Jan 20, 2022
Learn the basics of Python. These tutorials are for Python beginners. so even if you have no prior knowledge of Python, you won’t face any difficulty understanding these tutorials.

01_Python_Introduction Introduction 👋 Python is a modern, robust, high level programming language. It is very easy to pick up even if you are complet

Milaan Parmar / Милан пармар / _米兰 帕尔马 245 Dec 30, 2022
This repository contains completed Python projects

My Python projects This repository contains completed Python projects: 1) Build projects Guide for building projects into executable files 2) Calculat

Igor Yunusov 8 Nov 04, 2021
WGGCommute - Adding Commute Times to WG-Gesucht Listings

WGGCommute - Adding Commute Times to WG-Gesucht Listings This is a barebones implementation of a chrome extension that can be used to add commute time

Jannis 2 Jul 20, 2022
sfgp is a package that aggregates individual scripts and notebooks, primarily written for the basic analysis tasks of genetics and pharmacogenomics data.

sfgp is a package that aggregates individual scripts and notebooks, primarily written for the basic analysis tasks of genetics and pharmacogenomics data.

Vishal Sarsani 1 Mar 31, 2022
Scripts to integrate DFIR-IRIS, MISP and TimeSketch

Scripts to integrate DFIR-IRIS, MISP and TimeSketch

Koen Van Impe 20 Dec 16, 2022
This program can calculate the Aerial Distance between two cities.

Aerial_Distance_Calculator This program can calculate the Aerial Distance between two cities. This repository include both Jupyter notebook and Python

InvisiblePro 1 Apr 08, 2022
HatAsm - a HatSploit native powerful assembler and disassembler that provides support for all common architectures

HatAsm - a HatSploit native powerful assembler and disassembler that provides support for all common architectures.

EntySec 8 Nov 09, 2022
pybind11 — Seamless operability between C++11 and Python

pybind11 — Seamless operability between C++11 and Python Setuptools example • Scikit-build example • CMake example pybind11 is a lightweight header-on

pybind 12.1k Jan 08, 2023
Fused multiply-add (with a single rounding) for Python.

pyfma Fused multiply-add for Python. Fused multiply-add computes (x*y) + z with a single rounding. Useful for dot products, matrix multiplications, po

Nico Schlömer 18 Nov 08, 2022
Bootcamp de Introducción a la Programación. Módulo 6: Matemáticas Discretas

Módulo 6: Matemáticas Discretas Última actualización: 12 de marzo Irónicamente, las matemáticas discretas son las matemáticas que lo cuentan todo. Si

Cynthia Castillo 34 Sep 29, 2022
Create a program for generator Truth Table

Python-Truth-Table-Ver-1.0 Create a program for generator Truth Table in here you have to install truth-table-generator module for python modules inst

JehanKandy 10 Jul 13, 2022
CNKD - Minimalistic Windows ransomware written in Python

CNKD Minimalistic Windows ransomware written in Python (Still a work in progress

Alex 2 May 27, 2022
Get a list of all offline/online members in a discord server

Discord server insights Get a list of all offline/online members in a discord server. Uses Selenium to crawl invite links. Config Download Chrome driv

Prakhar Gurunani 3 Oct 21, 2022
Install packages with pip as if you were in the past!

A PyPI time machine Do you wish you could just install packages with pip as if you were at some fixed date in the past? If so, the PyPI time machine i

Thomas Robitaille 51 Jan 09, 2023
My Solutions to 120 commonly asked data science interview questions.

Data_Science_Interview_Questions Introduction 👋 Here are the answers to 120 Data Science Interview Questions The above answer some is modified based

Milaan Parmar / Милан пармар / _米兰 帕尔马 181 Dec 31, 2022
Cairo hooks for pre-commit

pre-commit-cairo Cairo hooks for pre-commit. See pre-commit for more details Using pre-commit-cairo with pre-commit Add this to your .pre-commit-confi

Fran Algaba 16 Sep 21, 2022
A "multiclipboards" script for an efficient way to improve the original clipboards which are only able to save one string at a time

A "multiclipboards" script for an efficient way to improve the original clipboards which are only able to save one string at a time. Works on both Windows and Linux.

1 Jan 24, 2022