On Mon, 9 Feb 2009 05:13:10 -0800 (PST), Li Han <lihang9...@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 Twisted (untested): from twisted.internet import serialport, protocol, reactor from twisted.protocols import portforward class SerialPortServer(portforward.Proxy): def connectionMade(self): # Stop the server, since only one thing can talk to the serial port # at a time. tcpPort.stopListening() # Hook up the proxy between this TCP connection and the serial port. self.peer = portforward.Proxy() self.peer.setPeer(self) self._serialPort = serialport.SerialPort(self.peer, '/dev/ttyS0', reactor) factory = protocol.ServerFactory() factory.protocol = SerialPortServer tcpPort = reactor.listenTCP(12345, factory) reactor.run() Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list