#!/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)
