[Twisted-Python] UDP + TCP + Serial
I'm looking for a way to combine serial input with UDP (and possibly TCP) communication. Currently I have a very simple quick-and-dirty script using pyserial and the socket module without Twisted that reads line-based data from a serial port and sends it out using UDP. It works very well, but functional and reliability requirements are growing and I'm looking for a better design. New functionality that we'll need is connection to a database, two-way network communication to control the program while it's running, and perhaps the ability to use encrypted connections for the output data. Twisted seems nice, but apart from a few simple hello-world-style test I don't have any experience with it. It doesn't seem too difficult though, except for one thing: I can't find any concrete information on how to combine serial communication and network communication. What reactor do I need? How do I initialize it? How can I make it listen to both a serial port and one or more UDP and/or TCP ports? I need to do this on Linux, but it would be nice to have it working on Windows too. Many thanks, Roel -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven
Might be that I have something useful for you - please see the attached zipped code. Basic idea was to have a serially connected device accepting commands and delivering status information connected to a browser via a server delivering LiveFragments. A few problems remain open, like: - how does one uniquely connect only one browser capable of sendign commands (the SPS is a single resource) - are other browsers able to connect and do a status display only Forgive me if I did did not use twisted/nevow/athenain in all aspects correctly, but with lots of source/doc re- and rereading I was able to bring it that far. If there are patterns I should avoid or correct I will gladly do so if pointed out to me. Thanks, Werner Roel Schroeven wrote:
I'm looking for a way to combine serial input with UDP (and possibly TCP) communication.
Currently I have a very simple quick-and-dirty script using pyserial and the socket module without Twisted that reads line-based data from a serial port and sends it out using UDP. It works very well, but functional and reliability requirements are growing and I'm looking for a better design. New functionality that we'll need is connection to a database, two-way network communication to control the program while it's running, and perhaps the ability to use encrypted connections for the output data.
Twisted seems nice, but apart from a few simple hello-world-style test I don't have any experience with it. It doesn't seem too difficult though, except for one thing: I can't find any concrete information on how to combine serial communication and network communication. What reactor do I need? How do I initialize it? How can I make it listen to both a serial port and one or more UDP and/or TCP ports? I need to do this on Linux, but it would be nice to have it working on Windows too.
Many thanks, Roel
Werner Thie schreef:
Might be that I have something useful for you - please see the attached zipped code. Basic idea was to have a serially connected device accepting commands and delivering status information connected to a browser via a server delivering LiveFragments.
A few problems remain open, like: - how does one uniquely connect only one browser capable of sendign commands (the SPS is a single resource)
- are other browsers able to connect and do a status display only
Forgive me if I did did not use twisted/nevow/athenain in all aspects correctly, but with lots of source/doc re- and rereading I was able to bring it that far. If there are patterns I should avoid or correct I will gladly do so if pointed out to me.
Thank you for your answer. Sorry for my late answer -- I haven't had much time to respond in the meantime. I will have a look at your code. Cheers, Roel -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven
Thanks Werner. Can be usefull in our project too, trying to connect a X3D ( Interactive 3D ) with mathworks/Simulink model over UDP. Simulink module done runnning in RT-mode, X3D-model done, working on the UDP module to X3D. Hope to have a shared interactive 3D viewer application readdy may 10 -07. BG Sven-Erik Tiberg -----Original Message----- From: twisted-python-bounces@twistedmatrix.com [mailto:twisted-python-bounces@twistedmatrix.com] On Behalf Of Werner Thie Sent: den 20 april 2007 22:29 To: Twisted general discussion Subject: Re: [Twisted-Python] UDP + TCP + Serial Might be that I have something useful for you - please see the attached zipped code. Basic idea was to have a serially connected device accepting commands and delivering status information connected to a browser via a server delivering LiveFragments. A few problems remain open, like: - how does one uniquely connect only one browser capable of sendign commands (the SPS is a single resource) - are other browsers able to connect and do a status display only Forgive me if I did did not use twisted/nevow/athenain in all aspects correctly, but with lots of source/doc re- and rereading I was able to bring it that far. If there are patterns I should avoid or correct I will gladly do so if pointed out to me. Thanks, Werner Roel Schroeven wrote:
I'm looking for a way to combine serial input with UDP (and possibly TCP) communication.
Currently I have a very simple quick-and-dirty script using pyserial and the socket module without Twisted that reads line-based data from a serial port and sends it out using UDP. It works very well, but functional and reliability requirements are growing and I'm looking for a better design. New functionality that we'll need is connection to a database, two-way network communication to control the program while it's running, and perhaps the ability to use encrypted connections for the output data.
Twisted seems nice, but apart from a few simple hello-world-style test
I don't have any experience with it. It doesn't seem too difficult though, except for one thing: I can't find any concrete information on
how to combine serial communication and network communication. What reactor do I need? How do I initialize it? How can I make it listen to
both a serial port and one or more UDP and/or TCP ports? I need to do this on Linux, but it would be nice to have it working on Windows too.
Many thanks, Roel
participants (3)
-
Roel Schroeven
-
Sven-Erik Tiberg
-
Werner Thie