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
784 views 8 comments
by
I have a bunch of RUT955 devices and I'm trying to figure out how to read analog/digital INPUT without using CLI. It takes a couple of seconds to initiate SSH, and it is a pain to hold active connection all the time. I can activate OUTPUT with GET/POST, but nothing for input.

Have I missed some crucial information?
by anonymous
I don't have it, I have to send 2 request like you. On PostMan, I can directly send another request without waiting return for the first :)

1 Answer

+1 vote
by anonymous

Hello,

On CLI,, you can enter/sbin/gpio.sh get DIN1 :)

AND cat /sys/class/hwmon/hwmon0/device/in0_input for Analog Input

Found here : https://wiki.teltonika-networks.com/view/RUT955_Input/Output#Status_and_control_from_command_line

If you want another method, maybe you can use Modbus TCP Master and Modbus Data Sender to generate Http Post request with configurable period. Define Modbus TCP Master > Slave with RUT955 IP, ID1 and register 135 for DIN1, 141 for Analog 1.

And Modbus Data Sender could send it to your application

BR

by
Yes thank you. That is already what I am using. But the problem is that establishing SSH connection takes 3-6 seconds, and I need to read the input way faster than that. Only solution so far is to always hold active ssh connection so calling gpio.sh takes a couple of ms. The other method you described is initiated by the device, but I need to initiate the request from server. I guess I'll need to write some kind of web service to run on the device.
by
I don't know why it takes 3-6s to get an SSH connection. When I use JSON RPC to execute some commands (like CLI), it takes somes milliseconds to get the Session ID.

It could be a solution. I don't have made tests for gpio.sh commands but gsmctl and uci commands works fine
by

Oh wow, thank you. Somehow I missed the JSON RPC - I have never used it. Seems that it is exactly what I need. Thou there is  issue with turning on the relay on the device. Perhaps there is some issue in my POST? It turns on the relay, but seems to timeout with response. I get result code 7 after it times out.

{

    "jsonrpc": "2.0", "id": 1, "method": "call", "params": 

    [

        "**************************", "file", "exec",

        {

            "command":"/sbin/gpio.sh",

            "params":

            [

                "set",

                "DOUT2" 

            ]

        }

    ]

}

by anonymous

As described on documentation, try to replace set DOUT1 by invert.

You can turn it ON (Active (Low level)) by setting its value to 1:

root@Teltonika:~# gpio.sh invert DOUT1
root@Teltonika:~# gpio.sh get DOUT1
1
by

I guess the problem is that gpio.sh doesn't return any stdout when setting a value so jsonrpc waits for it?

When calling INVERT or SET on DOUT2 it waits for 10 seconds and then returns (it does trigger the relay immediately):

{
    "jsonrpc""2.0",
    "id"1,
    "result": [
        7
    ]
}
If I call GET on DOUT2 then response is as expected:
{
    "jsonrpc""2.0",
    "id"1,
    "result": [
        0,
        {
            "code"0,
            "stdout""1\n"
        }
    ]
}
by anonymous
You are right, SET ou INVERT doesn't return actual state ... and on my side, i have the same result (waiting 10s and got 7)

That's why (i guess) Teltonika show 2 commands, INVERT + GET on their example

It's works ... but it's not perfect :)
by
Could you please share the example on how to send INVERT + GET with jsonrpc in one request? I can't seem to find it anywhere.

Otherwise I have to wait 10s for request to complete to get the current state.