Your problem is not twisted, but in python. Read this entry in the FAQ:
How to make a conclusion on one result of connecting output to another?
The thing is, if you want to send material to a client connected to TCP in your serial protocol, just pass the factory link to the protocol so that you can use this link to create the bridge.
Here is an example of code that roughly does this:
class USBClient(Protocol): def __init__(self, network): self.network = network def dataReceived(self, data): print "Data received", repr(data)
When initializing, pass the link:
tcpfactory = CommandRxFactory() reactor.listenTCP(8000, tcpfactory) SerialPort(USBClient(tcpfactory), 'COM8', reactor, baudrate='19200') reactor.run()
source share