mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
added crc to device names
in case of a Icom IC-705 we have the behavior, that this device will be recognized as two usb devices. In this case we need to have a way to select the correct one...
This commit is contained in:
parent
6eae5604d0
commit
0dd3cd4635
1 changed files with 11 additions and 1 deletions
|
@ -19,6 +19,9 @@ import psutil
|
|||
import serial.tools.list_ports
|
||||
import pyaudio
|
||||
import static
|
||||
import crcengine
|
||||
crc_algorithm = crcengine.new('crc16-ccitt-false') # load crc8 library
|
||||
|
||||
|
||||
def start_daemon():
|
||||
|
||||
|
@ -186,8 +189,15 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
# UPDATE LIST OF SERIAL DEVICES
|
||||
ports = serial.tools.list_ports.comports()
|
||||
for port, desc, hwid in ports:
|
||||
|
||||
# calculate hex of hwid if we have unique names
|
||||
crc_hwid = crc_algorithm(bytes(hwid, encoding='utf-8'))
|
||||
crc_hwid = crc_hwid.to_bytes(2, byteorder='big')
|
||||
crc_hwid = crc_hwid.hex()
|
||||
description = desc + ' [' + crc_hwid + ']'
|
||||
|
||||
data["SERIAL_DEVICES"].append(
|
||||
{"PORT": str(port), "DESCRIPTION": str(desc)})
|
||||
{"PORT": str(port), "DESCRIPTION": str(description) })
|
||||
|
||||
|
||||
jsondata = json.dumps(data)
|
||||
|
|
Loading…
Reference in a new issue