convert the ip packet to and from RS-232 packet
exarkun at divmod.com
Mon Feb 9 16:02:06 CET 2009
On Mon, 9 Feb 2009 05:13:10 -0800 (PST), Li Han <lihang9999 at gmail.com> wrote:
>Hi, I need to use radio to connect two local ip network, each local
>network has a server computer which connects to a radio with RS-232
>interface. I need to write a program to convert the local ip packet
>into RS-232 packet, so the radio can send packetes to the remote
>radio. I don't want to reinvent the wheel, is there anyone could give
>me some suggestions?
You can proxy between any two kinds of connection pretty easily with
from twisted.internet import serialport, protocol, reactor
from twisted.protocols import portforward
# Stop the server, since only one thing can talk to the serial port
# at a time.
# Hook up the proxy between this TCP connection and the serial port.
self.peer = portforward.Proxy()
self._serialPort = serialport.SerialPort(self.peer, '/dev/ttyS0', reactor)
factory = protocol.ServerFactory()
factory.protocol = SerialPortServer
tcpPort = reactor.listenTCP(12345, factory)
More information about the Python-list