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
Play tic-tac-toe in PowerPoint

The presentation has around 6,000 slides representing every possible game state (and some impossible ones, since I didn't check for wins or ties). You play by clicking on the squares, which are hyper

Jesse Li 3 Dec 18, 2021
This is a batch script created to WEB-DL.

widevine-L3-WEB-DL-Script This is a batch script created to WEB-DL. Works well with .mpd files , for m3u8 please use n_m3u8 program (not included in t

Paranjay Singh 312 Dec 31, 2022
This is a multi-app executor that it used when we have some different task in a our applications and want to run them at the same time

This is a multi-app executor that it used when we have some different task in a our applications and want to run them at the same time. It uses SQLAlchemy for ORM and Alembic for database migrations.

Majid Iranpour 5 Apr 16, 2022
Wrapper for the undocumented CodinGame API. Can be used both synchronously and asynchronlously.

codingame API wrapper Pythonic wrapper for the undocumented CodinGame API. Installation Python 3.6 or higher is required. Install codingame with pip:

Takos 19 Jun 20, 2022
This is a working model for which I have used python.

Jarvis_voiceAssistance This is a working model for which I have used python. This model can: 1)Play a video or song on youtube. 2)Tell us time. 3)Tell

Hardik Jain 1 Jan 30, 2022
Simple module with some functions such as generate password (get_random_string)

Simple module with some functions such as generate password (get_random_string), fix unicode strings, size converter, dynamic console, read/write speed checker, etc.

Dmitry 2 Dec 03, 2022
Rufus port to linux, writed on Python3

Rufus-for-Linux Rufus port to linux, writed on Python3 Программа будет иметь тот же интерфейс что и оригинал, и тот же функционал. Программа создается

6 Jan 07, 2022
Coded in Python 3 - I make for education, easily clone simple website.

Simple Website Cloner - Single Page Coded in Python 3 - I make for education, easily clone simple website. How to use ? Install Python 3 first. Instal

Phạm Đức Thanh 2 Jan 13, 2022
Repo Home WPDrawBot - (Repo, Home, WP) A powerful programmatic 2D drawing application for MacOS X which generates graphics from Python scripts. (graphics, dev, mac)

DrawBot DrawBot is a powerful, free application for macOS that invites you to write Python scripts to generate two-dimensional graphics. The built-in

Frederik Berlaen 342 Dec 27, 2022
A basic animation modding workflow for FFXIV

AnimAssist Provides a quick and easy way to mod animations in FFXIV. You will need: Before anything, the VC++2012 32-bit Redist from here. Havok will

liam 37 Dec 16, 2022
Our Ping Pong Project of numerical analysis, 2nd year IC B2 INSA Toulouse

Ping Pong Project The objective of this project was to determine the moment of impact of the ball with the ground. To do this, we used different model

0 Jan 02, 2022
This repository contains the code for the python introduction lab

This repository contains the code for the python introduction lab. The purpose is to have a fairly simple python assignment that introduces the basic features and tools of python

1 Jan 24, 2022
Collection of functions for working with interlaced content in VapourSynth.

vsfieldkit Collection of functions for working with interlaced content in VapourSynth. It does not have any hard dependencies outside of VapourSynth.

Justin Turner Arthur 11 May 27, 2022
原神抽卡记录导出

原神抽卡记录导出 抽卡记录分析工具 from @笑沐泽 抽卡记录导出工具js版,含油猴脚本可在浏览器导出 注意:我的是python版,带饼图的是隔壁electron版,功能类似 Wik

834 Jan 04, 2023
A simple chatbot that I made for school project

Chatbot: Python A simple chatbot that I made for school Project. Tho this chatbot is dumb sometimes, but it's not too bad lol. Check it Out! FAQ How t

Prashant 2 Nov 13, 2021
This is an independent project to track Nubank expenses

Nubank expense tracker This is an independent project to track Nubank expenses. To fetch Nubank data we are going to use an unofficial Nubank API, tha

Ramon Gazoni Lacerda 0 Aug 28, 2022
Personal Finance Forecaster - An AI tool for forecasting personal expenses

Personal Finance Forecaster - An AI tool for forecasting personal expenses

2 Mar 09, 2022
Mahadi-6 - This Is Bangladeshi All Sim 6 Digit Cloner Tools

BANGLADESHI ALL SIM 6 DIGIT CLONER TOOLS TOOLS $ apt update $ apt upgrade $ apt

MAHADI HASAN AFRIDI 2 Jan 23, 2022
BlackIP-Rep is a tool designed to gather the reputation and information of Bulk IP's.

BlackIP-Rep is a tool designed to gather the reputation and information of Bulk IP's. Focused on increasing the workflow of Security Operations(SOC) team during investigation.

0LiVEr 6 Dec 12, 2022
Gobigger Explore For Python

Gobigger-Explore 🔮 GoBigger Challenge 2021 Baseline en/中文 🤖 Introduction This is the baseline of GoBigger Multi-Agent Decision Intelligence Challeng

OpenDILab 145 Dec 22, 2022