
When initializing, pass the reference: tcpfactory = CommandRxFactory() Here's some example code that roughly does this: class USBClient(Protocol): Thing is, if you want to send stuff to a TCP-connected client in your serial-connected protocol, just pass to the protocol a reference to the factory, so you can use that reference to make the bridge. How do I make input on one connection result in output on another? Your problem is not about twisted, but about python. SerialPort(USBClient(), 'COM8', reactor, baudrate='19200') Reactor.listenTCP(8000, CommandRxFactory())

#Build command, if ok, send to serial port Print "outReceived! with %d bytes!" % len(data)

#check & perhaps modify response and return to client Print "Data received! with %d bytes!" % len(data) I'm want to take dataReceived from client and send this to modem.I'm struggling to get this to work.Any help will be highly appreciated! the code: from twisted.internet import win32eventreactorįrom import SerialPortįrom import Protocol, FactoryĬlient_list = #TCP clients connecting to me The next piece of code is an infinite loop, which does a few things.I've managed to connect to usb modem and a client can connect via tcp to my reactor.listenTCP,the data received from modem will be send back to client.A port also cannot be accessed if it has not been opened. It is imperative that the open() function is called, because it allows our program to âclaimâ the port and prevent any other processes from accessing it. In our simple program, we first open the serial port defined previously.

