V
V
Vladimir2015-09-10 15:49:15
Python
Vladimir, 2015-09-10 15:49:15

How to use read_holding register in pymodbus?

A piece of product documentation
Socomec products implement functions :
- 3 : to read n Words ( Maximum 125 words )
- 6 : to write 1 word
- 16 : to write n Word
Dec. address hex. Address Words count Description Unit Data Type
50770 C652 2 Total Positive Active Energy (no resetable) : Ea+ kWh U32
There is a piece of code

from pymodbus.client.sync import ModbusSerialClient as ModbusClient

client = ModbusClient(method = "rtu", port="COM1",stopbits = 1, bytesize = 8, parity = 'N',baudrate= 9600)
client.connect()
request = client.read_holding_registers(address=50532,count=2,unit=6)
print request.getRegister(1)
client.close()

In response, I get an unintelligible number
Question, is it possible to see in raw form what goes to the server and what comes from it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
slepowl, 2015-09-10
@Casufi

www.agrostroy.ru/index.php?page=4 - here is the modbus tester. Acts as a master. Can both request registers and write. Ask around and see what he answers. Matches or not with your testimony.
In general, if the exchange is via RS-485, then you can sit in parallel and see what is happening in the port. freeserialanalyzer.com/features - these for example.
the unit parameter is the address of the device?
you give the address 50770 from the document, but you ask for 50532 - is that normal?
getRegister takes what parameter?
and unintelligible - what is it? Does your device on the face reflect energy? Maybe the resulting number still needs to be converted. What does the documentation say about this?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question