Closed Frans400 closed 2 years ago
for (;;) {
//this part is not working and returns a 0 value to int_reading_10
if (!mb.slave()) {
mb.readHreg(1, 10, &uint16_t_reading_10, 1, bool_rtu);// slave address, hreg number , retuned value ,bool_rtu
//---------------------------------------------^
}
while(mb.slave()) // <--- Wait transaction to complete
mb.task();
int_reading_10 = (int(uint16_t_reading_10));
vTaskDelay(100);
//this part is working and returns the correct value int_reading_243
if (!mb.slave()) {
mb.readHreg(1, 243, &uint16_t_reading_243, 1, bool_rtu);
}
while(mb.slave()) // <--- Wait transaction to complete
mb.task();
int_reading_243 = (int(uint16_t_reading_243));
vTaskDelay(100);
}
Hi Thanks for this great library, this library the only liberty I got to work and understands as a non-programmer.
Hopefully someone can tell me how to solve an issue, most of the holding hreg on my power supply only have 1 value per hreg but a few have 2 values according to the user manual. If I try to read any of the hreg with 2 values my code returns 0. Can someone please fix my code if its even possible.