FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
268 views 2 comments
by anonymous

Hello,

in the SMS utilities section -> SMS rules, i want to add a new custom message, like when i send an SMS message with text "hi", the RUT955 will answer me with modbus register values like for example read input registers 1,2, and 3 from the modbus slave.

the RUT955 is configured as modbus TCP master.

firmware: RUT9_R_00.07.04.2

so what are the parameters for that related to modbus values?

thanks in advance

1 Answer

0 votes
by anonymous

Hi,

While such option is not directly available, you can create a script and execute it via SMS. I will show an example of how you can also pass arguments. So you will need to make changes according to your own needs, like hardcoding everything so that you do not need to pass any arguments.

Example of an SMS rule:

Script example:

Pasted script to make it easier:

#!/bin/sh
freg=$1
regc=$2
type=$3

json=$(printf '{"ip":"127.0.0.1","port":502,"id":1,"timeout":1,"function":3,"fir st_reg":%d,"reg_count":"%s","data_type":"%s","no_brackets":1}' "$freg" "$regc" "$type")

ubus call modbus_master tcp.test "$json"

If I send the following SMS to the SIM in the router, passing register numbers and data type:

  • admin01 getmodbus 72 3 ascii

I can obtain the routers name. Results:

Kind Regards,

Andzej

Best answer
by anonymous
Hello,

first of all thank you for your response;

i added the following script directly to the SMS utilities --> customer script:

"

#!/bin/sh

json=$(printf '{"ip":"192.168.10.177", "port":502, "id":1, "timeout":5, "function":4, "first_reg":1, "reg_count":"1", "data_type":"16bit INT, high byte first", "no_brackets":1}')

ubus call modbus_master tcp.test "$json"

"

i got the following using SMS:

{

?"error":0,

?"result": ""

}

status code: 0

but when i try from modbus screen using the same parameters i get the values as expected
by anonymous
solved, the data type value:

ubus call modbus_master tcp.test '{"ip":"192.168.10.177", "port":502, "id":1, "timeout":1, "function":4, "first_reg":1, "reg_count":"2", "data_type":"16bit_int_hi_first", "no_brackets":1}'