stephane / libmodbus

A Modbus library for Linux, Mac OS, FreeBSD and Windows
http://libmodbus.org
GNU Lesser General Public License v2.1
3.44k stars 1.75k forks source link

Read reg modbus master #162

Closed mbenedetti closed 10 years ago

mbenedetti commented 10 years ago

I try to use the library Modbus on rtu mode on raspberry pi. I ‘ve install and have make the examples succesfully. I’ve the little question. I use the Modbus master on pi and one slave arduino and another on pic. The pic send the request to raspberry but I do not understand how to view the contents of the register.

Below you can see the string of data that is passed to raspberry (debug)

<03><10><00><0A><00><08><10><00><00><00><01><00><42><00><43><00><44><00><45><00><46><00><47><09> [03][10][00][0A][00][08][E0][2F] This is the output of printf (0xC4) (0x16) (0x6B) (0x3) (0) (10) (0) (0) (2) (8858) (0) (17509) (0) (8858) (0) (17509) (0) (25460) (0) (112) (0x0) (0x6374) reg[6]=(0), (0x0) , (0) (0x0) this is the part of code I try to print the reg on raspberry. printf("(0x%X) (0x%X)\n", UT_INPUT_BITS_ADDRESS, UT_INPUT_BITS_NB); printf("(0x%X) (0x%X)\n", UT_REGISTERS_ADDRESS, UT_REGISTERS_NB); printf("(%d) (%d)\n", mb_mapping->tab_registers[1], UT_INPUT_REGISTERS_TAB[0]); printf("(%d) (%d)\n", mb_mapping->tab_registers[2], UT_INPUT_REGISTERS_TAB[1]); printf("(%d) (%d)\n", mb_mapping->tab_input_registers[UT_INPUT_REGISTERS_ADDRESS+3], UT_INPUT_REGISTERS_TAB[2]); printf("(%d) (%d)\n", mb_mapping->tab_registers[4], UT_INPUT_REGISTERS_TAB[3]); printf("(%d) (%d)\n", mb_mapping->tab_registers[5], UT_INPUT_REGISTERS_TAB[4]); printf("(%d) (%d)\n", mb_mapping->tab_registers[6], UT_INPUT_REGISTERS_TAB[5]); printf("(%d) (%d)\n", mb_mapping->tab_registers[7], UT_INPUT_REGISTERS_TAB[6]); printf("(%d) (%d)\n", mb_mapping->tab_input_registers[UT_INPUT_REGISTERS_ADDRESS+8], UT_INPUT_REGISTERS_TAB[7]); printf("(0x%X) (0x%X)\n", mb_mapping->tab_registers[9], UT_INPUT_REGISTERS_TAB[8]); printf("reg[%d]=(%d), (0x%X) , (%d) (0x%X)\n", 6,mb_mapping->tab_input_registers[0],mb_mapping->tab_input_registers[1], mb_mapping->tab_input_registers[2], mb_mapping->tab_input_registers[3]);
stephane commented 10 years ago

Please use the mailing list for question. http://libmodbus.org/reportbug/