Raspberry Pi: how to send serial command using Ethernet?
What about using the socat
command? Using the following command line you can make /dev/ttyAMA0
accessible via eth 127.0.0.1:5555
:
socat PTY,link=/dev/ttyAMA0 TCP:127.0.0.1:5555
yvonnezoe
Not too late to learn from the start :) i love arts and start to love programming as well!
Updated on June 26, 2022Comments
-
yvonnezoe almost 2 years
I have a python script, which will start cherrypy webserver when run in the terminal. In the script, i use pyserial by importing
serial
, then i open up the port /dev/ttyAMA0 and i can send any serial commands.@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) #get reply reply=serialport.readlines(1) print reply, type(reply)
However, since there is an Ethernet port and i can send the serial command to that similar device using Netcat, how can i let this script to send commands through the ethernet port instead of the serial port? What should i change?
sorry but i'm really clueless on how to do this. i've searched through google and i can't find answers. :(