Python Event Driven Serial Port

Oct 27, 2017 - #!/usr/bin/env python import time import serial ser = serial. To use the data being read back to trigger a read on a different serial port (I. There's a different mindset required to move from sequential programs to event driven.
(Feb-14-2017, 04:46 PM)nilamo Wrote: Threads merged. Those of us that are here to help, check all the boards. There's no reason to post in more than one place. Anyway, how are you reading data? Don't most interfaces just block until there's something to read? With this line of code: while true: s = serialport.readline() which is run on the pi with the python script. A serial connection is between the pi and a desktop.
As I type characters on the terminal (Putty) on the desktop, there should be an interrupt to say data is ready or a flag maybe. I dont want always listen to the serial port (Polling). (Feb-15-2017, 06:43 AM)trainee1 Wrote: (Feb-14-2017, 04:46 PM)nilamo Wrote: Threads merged. Those of us that are here to help, check all the boards.
There's no reason to post in more than one place. Anyway, how are you reading data? Don't most interfaces just block until there's something to read?
With this line of code: while true: s = serialport.readline() which is run on the pi with the python script. A serial connection is between the pi and a desktop.
As I type characters on the terminal (Putty) on the desktop, there should be an interrupt to say data is ready or a flag maybe. I dont want always listen to the serial port (Polling). Start a thread that waits on a read of the serial port.
Grant Edwards Cool. At first I thought you must be a newbie who doesn't know what's inside his own computer -- then I noticed your e-mail address.:) Under Unix, serial I/O is generally done using the modules that wrap the standard Posix termios interface. If you know how to do what you want in C, then just take a look at the TERMIOS, termios, and os or posix modules. Note that you need to use the termios stuff with file descriptors as returned by os.open(), and not with Python file objects as returned.
I don't know whether serial port stuff has been enabled yet for this environment. If you know how Python deals with serial ports on other Linux environments, that would at least give me a path to look down.Under Unix, serial I/O is generally done using the modules that wrap the standard Posix termios interface.
If you know how to do what you want in C, then just take a look at the TERMIOS, termios, and os or posix modules. Note that you need to use the termios stuff with file descriptors as returned by os.open(), and not with Python file objects as returned by the built-in open(). Under Win32, there's a serial-IO module that impliments serial-port objects in a completely different manner. I don't know about MacOS, VMS, etc. Pehr anderson I had started on this some months ago, but ended up needing *many* serial ports, so rather than juggling PCs we used Lantronix serial port terminal serers. 16 ports in a very small box! You just telnet to the right port to set up a connection.
As for what would be the right long term solution. Is there a best-in-class serial API that should be cloned?
What do people think of the RXTX package for Java? I'd really like to work on consolidating cross-platform APIs for Audio (using pyesd) and USB. I had started on this some months ago, but ended up needing *many* serial ports, so rather than juggling PCs we used Lantronix serial port terminal serers. 16 ports in a very small box! You just telnet to the right port to set up a connection.
As for what would be the right long term solution. Is there a best-in-class serial API that should be cloned? What do people think of the RXTX package for Java? Launch x431 scan tool.
I'd really like to work on consolidating cross-platform APIs for Audio (using pyesd) and USB (using libusb). -pehr Warren Postma wrote. Peter Hansen I agree this is bad, and have thought so since I encountered the same problem with Java, early on. At the time, and I think perhaps still now, nobody had yet created anything that would be a deserving candidate for the title 'standard serial module for both Unix and Win32'. I made a very crufty one for Win32, in the process learning many Windows-specific things which I still shudder over as I recall. Hideous problems with lost characters when run from a DOS window, for example, but not when run.