k0hax-d578uv
This is a python library designed to interface to an AnyTone™ AT-D578UV radio's Microphone port serial connection.
Features
- Control the radio's PTT line
- Send keypad button presses
- Continuously monitor the radio's state
- Perform callbacks on RX sense
Copyright and License
Copyright © 2021 Michael Englehorn
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Installing
pip install d578uv-k0hax
Examples
Control PTT
from d578uv import d578uv
radio = d578uv.d578uv('/dev/ttyUSB0')
# Transmit for 5 seconds
radio.Tx(5)
# Transmit until told to stop transmitting
radio.Tx()
# Stop transmitting, enter receive mode
radio.Rx()
Pictures
AT-578UV
Wiring
In order to determine which UART commands needed to be sent to the radio, and how the radio responds, I used a Bus Pirate by Dangerous Prototypes
I also built a small Cat5 cable breakout that split the cable between the radio and microphone, and allowed me to probe it while it was in operation.
Decoded Communications
Microphone to Radio
Notes
- A single 0x06 packet is sent approximately once per second by the microphone to the radio as a type of keepalive
| Description | Byte 0 | PTT | Pressed | Long Press | Button Address | Byte 5 | Byte 6 | Number of Bytes |
|---|---|---|---|---|---|---|---|---|
| PTT Pressed | 0x41 | 0x01 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 7 |
| PTT Released | 0x41 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 7 |
| A = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x1a | 0x00 | 0x00 | 7 |
| A = Held Long | 0x41 | 0x00 | 0x01 | 0x01 | 0x1a | 0x00 | 0x00 | 7 |
| A = Released | 0x41 | 0x00 | 0x00 | 0x01 | 0x1a | 0x00 | 0x00 | 7 |
| B = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x1b | 0x00 | 0x00 | 7 |
| B = Held Long | 0x41 | 0x00 | 0x01 | 0x01 | 0x1b | 0x00 | 0x00 | 7 |
| B = Released | 0x41 | 0x00 | 0x00 | 0x01 | 0x1b | 0x00 | 0x00 | 7 |
| C = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x1c | 0x00 | 0x00 | 7 |
| C = Held Long | 0x41 | 0x00 | 0x01 | 0x01 | 0x1c | 0x00 | 0x00 | 7 |
| C = Released | 0x41 | 0x00 | 0x00 | 0x01 | 0x1c | 0x00 | 0x00 | 7 |
| D = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x1d | 0x00 | 0x00 | 7 |
| D = Held Long | 0x41 | 0x00 | 0x01 | 0x01 | 0x1d | 0x00 | 0x00 | 7 |
| D = Released | 0x41 | 0x00 | 0x00 | 0x01 | 0x1d | 0x00 | 0x00 | 7 |
| D = Short 1 | 0x41 | 0x00 | 0x01 | 0x00 | 0x1d | 0x00 | 0x00 | 7 |
| D = Short 2 | 0x41 | 0x00 | 0x00 | 0x00 | 0x1d | 0x00 | 0x00 | 7 |
| 1 = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x02 | 0x00 | 0x00 | 7 |
| 2 = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x03 | 0x00 | 0x00 | 7 |
| 3 = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x04 | 0x00 | 0x00 | 7 |
| 4 = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x05 | 0x00 | 0x00 | 7 |
| 5 = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x06 | 0x00 | 0x00 | 7 |
| 6 = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x07 | 0x00 | 0x00 | 7 |
| 7 = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x08 | 0x00 | 0x00 | 7 |
| 8 = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x09 | 0x00 | 0x00 | 7 |
| 9 = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x0a | 0x00 | 0x00 | 7 |
| 0 = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x01 | 0x00 | 0x00 | 7 |
| * = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x0b | 0x00 | 0x00 | 7 |
| # = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x0c | 0x00 | 0x00 | 7 |
| SubPTT = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x0d | 0x00 | 0x00 | 7 |
| Down = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x11 | 0x00 | 0x00 | 7 |
| Up = Pressed | 0x41 | 0x00 | 0x01 | 0x00 | 0x10 | 0x00 | 0x00 | 7 |
Button Address Table
This is for clarity
| Button | Address |
|---|---|
PTT |
0x00 |
0 |
0x01 |
1 |
0x02 |
2 |
0x03 |
3 |
0x04 |
4 |
0x05 |
5 |
0x06 |
6 |
0x07 |
7 |
0x08 |
8 |
0x09 |
9 |
0x0a |
* |
0x0b |
# |
0x0c |
SubPTT |
0x0d |
Up |
0x10 |
Down |
0x11 |
A |
0x1a |
B |
0x1b |
C |
0x1c |
D |
0x1d |
Radio to Microphone
| Description | Byte 0 | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Byte 5 | Byte 6 | Byte 7 | Byte 8 | Byte 9 | Byte 10 | Byte 11 | Byte 12 | Byte 13 | Byte 14 | Byte 15 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| RX Start, A | 0x53 | 0x01 | 0x01 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x10 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x06 |
| RX Stop, A | 0x53 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x10 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x06 |
| A to B | 0x53 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x01 | 0x00 | 0x10 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x06 |
| B to A | 0x53 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x10 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x06 |
| CMD Ack | 0xaa | |||||||||||||||
| TX Start, A | 0x53 | 0x00 | 0x00 | 0x01 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x10 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x06 |
| TX Start, B | 0x53 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x01 | 0x01 | 0x00 | 0x10 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x06 |
| TX End, A | 0x53 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x10 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x06 |
| TX End, B | 0x53 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x01 | 0x00 | 0x10 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x06 |
Metadata
Release files for d578uv-k0hax 0.1.20210516.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| d578uv_k0hax-0.1.20210516.2-py3.10.egg | Legacy Egg format | - | - | Details for d578uv_k0hax-0.1.20210516.2-py3.10.egg |
| d578uv_k0hax-0.1.20210516.2-py3-none-any.whl | Python 3 | none | any | Details for d578uv_k0hax-0.1.20210516.2-py3-none-any.whl |
Total release size: 21.4 kB
Release files / d578uv_k0hax-0.1.20210516.2-py3.10.egg
| Download URL | d578uv_k0hax-0.1.20210516.2-py3.10.egg |
|---|---|
| Size | 5.1 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
a6dcc45d901f484fd4f5b9e11eee11626ba200d57932ac7e2d55b132558bbcef
|
|
BLAKE2b-256 checksum How to use checksums |
2f0534d6a431384e6e55fdf9b0b2f3d62d572ce5f527e4843c820b42f8611066
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.10.0b1
|
Release files / d578uv_k0hax-0.1.20210516.2-py3-none-any.whl
| Download URL | d578uv_k0hax-0.1.20210516.2-py3-none-any.whl |
|---|---|
| Size | 16.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d36bc8944823379362aebab3b133aff497e7d1dfc148ee54265e18a55c26d9a6
|
|
BLAKE2b-256 checksum How to use checksums |
63d1406da02816a75bb8f03ca9b73170c1fa47f7eb51322e2707c29adf8bc4d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.10.0b1
|
Security for d578uv-k0hax 0.1.20210516.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.