convert the ip packet to and from RS-232 packet

convert the ip packet to and from RS-232 packet

Post by Li Ha » Tue, 10 Feb 2009 22:13:10


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?
Thank you!
Han
 
 
 

convert the ip packet to and from RS-232 packet

Post by Steve Hold » Tue, 10 Feb 2009 22:29:06


There's a package called pyserial that's pretty good at handling RS-232
interfaces. Good luck!

regards
Steve
(G3VEK)
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.yqcomputer.com/

 
 
 

convert the ip packet to and from RS-232 packet

Post by bobicanpro » Tue, 10 Feb 2009 23:43:28


You might want to check out the SIMPL toolkit. (http://
www.icanprogram.com/simpl). It come standard with an RS232
surrogate. This generic module will transparently transmit a SIMPL
message via RS232 serial connection. Although this module is written
in C, SIMPL itself fully supports Python as a language to create
modules.

bob
 
 
 

convert the ip packet to and from RS-232 packet

Post by Jean-Paul » Wed, 11 Feb 2009 00:02:06


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