Код: Выделить всё
async def requestErrorLogNumber(blueClient, errorLogNum):
global requestedState
# Create the ModBus write message
# We will write to device one, address zero and then add the cycle number we want to write
modbusBytes = READ_DEVICE_5
address = 256 + (errorLogNum*32)
# Convert the number into bytes to add to the byte array
byte_address = address.to_bytes(length=2, byteorder='big')
modbusBytes += byte_address
size = 8
readSize = size.to_bytes(length=2, byteorder='big')
modbusBytes += readSize
# Calculate the CRC for this ModBus packet
headerCRC = crccheck.crc.Crc16Modbus()
headerCRC.process(modbusBytes)
tempCrc = headerCRC.final()

Подробнее здесь: https://stackoverflow.com/questions/792 ... s-not-work
Мобильная версия