Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
a265a0c
fix proc bytes for bit types
HotNoob May 30, 2025
7e9175b
fix proc bytes bit flags
HotNoob May 30, 2025
5ab463e
add canbus simulator!!!
HotNoob May 30, 2025
44e031a
proc bytes fix bit flags... i hope
HotNoob May 30, 2025
84112b4
ooof, didnt add the canbus sim files. here they are
HotNoob May 30, 2025
19a0713
Delete pace_bms_v1.3.input_registry_map.csv
HotNoob May 30, 2025
ffd84ab
Update growatt_bms_canbus_v1.04.registry_map.csv
HotNoob May 30, 2025
4fcd48b
fix parser for float
HotNoob May 31, 2025
392a126
proc bytes byte, isolate byte
HotNoob May 31, 2025
cfa56e4
update python version for docker
HotNoob Jun 6, 2025
28d09b2
docker hub readme
HotNoob Jun 6, 2025
0cd3c00
Update README.md
HotNoob Jun 6, 2025
ca3fae1
Update README.md
HotNoob Jun 6, 2025
f2d6d83
Update README.md
HotNoob Jun 6, 2025
d2deb9a
add check - is usb port a link
gorbyo Jun 12, 2025
eccb024
Merge pull request #90 from gorbyo/issue-serial-symlink
HotNoob Jun 14, 2025
75de12f
add permissions to workflows
HotNoob Jun 19, 2025
b13e5c3
add eg4-18k
HotNoob Jun 19, 2025
44db2f3
* improve eg4 handling
jaredmauch Jun 20, 2025
4db8362
add serial number ( one string )
HotNoob Jun 20, 2025
30902c8
s/type/trasport
jaredmauch Jun 20, 2025
8afe3f0
revert
jaredmauch Jun 20, 2025
d5632a5
attempt to fix issue with analyze_protocol = true
jaredmauch Jun 20, 2025
f9d5fc2
attempt to fix issue with analyze_protocol = true
jaredmauch Jun 20, 2025
a52c418
attempt to fix issue with analyze_protocol = true
jaredmauch Jun 20, 2025
0248882
attempt to fix issue with analyze_protocol = true
jaredmauch Jun 20, 2025
e8be5e9
Fix pymodbus 3.7+ compatibility issues
jaredmauch Jun 20, 2025
7f6e1ed
remove testing files from branch
jaredmauch Jun 20, 2025
fcad1f2
Fix UnboundLocalError and improve validation robustness
jaredmauch Jun 20, 2025
7650f0b
Fix analyze_protocol validation timing issue
jaredmauch Jun 20, 2025
9c69c2e
Fix analyze_protocol to use configured protocol register ranges
jaredmauch Jun 20, 2025
e36fa93
address connection issue
jaredmauch Jun 20, 2025
663e76d
address issue with analyze_protocol
jaredmauch Jun 20, 2025
55e2a68
address issue with analyze_protocol
jaredmauch Jun 20, 2025
635e3ba
address issue with analyze_protocol
jaredmauch Jun 20, 2025
e8d7c56
address issue with analyze_protocol
jaredmauch Jun 20, 2025
5374391
address issue with analyze_protocol
jaredmauch Jun 20, 2025
20e18b1
address issue with analyze_protocol
jaredmauch Jun 20, 2025
1970e23
address issue with analyze_protocol
jaredmauch Jun 20, 2025
d3b4166
address issue with analyze_protocol
jaredmauch Jun 20, 2025
bbf19e3
address issue with analyze_protocol
jaredmauch Jun 20, 2025
021736f
address issue with analyze_protocol baudrate
jaredmauch Jun 20, 2025
c0510f6
address issue with analyze_protocol baudrate
jaredmauch Jun 20, 2025
224d4ed
restore file accidentally deleted in 7f6e1ed
jaredmauch Jun 20, 2025
d6d14d1
sync over 4db83627f1ec637851e5acf0906003b0341b4344
jaredmauch Jun 20, 2025
64fb1ef
Merge branch 'main' of github.com:jaredmauch/PythonProtocolGateway
jaredmauch Jun 20, 2025
af51f7d
cleanup logging, place DEBUG level messages behind debug
jaredmauch Jun 20, 2025
df9c9c6
cleanup logging, place DEBUG level messages behind debug
jaredmauch Jun 20, 2025
9c2aa14
simulate modbus from registry dumps
HotNoob Jun 20, 2025
a8f606a
influxdb floating point fixup
jaredmauch Jun 20, 2025
fb49a90
promote serial number from inverter to device
jaredmauch Jun 20, 2025
e7d78b0
promote serial number from inverter to device
jaredmauch Jun 20, 2025
d03a843
simplify device_serial_number
jaredmauch Jun 20, 2025
8d3e784
add byte order to data types _BE _LE
HotNoob Jun 20, 2025
be2c3ea
document _LE _BE data type suffixes
HotNoob Jun 20, 2025
950fd4b
Merge branch 'v1.1.10-pr92' into main
HotNoob Jun 20, 2025
c5404a7
Merge pull request #92 from jaredmauch/main
HotNoob Jun 20, 2025
2ce4143
clean. accept / decline changes
HotNoob Jun 20, 2025
6104524
Merge pull request #93 from HotNoob/v1.1.10-pr92
HotNoob Jun 20, 2025
e718041
clean
HotNoob Jun 20, 2025
eb29873
fix pymodbus 3.8+ bug
HotNoob Jun 20, 2025
750a832
Merge branch 'v1.1.10' of github.com:HotNoob/PythonProtocolGateway in…
HotNoob Jun 20, 2025
1abcce6
fix sn / modbus base init
HotNoob Jun 21, 2025
83e627d
add write modes to documentation
HotNoob Jun 21, 2025
7c2ce78
add flow diagram
HotNoob Jun 21, 2025
eb1febf
add diagram
HotNoob Jun 21, 2025
c5cec39
instructions for external mqtt broker on ha
HotNoob Jun 21, 2025
7bbb927
Update README.md
HotNoob Jun 21, 2025
acb236b
house keeping
HotNoob Jun 21, 2025
404c591
add pyproject.toml for pypi package
HotNoob Jun 21, 2025
9ec6aec
Merge branch 'v1.1.10' of https://github.com/HotNoob/PythonProtocolGa…
HotNoob Jun 21, 2025
0ec031b
Update pyproject.toml
HotNoob Jun 21, 2025
6524bbf
Update README.md
HotNoob Jun 21, 2025
fedddd9
add protocol_gateway.py alias "ppg.py"
HotNoob Jun 21, 2025
9a3ee28
start documentation of various install methods
HotNoob Jun 21, 2025
38c54b6
Update pip.md
HotNoob Jun 21, 2025
cf77f2b
Create RELEASE.md
HotNoob Jun 21, 2025
91c7f03
debug two serial ports at once
jaredmauch Jun 22, 2025
8333afc
Merge branch 'main' of github.com:jaredmauch/PythonProtocolGateway
jaredmauch Jun 22, 2025
d06d9c5
multiprocessing test
jaredmauch Jun 22, 2025
081add7
multiprocessing test
jaredmauch Jun 22, 2025
e226055
multiprocessing test
jaredmauch Jun 22, 2025
d6caf06
influxdb fix
jaredmauch Jun 22, 2025
8535bab
reduce main loop delay
HotNoob Jun 22, 2025
513bb05
clean up example config a bit
HotNoob Jun 23, 2025
aeef8bb
Merge pull request #94 from jaredmauch/main
HotNoob Jun 23, 2025
d889fa6
Revert "Improve support of two rs485 inputs at once and single output…
HotNoob Jun 23, 2025
42bc7c9
add
HotNoob Jun 23, 2025
2a253a2
Merge pull request #95 from HotNoob/revert-94-main
HotNoob Jun 23, 2025
435bae9
quick clean
HotNoob Jun 23, 2025
b8c92b5
add PV statistics for SRNE
gorbyo Jun 23, 2025
16a751e
Merge pull request #97 from gorbyo/dev
HotNoob Jun 25, 2025
71e8304
implement influxdb backlog and reconnection logic
jaredmauch Jul 1, 2025
79d9018
add protocol settinsg
jaredmauch Jul 1, 2025
5dc0ecf
influxdb docs
jaredmauch Jul 1, 2025
7bd0011
Merge branch 'v1.1.10' into main
HotNoob Jul 1, 2025
b6d7f19
Merge pull request #98 from jaredmauch/main
HotNoob Jul 1, 2025
db0eabf
add few stats for srne and refactored
gorbyo Jul 7, 2025
ce46d68
Merge pull request #101 from gorbyo/add_srne_stats
HotNoob Jul 7, 2025
8547284
fix writing "codes" to registers
HotNoob Jul 30, 2025
71aeef8
fix config parser getboolean
HotNoob Jul 30, 2025
db29e69
fix writing "codes"
HotNoob Jul 30, 2025
3593aa4
add get_code_by_value
HotNoob Jul 30, 2025
799b57a
Create devices_and_protocols.csv
HotNoob Aug 7, 2025
52529c6
Update devices_and_protocols.csv
HotNoob Aug 7, 2025
82d7cfe
move to csv for tracking protocols and devices
HotNoob Aug 7, 2025
f6da551
Update README.md
HotNoob Aug 7, 2025
5a6c8df
relative links
HotNoob Aug 7, 2025
98be5ea
more cleaning
HotNoob Aug 7, 2025
e411507
fix #104
HotNoob Aug 8, 2025
e9ccf16
fix for flake8
HotNoob Aug 11, 2025
255ad86
fix pytest for influxdb
HotNoob Aug 11, 2025
2c3c682
move data dump to debug output level
HotNoob Aug 11, 2025
ef6d13a
Revert "move data dump to debug output level"
HotNoob Aug 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/python-3.10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

