PDA

View Full Version : Confused about interacting with devices



rickerdo
May 2nd, 2015, 09:44 AM
I'm thoroughly confused about how to interact with devices using a custom plugin. I know I'm missing something, but I'm not sure where to begin.

Current environment:
- Raspberry Pi running Girder 6 as a backend
- Win 7 running the frontend
- New group with just a "Scripting" action which contains the following code:
require('examples.simpleSendAndReceive')
conn = examples.simpleSendAndReceive.new('192.168.1.213', 5000)
conn:connect()
conn:send("hello\n")
- A simple python script runs on 192.168.1.213:5000 which echos back "OK...{received_text}"

I can send a "hello\n" to 192.168.1.213, however, I don't understand how to capture and parse the response. Is this something that should be done solely via LUA? I was under the impression that a response could be acted upon by an event or another action.

Secondly, how do you send different commands based on other actions using the same connection?

Any help would be greatly appreciated. TIA!

Ron
May 2nd, 2015, 03:00 PM
Well typically you use the transport classes with transactions. A transaction holds the part to send and a function that captures the return value. The simpleSendAndReceive example basically cuts that down and provides a way to send and receive without transactions (not what you usually want doing a driver ). To receive data you have to copy the lua file and implement the onDataReceived function to do what you want.

The GlobalCache or PIO-1 plugin are examples of how transactions would work. The manual shows (http://promixis.com/man/g6/?transport_pio1_example.html) how to do it.