Closed kunaala closed 4 years ago
Could you :
In debug mode [01][03][00][F8][00][02][45][FA] Waiting for a confirmation... 01 03 04 00 00 40 40 CA 03
Simulator output Tx-> 01 03 04 00 00 40 40 CA 03 Rx-> 01 03 00 F8 00 02 45 FA
code excerpt: Modbus::Data<int, Modbus::EndianBigLittle> valread[2]; int regResponse = slave->readRegisters(addr, valread, 1); std::cout<<regResponse<<std::endl;
Please let me know if i need to attach something else
Um ... I don't see the problem.
an int
is not coded on 32bits on your machine ?
in modbus, a register is 16bits, so it is normal for the function to read 2 registers 16bits to make a register 32bits !
The syntax of the call to the readRegisters () function is bad, you should put:
int regResponse = slave->readRegisters (addr, &valread[0], 1);
even if it comes down to the same, it is better for what you want to do.
Thanks @epsilonrt that worked! is there a way to make it machine agnostic for portability I would be keen on working on the same
I'm reading through RTU mode as master at 38400 8N1 Master: Raspberrypi, connected to system running modpoll simulator in slave mode using FTDI cable
I'm able to read registers using the aforementioned function, But the modpoll simulator receives a request for reading two consecutive registers from the starting address.The value received from the simulator is in accordance with the same.
When I tried reading from the libmodbus (C) directly using modbus_read_registers, the response is as desired: reading 1 register at a time
Please help me in resolving this issue