name: Python 3.10

permissions:
contents: read

on:
push:
branches: [ "main" ]
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/python-3.11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

name: Python 3.11

permissions:
contents: read

on:
push:
branches: [ "main" ]
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/python-3.12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

name: Python 3.12

permissions:
contents: read

on:
push:
branches: [ "main" ]
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/python-3.13.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

name: Python 3.13

permissions:
contents: read

on:
push:
branches: [ "main" ]
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/python-3.9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

name: Python 3.9

permissions:
contents: read

on:
push:
branches: [ "main" ]
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ classes/transports/*custom*

input_registry.json
holding_registry.json

#ignore pypi / pyproject.toml output
dist/*
build/*
python_protocol_gateway.egg-info/*
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9-alpine as base
FROM python:3.13-alpine as base
FROM base as builder
RUN mkdir /install
WORKDIR /install
Expand Down
66 changes: 40 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
![Python 3.12](https://github.com/HotNoob/PythonProtocolGateway/actions/workflows/python-3.12.yml/badge.svg)
![Python 3.13](https://github.com/HotNoob/PythonProtocolGateway/actions/workflows/python-3.13.yml/badge.svg)

[![PyPI version](https://img.shields.io/pypi/v/python-protocol-gateway.svg)](https://pypi.org/project/python-protocol-gateway/)
[![CodeQL](https://github.com/HotNoob/PythonProtocolGateway/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/HotNoob/PythonProtocolGateway/actions/workflows/github-code-scanning/codeql)

For advanced configuration help, please checkout the documentation :)
https://github.com/HotNoob/PythonProtocolGateway/tree/main/documentation

[/documentation](/documentation)

# Python Protocol Gateway

Expand All @@ -17,8 +19,9 @@ Configuration is handled via a small config files.
In the long run, Python Protocol Gateway will become a general purpose protocol gateway to translate between more than just modbus and mqtt.

For specific device installation instructions please checkout the documentation:
Growatt, EG4, Sigineer, SOK, PACE-BMS
https://github.com/HotNoob/PythonProtocolGateway/tree/main/documentation
Growatt, EG4, Sigineer, SOK, PACE-BMS, Sigineer, ect...

[/documentation/devices](/documentation/devices)

# General Installation
Connect the USB port on the inverter into your computer / device. This port is essentially modbus usb adapter.
Expand All @@ -28,7 +31,7 @@ Alternatively, connect a usb adapter to your rs485 / can port with appropriate w

### install as homeassistant add-on
checkout:
https://github.com/felipecrs/python-protocol-gateway-hass-addon/tree/master
[PPG HASS Addon](https://github.com/HotNoob/python-protocol-gateway-hass-addon/tree/master)

### install requirements
```
Expand All @@ -49,21 +52,30 @@ nano config.cfg
manually select protocol in .cfg
protocol_version = {{version}}
```
eg4_v58 = eg4 inverters
eg4_3000ehv_v1 = eg4 inverters
v0.14 = growatt inverters 2020+
sigineer_v0.11 = sigineer inverters
growatt_2020_v1.24 = alt protocol for large growatt inverters - currently untested
srne_v3.9 = SRNE inverters - confirmed working-ish
victron_gx_3.3 = Victron GX Devices - Untested
solark_v1.1 = SolarArk 8/12K Inverters - Untested
srne_v3.9 = SRNE inverters

hdhk_16ch_ac_module = some chinese current monitoring device :P
srne_2021_v1.96 = SRNE inverters 2021+ (tested at ASF48100S200-H, ok-ish for HF2430U60-100 )
```

eg4_v58 = eg4 inverters ( EG4-6000XP ) - confirmed working
eg4_3000ehv_v1 = eg4 inverters ( EG4_3000EHV )
Untested Protocols
```
growatt_2020_v1.24 = alt protocol for large growatt inverters
victron_gx_3.3 = Victron GX Devices
solark_v1.1 = SolarArk 8/12K Inverters
```

For a complete list of protocols, explore:
[/Protocols](/protocols)

more details on these protocols can be found in the documentation:
https://github.com/HotNoob/PythonProtocolGateway/tree/main/documentation
For a more complete list of tested devices & protocols:
[Tested Devices & Protocols](documentation/usage/devices_and_protocols.csv)

more advanced details can be found in the documentation:
[/Documentation](/documentation)

### run as script
```
Expand Down Expand Up @@ -108,8 +120,11 @@ once installed; the device should show up on home assistant under mqtt

```Settings -> Devices & Services -> MQTT ```

more docs on setting up mqtt here: https://www.home-assistant.io/integrations/mqtt
i probably might have missed something. ha is new to me.
more docs on setting up mqtt here:
https://www.home-assistant.io/integrations/mqtt

#### connect mqtt on home assistant with external mqtt broker
[HowTo Connect External MQTT Broker To HomeAssistant](https://www.youtube.com/watch?v=sP2gYLYQat8)

### general update procedure
update files and restart script / service
Expand All @@ -118,8 +133,6 @@ git pull
systemctl restart protocol_gateway.service
```

**if you installed this when it was called growatt2mqtt-hotnoob or invertermodbustomqtt, you'll need to reinstall if you want to update. **

### Unknown Status MQTT Home Assistant
If all values appear as "Unknown"
This is a bug with home assistant's discovery that some times happens when adding for the first time. just restart the service / script and it will fix itself.
Expand Down Expand Up @@ -148,17 +161,18 @@ As i dive deeper into solar monitoring and general automation, i've come to the

So... don't mind me as i may add other devices such as battery bms' and... i have a home energy monitor on the way! so i'll be adding that when it arrives.

### Rebranding Again... last time.
if you installed this when it was called growatt2mqtt-hotnoob or InverterModBusToMQTT, you'll need to reinstall if you want to update.


### donate
this took me a while to make; and i had to make it because there werent any working solutions.
donations would be appreciated.
![BitCoin Donation](https://github.com/HotNoob/growatt2mqtt-hotnoob/blob/main/images/donate_to_hotnoob.png?raw=true)

```(btc) bc1qh394vazcguedkw2rlklnuhapdq7qgpnnz9c3t0```
donations / sponsoring this repo would be appreciated.

### Use Docker - untested
### Use Docker
- ```docker build . -t protocol_gateway ```
- ```docker run --device=/dev/ttyUSB0 protocol_gateway```

### Use Docker Image
- ``` docker pull hotn00b/pythonprotocolgateway ```
- ```docker run -v $(pwd)/config.cfg:/app/config.cfg --device=/dev/ttyUSB0 hotn00b/pythonprotocolgateway```

See [config.cfg.example](/config.cfg.example)

[Docker Image Repo](https://hub.docker.com/r/hotn00b/pythonprotocolgateway)
8 changes: 8 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
things todo to perform a release.

can try to automate some of these later.

GitHub - https://github.com/HotNoob/PythonProtocolGateway/releases
PyPi Package - https://pypi.org/project/python-protocol-gateway/
HomeAssistant repo - https://github.com/HotNoob/python-protocol-gateway-hass-addon
Docker Image - https://hub.docker.com/r/hotn00b/pythonprotocolgateway
73 changes: 62 additions & 11 deletions classes/protocol_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class registry_map_entry:
register_bit : int
register_byte : int
''' byte offset for canbus ect... '''

variable_name : str
documented_name : str
unit : str
Expand All @@ -208,6 +209,9 @@ class registry_map_entry:
data_type_size : int = -1
''' for non-fixed size types like ASCII'''

data_byteorder : str = ''
''' entry specific byte order little | big | '' '''

read_command : bytes = None
''' for transports/protocols that require sending a command ontop of "register" '''

Expand Down Expand Up @@ -330,6 +334,19 @@ def get_registry_entry(self, name : str, registry_type : Registry_Type) -> regis
return item

return None

def get_code_by_value(self, entry : registry_map_entry, value : str, fallback=None) -> str:
''' case insensitive '''

value = value.strip().lower()

if entry.variable_name+"_codes" in self.codes:
codes = self.codes[entry.variable_name+"_codes"]
for code, val in codes.items():
if value == val.lower():
return code

return fallback

def load__json(self, file : str = "", settings_dir : str = ""):
if not settings_dir:
Expand Down Expand Up @@ -512,16 +529,30 @@ def process_row(row):

#region data type
data_type = Data_Type.USHORT

data_type_len : int = -1
data_byteorder : str = ''
#optional row, only needed for non-default data types
if "data type" in row and row["data type"]:
data_type_str : str = ''

matches = data_type_regex.search(row["data type"])
if matches:
data_type_len = int(matches.group("length"))
data_type = Data_Type.fromString(matches.group("datatype"))
data_type_str = matches.group("datatype")
else:
data_type = Data_Type.fromString(row["data type"])
data_type_str = row["data type"]

#check if datatype specifies byteorder
if data_type_str.upper().endswith("_LE"):
data_byteorder = "little"
data_type_str = data_type_str[:-3]
elif data_type_str.upper().endswith("_BE"):
data_byteorder = "big"
data_type_str = data_type_str[:-3]


data_type = Data_Type.fromString(data_type_str)



if "values" not in row:
Expand Down Expand Up @@ -658,6 +689,7 @@ def process_row(row):
unit_mod= unit_multiplier,
data_type= data_type,
data_type_size = data_type_len,
data_byteorder = data_byteorder,
concatenate = concatenate,
concatenate_registers = concatenate_registers,
values=values,
Expand Down Expand Up @@ -857,6 +889,10 @@ def load_registry_map(self, registry_type : Registry_Type, file : str = "", sett
def process_register_bytes(self, registry : dict[int,bytes], entry : registry_map_entry):
''' process bytes into data'''

byte_order : str = self.byteorder
if entry.data_byteorder: #allow map entry to override byteorder
byte_order = entry.data_byteorder

if isinstance(registry[entry.register], tuple):
register = registry[entry.register][0] #can bus uses tuple for timestamp
else:
Expand All @@ -869,14 +905,15 @@ def process_register_bytes(self, registry : dict[int,bytes], entry : registry_ma
register = register[:entry.data_type_size]

if entry.data_type == Data_Type.UINT:
value = int.from_bytes(register[:4], byteorder=self.byteorder, signed=False)
value = int.from_bytes(register[:4], byteorder=byte_order, signed=False)
elif entry.data_type == Data_Type.INT:
value = int.from_bytes(register[:4], byteorder=self.byteorder, signed=True)
value = int.from_bytes(register[:4], byteorder=byte_order, signed=True)
elif entry.data_type == Data_Type.USHORT:
value = int.from_bytes(register[:2], byteorder=self.byteorder, signed=False)
value = int.from_bytes(register[:2], byteorder=byte_order, signed=False)
elif entry.data_type == Data_Type.SHORT:
value = int.from_bytes(register[:2], byteorder=self.byteorder, signed=True)
value = int.from_bytes(register[:2], byteorder=byte_order, signed=True)
elif entry.data_type == Data_Type._16BIT_FLAGS or entry.data_type == Data_Type._8BIT_FLAGS or entry.data_type == Data_Type._32BIT_FLAGS:
val = int.from_bytes(register, byteorder=byte_order, signed=False)
#16 bit flags
start_bit : int = 0
end_bit : int = 16 #default 16 bit
Expand Down Expand Up @@ -952,11 +989,20 @@ def process_register_bytes(self, registry : dict[int,bytes], entry : registry_ma
# If positive, simply extract the value using the bit mask
value = (register >> bit_index) & bit_mask

elif entry.data_type.value > 200 or entry.data_type == Data_Type.BYTE: #bit types
elif entry.data_type == Data_Type.BYTE: #bit types
value = int.from_bytes(register[:1], byteorder=byte_order, signed=False)
elif entry.data_type.value > 200: #bit types
bit_size = Data_Type.getSize(entry.data_type)
bit_mask = (1 << bit_size) - 1 # Create a mask for extracting X bits
bit_index = entry.register_bit


if isinstance(register, bytes):
register = int.from_bytes(register, byteorder=byte_order)

value = (register >> bit_index) & bit_mask


elif entry.data_type == Data_Type.HEX:
value = register.hex() #convert bytes to hex
elif entry.data_type == Data_Type.ASCII:
Expand Down Expand Up @@ -986,6 +1032,11 @@ def process_register_bytes(self, registry : dict[int,bytes], entry : registry_ma

def process_register_ushort(self, registry : dict[int, int], entry : registry_map_entry ):
''' process ushort type registry into data'''

byte_order : str = self.byteorder
if entry.data_byteorder:
byte_order = entry.data_byteorder

if entry.data_type == Data_Type.UINT: #read uint
if entry.register + 1 not in registry:
return
Expand Down Expand Up @@ -1058,7 +1109,7 @@ def process_register_ushort(self, registry : dict[int, int], entry : registry_ma
else:
flags : list[str] = []
if end_bit > 0:
end : int = 16 if end_bit >= 16 else end_bit
end : int = 16 if end_bit >= 16 else end_bit
for i in range(start_bit, end): # Iterate over each bit position (0 to 15)
# Check if the i-th bit is set
if (val >> i) & 1:
Expand All @@ -1074,10 +1125,10 @@ def process_register_ushort(self, registry : dict[int, int], entry : registry_ma
bit_index = entry.register_bit
value = (registry[entry.register] >> bit_index) & bit_mask
elif entry.data_type == Data_Type.HEX:
value = registry[entry.register].to_bytes((16 + 7) // 8, byteorder=self.byteorder) #convert to ushort to bytes
value = registry[entry.register].to_bytes((16 + 7) // 8, byteorder=byte_order) #convert to ushort to bytes
value = value.hex() #convert bytes to hex
elif entry.data_type == Data_Type.ASCII:
value = registry[entry.register].to_bytes((16 + 7) // 8, byteorder=self.byteorder) #convert to ushort to bytes
value = registry[entry.register].to_bytes((16 + 7) // 8, byteorder=byte_order) #convert to ushort to bytes
try:
value = value.decode("utf-8") #convert bytes to ascii
except UnicodeDecodeError as e:
Expand Down
Loading