I have a web application that will constantly post some queries and get replies from a device through the serial port on Raspberry Pi. Like this:
@cherrypy.expose def login (self, **data): passcode = data.get("passcode", None) print "logging in using passcode %s"%passcode ,type(passcode) import serial import time #open connection serialport=serial.Serial ("/dev/ttyAMA0", 9600, timeout=0.5) #write in user sign in code serialport.write("\x03LI%s\x0D"%passcode) reply=serialport.readlines(1) print reply, type(reply) #check if log in success if not "00" in reply: if "FE" in reply: state="engineer" else: state="user" else: state="none" print state time.sleep(1) return state
Currently I am using direct 3 wires (gnd, txd, rxd) from Raspberry Pi to the device's (gnd, rxd, txd). The serial port of Raspberry Pi is /dev/ttyAMA0 and say the device has an IP of 10.0.0.55. i could send netcat command one at a time like this:
nc 10.0.0.55 1001 ^CLI1234^M //this is an example of the serial command sent to the device from Raspberry Pi terminal
How should i do it with
socat? I don't want to change the script but just to manipulate some configuration in socat (or something else) that would forward the command to the device's IP. I want to get rid of the 3 wires connected to R-Pi UART. i hardly find examples on socat that would suit this requirement (or may be i don't know what keyword i should use). Please enlighten me :) Thanks a lot!