![]() ![]() #Profantasy Torrent serial#The only 'easy' serial port programming on Windows is the VB MSCOMM control, which does have an event handler (ONE handler, requiring long case/if logic to determine if it is input/output or error). It was NOT pretty (and basically came down to the same thing - running the I/O in a thread and signaling the main process when data had arrived, using very low-level w32 os calls). ![]() I had to do serial stuff on a W98 laptop in C. Main process would be a loop retrieving data from the queue (use one queue, and package the data with a source Identifier: ('GPS', data-string), ('CMD', command-data) I'd write a C extension to do the serial stuff, but I don't know a thing about Windows programming. The command port probably should read&queue everything. On Thu, 21:55:35 -0600, 'Bob Greschke' declaimed the following in : One of the serial ports (there are actually two) is used to read some NMEA sentences from a GPS. Did I mention it wasn't ready for prime time? If you've ever been annoyed having to do.read(1) to get characters one at a time in PySerial, or.read(100) with a timeout, or whatever, this might be of interest to you. #Profantasy Torrent code#No docs yet, no contrived examples (but various pieces of working code in real daily use). I don't know if this is something that should be contributed to the PySerial project (it's more of a rewrite than an add-on), or set up as a new project, or passed around quietly behind the scenes for a while. And, obviously, to hear back from those interested. #Profantasy Torrent plus#On the plus side, it's been letting me convert my serial stuff to be fully event-driven and with the resulting much lower latencies and better CPU efficiency, while keeping my code more 'traditional' instead of having to force it entirely into the Twisted point of view. It shares a number of features with the Twisted-based PySerial port (also done by Chris Liechti, for the Twisted team, judging by the code comments) but doesn't require one to adopt the whole Twisted framework. On that note, I've got a preliminary version of something I call 'Bent' (think 'slightly Twisted') which is focused for now on providing an asynchronous version of PySerial which is designed around the event-driven model instead of its current polled scheme. The way I get round this is to have a loop polling (in a seperate thread) to see if any data is available (it's a method on the interface), then read all the data in and fire this off to my listeners/observers with the read data. Neil Benn wrote: PySerial doesn t have any kind of event firing to notify you when data is available. Messages can be sent by the GPS even when you didn't ask for one explicitly? If so, then it's possible there are problems even with your current approach: what if you open the port halfway through a packet, and receive only the last few bytes? If it's synchronous (data sent only in response to your requests), then none of this is an issue since there will be no traffic unless you ask for it, so the serial port will be idle between uses. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |