Skip to content

Commit 08848b7

Browse files
Distinct unit and slave IDs
1 parent 899dfc4 commit 08848b7

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎utils/solarman_tcp_proxy.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,19 @@ async def handle_client(
4646
unit_id = await reader.readexactly(1)
4747
pdu = await reader.readexactly(length - 1) # length includes unit_id
4848

49-
modbus_rtu = unit_id + pdu + get_crc(unit_id + pdu)
49+
slave_id = b'\x01'
50+
modbus_rtu = slave_id + pdu + get_crc(slave_id + pdu)
5051

5152
try:
5253
# Convert RTU back to TCP
5354
reply_rtu = await solarmanv5.send_raw_modbus_frame(modbus_rtu)
5455

55-
unit_id_reply = reply_rtu[0:1]
56+
slave_id_reply = reply_rtu[0:1]
5657
pdu_reply = reply_rtu[1:-2]
5758
crc_reply = reply_rtu[-2:]
5859

5960
mbap = struct.pack(">HHH", trans_id, 0, len(pdu_reply) + 1)
60-
reply_tcp = mbap + unit_id_reply + pdu_reply
61+
reply_tcp = mbap + unit_id + pdu_reply
6162

6263
writer.write(reply_tcp)
6364
except:

0 commit comments

Comments
 (0)