It is all okay when it comes to read registers with:


It gives me values of 32 different registers. But when it comes to reading bits(coils) in registers i get illegal function error.


After getting this error again and again i made a scanning program like:

for(int i=0; i<100000; i++)

All gives me the same error. I have altivar 930(ATV 930). What to do to read CMD register that has 15 bits with logic address 16#2135 = 8501?

ps: I also tried inputting 0x2135 and 2135. I also get invalid address when i try to read


libmodbus.org/docs/v3.0.6/modbus_read_registers.html http://libmodbus.org/docs/v3.0.6/modbus_read_bits.html

  • \$\begingroup\$ Some Modbus implementations don't support reading less than 8 coils (one byte) at a time, try requesting 8 coils. Also, what is dest? Is it an array or a single byte? \$\endgroup\$ – Ron Beyer Oct 14 '17 at 12:29
  • \$\begingroup\$ @RonBeyer hello thank your for your comment it is output, libmodbus.org/docs/v3.0.6/modbus_read_registers.html. Let me try 8 coils \$\endgroup\$ – Mr.Coder Oct 14 '17 at 12:36
  • \$\begingroup\$ @RonBeyer I still get illegal function with rc= modbus_read_bits(ctx, 0, 8, read_bits); btw uint8_t read_bits[64]; libmodbus.org/docs/v3.0.6/modbus_read_bits.html \$\endgroup\$ – Mr.Coder Oct 14 '17 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.