WIP read device id test
This commit is contained in:
parent
165c361a6b
commit
771fd24f93
34
tests/test_read_device_id.py
Executable file
34
tests/test_read_device_id.py
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
#
|
||||||
|
# Test: Read device ID
|
||||||
|
# --------------------
|
||||||
|
# Read device ID
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# This functionality is not implemented in minimalmodbus,
|
||||||
|
# so we have to emulate it (using serial)
|
||||||
|
#
|
||||||
|
import serial
|
||||||
|
|
||||||
|
serial_file = '/dev/rs485'
|
||||||
|
address = 247
|
||||||
|
baudrate = 19200
|
||||||
|
|
||||||
|
s = serial.Serial(serial_file, baudrate)
|
||||||
|
|
||||||
|
# first test: read company ID
|
||||||
|
msg = [
|
||||||
|
address,
|
||||||
|
0x2B, # Function code
|
||||||
|
0x0E, # MEI type
|
||||||
|
0x01, # Read device ID code (get basic identification)
|
||||||
|
0x14, # object ID
|
||||||
|
0xbc, # CRC8 MSB
|
||||||
|
0xda # CRC8 LSB
|
||||||
|
]
|
||||||
|
|
||||||
|
msg = bytes([1,2,3,4,5,6,7,8,9,10])
|
||||||
|
|
||||||
|
s.write(msg)
|
||||||
|
response = s.read()
|
||||||
|
print(response)
|
Loading…
Reference in New Issue
Block a user