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
Neogex is a human readable parser standard, being implemented in Python

Neogex (New Expressions) Parsing Standard Much like Regex, Neogex allows for string parsing and validation based on a set of requirements. Unlike Rege

Seamus Donnellan 1 Dec 17, 2021
:snake: Complete C99 parser in pure Python

pycparser v2.20 Contents 1 Introduction 1.1 What is pycparser? 1.2 What is it good for? 1.3 Which version of C does pycparser support? 1.4 What gramma

Eli Bendersky 2.8k Dec 29, 2022
The Python Fuzzer that the world deserves 🐍

pip3 install frelatage Current release : 0.0.2 The Python Fuzzer that the world deserves Installation | How it works | Features | Use Frelatage | Conf

Rog3r 219 Dec 21, 2022
Your one and only Discord Bot that helps you concentrate!

Your one and only Discord Bot thats helps you concentrate! Consider leaving a ⭐ if you found the project helpful. concy-bot A bot which constructively

IEEE VIT Student Chapter 22 Sep 27, 2022
Absolute solvation free energy calculations with OpenFF and OpenMM

ABsolute SOLVantion Free Energy Calculations The absolv framework aims to offer a simple API for computing the change in free energy when transferring

7 Dec 07, 2022
Git Hooks Tutorial.

Git Hooks Tutorial My public talk about this project at Sberloga: Git Hooks Is All You Need 1. Git Hooks 101 Init git repo: mkdir git_repo cd git_repo

Dani El-Ayyass 17 Oct 12, 2022
Introduction to Databases Coursework 2 (SQL) - dataset generator

Introduction to Databases Coursework 2 (SQL) - dataset generator This is python script generates a text file with insert queries for the schema.sql fi

Javier Bosch 1 Nov 08, 2021
YourX: URL Clusterer With Python

YourX | URL Clusterer Screenshots Instructions for running Install requirements

ARPSyndicate 1 Mar 11, 2022
The dynamic code loading framework used in LocalStack

localstack-plugin-loader localstack-plugin-loader is the dynamic code loading framework used in LocalStack. Install pip install localstack-plugin-load

LocalStack 5 Oct 09, 2022
Tools for teachers and students using nng (Natural Number Game)

nngtools Usage Place your nngsave.json to the directory in which you want to extract the level files. Place nngmap.json on the same directory. Run nng

Thanos Tsouanas 1 Dec 12, 2021
Script for resizing MTD partitions on a QNAP device in order to be available to upgrade from buster to bullseye

QNAP partitions resize for kirkwood devices. As explained by Marin Michlmayr, Debian bullseye support on kirkwood QNAP devices was dropped due to [mai

Arnaud Mouiche 26 Jan 05, 2023
A tool for fixing inconsistent timestamp metadata (atime, ctime, and mtime).

Mtime Fixer Mtime Fixer is a tool for fixing inconsistent timestamp metadata (atime, ctime, and mtime). Sometimes timestamp metadata of folders are in

Halit Şimşek 2 Jan 11, 2022
Brython (Browser Python) is an implementation of Python 3 running in the browser

brython Brython (Browser Python) is an implementation of Python 3 running in the browser, with an interface to the DOM elements and events. Here is a

5.9k Jan 02, 2023
Scientific color maps and standardization tools

Scicomap is a package that provides scientific color maps and tools to standardize your favourite color maps if you don't like the built-in ones. Scicomap currently provides sequential, bi-sequential

Thomas Bury 14 Nov 30, 2022
PythonKafkaCompose is an upgrade of the amazing work done in liveMaps

PythonKafkaCompose is an upgrade of the amazing work done in liveMaps It is a simple project composed by: an instance of Kafka a Py

5 Jun 19, 2022
Blender Add-on to Add Metal Materials to Your Scene

Blender QMM (Quick Metal Materials) Blender Addon to Add Metal Materials to Your Scene Installation Download the latest ZIP from Releases. Usage This

Don Schnitzius 27 Dec 26, 2022
Flow control is the order in which statements or blocks of code are executed at runtime based on a condition. Learn Conditional statements, Iterative statements, and Transfer statements

03_Python_Flow_Control Introduction 👋 The control flow statements are an essential part of the Python programming language. A control flow statement

Milaan Parmar / Милан пармар / _米兰 帕尔马 209 Oct 31, 2022
A student information management system in Python

Student-information-management-system 本项目是一个学生信息管理系统,这个项目是用Python语言实现的,也实现了图形化界面的显示,同时也实现了管理员端,学生端两个登陆入口,同时底层使用的是Redis做的数据持久化。 This project is a stude

liuyunfei 7 Nov 15, 2022
Your copilot to studies and work (Pomodoro-timer, Translate and Notes app)

Copylot Your copilot to studies and work (Pomodoro-timer, Translate and Notes app) Copylot are three applications in one: Pomodoro Translate Notes Cop

Eduardo Mendes 20 Dec 16, 2022
App to decide weekly winners in H2H 1 Win (9 Cat)

Fantasy Weekly Winner for H2H 1 Win (9 Cat) Yahoo Fantasy API Read

Sai Atmakuri 1 Dec 31, 2021