Question: Is it possible to set the object id count to 0x00 when reading device information
Atheer2104 opened this issue · 5 comments
Versions
- Python: 3.11.6
- OS: ubuntu 23.10
- Pymodbus: 3.6.9
- Modbus Hardware (if used):
Pymodbus Specific
- Client: rtu - async
Description
Hello, I'm trying to read the device information from a battery via serial connection I can read other input registers values which are defined by the manufacturer. But i'm having problems with reading the device information, this can be wrong from the device itself I'm not actually sure. But none the less according to the manufacturer the object start id and object id count by default should be 0x00 when looking at the logs the package automatically sets object id count to 0x79, can I in some way change this to be 0x00
Code and Logs
only adding the most important part of the code
# reading device info
rq = mei_message.ReadDeviceInformationRequest(unit=0,read_code=0x01, object_id=int(0x00), slave=device_slave_id)
result = await self.device.execute(rq)
# LOGS
2024-07-29 18:24:19,103 DEBUG logging:103 Connecting to /dev/ttyUSB0.
2024-07-29 18:24:19,103 DEBUG logging:103 Connecting comm
2024-07-29 18:24:19,105 DEBUG logging:103 Connected to comm
2024-07-29 18:24:19,105 DEBUG logging:103 Resetting frame - Current Frame in buffer -
2024-07-29 18:24:19,105 DEBUG logging:103 Adding transaction 0
2024-07-29 18:24:19,105 DEBUG logging:103 Resetting frame - Current Frame in buffer -
2024-07-29 18:24:19,105 DEBUG logging:103 send: 0x27 0x2b 0xe 0x1 0x0 0x79 0xb0
2024-07-29 18:24:19,255 DEBUG logging:103 Adding transaction 0
2024-07-29 18:24:19,256 DEBUG logging:103 Resetting frame - Current Frame in buffer -
2024-07-29 18:24:19,256 DEBUG logging:103 send: 0x27 0x2b 0xe 0x1 0x0 0x79 0xb0
2024-07-29 18:24:19,406 DEBUG logging:103 Connection lost comm due to Server not responding
2024-07-29 18:24:19,407 DEBUG logging:103 callback_disconnected called: Server not responding
Your code is using the wrong parameters, please see the documentation
0x79 0xb0 is the crc, not the request.
alright currently using the read_device_information function as below.
result = await self.device.read_device_information(read_code=1, object_id=0, slave=device_slave_id)
#LOGS
2024-07-29 19:18:15,102 DEBUG logging:103 Connecting to /dev/ttyUSB0.
2024-07-29 19:18:15,102 DEBUG logging:103 Connecting comm
2024-07-29 19:18:15,103 DEBUG logging:103 Connected to comm
2024-07-29 19:18:15,103 DEBUG logging:103 Resetting frame - Current Frame in buffer -
2024-07-29 19:18:15,104 DEBUG logging:103 Adding transaction 0
2024-07-29 19:18:15,104 DEBUG logging:103 Resetting frame - Current Frame in buffer -
2024-07-29 19:18:15,104 DEBUG logging:103 send: 0x27 0x2b 0xe 0x1 0x0 0x79 0xb0
2024-07-29 19:18:15,254 DEBUG logging:103 Adding transaction 0
2024-07-29 19:18:15,254 DEBUG logging:103 Resetting frame - Current Frame in buffer -
2024-07-29 19:18:15,254 DEBUG logging:103 send: 0x27 0x2b 0xe 0x1 0x0 0x79 0xb0
2024-07-29 19:18:15,405 DEBUG logging:103 Connection lost comm due to Server not responding
2024-07-29 19:18:15,406 DEBUG logging:103 callback_disconnected called: Server not responding
according to the manufacturer the hex request that they are sending is the following 27 2B 0E 01 00 00 71 E2,
0x27 - Device address
0x2B - Modbus device information function code
0x0E - sub function code
0x01 - read device id code
0x00 - object id
0x00 - object id count
0x71 - CRC CHECK LSB
0xE2 - CRC CHECK MSB
Alright I see, how would one go about overwriting the standard code any documentation on that ?
Also is it possible to write a raw hex and send it as a request?
Btw thanks for the quick replies:)
See our examples, and documentation.
If you send raw hex you do not need pymodbus.