FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

12671 questions

15052 answers

24113 comments

47054 members

0 votes
655 views 1 comments
by

Hello,

I'm looking for an example of a bash script line to execute a Modbus RTU read request to a slave.

Thanks

2 Answers

0 votes
by
Hi,

Regarding your question kindly check this link: https://mega.nz/file/OzhlGQbb#knVqT5J9UdDXxxDbP1o9tORjbR7aXiazq5rjLlySjUI

I hope this one will help you :)

Regards,
Jerome
Best answer
by
Great, thank you for your answer

I have another question:

I have enabled router as Modbus TCP Slave (Network -> Modbus -> Modbus TCP Slave);

and enabled Custom Register Block in the webUI from (40000 to 41000)

and enabled Router as Modbus serial master to read slaves via RS485.

Can I store the RTU registers in the Custom Register Block and access them via Modbus TCP, or in other words can I forward the RTU registers to the TCP custom registers?

Thanks
0 votes
by
Hello,

For Modbus TCP, I use modbus_tcp_test

For Morbus RTU, I use the same thing after setting the Modbus Gateway function, which allows to translate the Modbus TCP request into Modbus RTU directly

Example

modbus_tcp_test 192.168.1.251 502 5 255 3 1 10 hex 1

Modbus TCP device (slave ID 255)

Reading from %MW1 to %MW10 on IP 192.168.1.251, Device ID 255, presentation of the result in hexa

In Modbus RTU, after configuration of the gateway

modbus_tcp_test 127.0.0.1 502 5 2 3 1 10 hex 1

Execute %MW1 %MW10 on the local address of the gateway, Modbus RTU slave ID 2, result in hex

root@Teltonika-TRB245:~# modbus_tcp_test -h                                                                                                  

Usage:                                                                                                                                       

        modbus_tcp_test IP PORT TIMEOUT SLAVE_ID FUNCTION REG_ADDRESS REG_COUNT/VALUE(S) DATA_TYPE NO_BRACKETS                               

DATA_TYPE may be one of:                                                                                                                     

        8bit_int                                                                                                                             

        8bit_uint                                                                                                                            

        16bit_int_hi_first                                                                                                                   

        16bit_int_low_first                                                                                                                  

        16bit_uint_hi_first                                                                                                                  

        16bit_uint_low_first                                                                                                                 

        32bit_float1234                                                                                                                      

        32bit_float4321                                                                                                                      

        32bit_float2143                                                                                                                      

        32bit_float3412                                                                                                                      

        32bit_int1234                                                                                                                        

        32bit_int4321                                                                                                                        

        32bit_int2143                                                                                                                        

        32bit_int3412                                                                                                                        

        32bit_uint1234                                                                                                                       

        32bit_uint4321                                                                                                                       

        32bit_uint2143                                                                                                                       

        32bit_uint3412                                                                                                                       

        hex                                                                                                                                  

        ascii