I didn't fully think through my application before posting my
question. Async com port routines to handle com port interrups
only work well if one has access to the low level operating
system. In that case the receive buffer interrupt would cause
a jump to an interrupt service routine.. I don't believe that
Python provides that capabilty directly. The solution then would
be to write a C extention?
The suggestions offered by respondents to my original post
were almost all of a "Use threads, and poll as needed" flavor.
You're right...I need to learn threads as applied to com ports.
Norm B 6 1999
engsol wrote: I didn't fully think through my application before posting my question. Async com port routines to handle com port interrups only work well if one has access to the low level operating system. In that case the receive buffer interrupt would cause a jump to an interrupt service routine.. I don't believe that Python provides that capabilty directly. The solution then would be to write a C extention?
Maybe, but I doubt that you can or would really want to do this
with modern operating systems anyway. With DOS, and similar
primitive things, glomming onto an interrupt or hooking yourself
into the interrupt table was pretty easy. I don't think either
Windows or Linux is structured such that you just "write a
C extension" to intercept interrupts. Instead, you must write
relatively complicated drivers which have to be loaded at
system startup (more or less) and be tied into the kernel at
a relatively low level. Think "rocket science", at least in
comparison to writing a simple C extension. :-)
The suggestions offered by respondents to my original post were almost all of a "Use threads, and poll as needed" flavor. You're right...I need to learn threads as applied to com ports.
At least on Windows, I'm fairly sure you can configure the
read timeouts so that you get behaviour on reads that for
all intents and purposes is about as good as an interrupt,
without the difficulties inherent in that approach, but
provided you are willing to dedicate a thread to the task.
On Linux, it's possible the read timeouts capabilities are
a little less flexible (but I've only just barely glanced
at this area), but as I recall you were on Windows anyway.
BTW, another post pointed you to USPP. As far as I know,
it hasn't been updated recently and, while I can't say how
it compares to PySerial, I believe it's fair to say at
this point in time that PySerial is the _de facto_ standard
way to do serial port stuff in Python. If it doesn't do
what you need, it's probably a good idea to at least point
that out in its mailing list so that it can be improved.
-Peter
engsol <en********@peak.org> wrote in
news:15********************************@4ax.com: I didn't fully think through my application before posting my question. Async com port routines to handle com port interrups only work well if one has access to the low level operating system. In that case the receive buffer interrupt would cause a jump to an interrupt service routine.. I don't believe that
i would not go that route... the operating system provides sync and async
methods to access the serial port. it would make sense to use these before
hacking the operating system. (also see below)
Python provides that capabilty directly. The solution then would be to write a C extention?
ctypes can do many things without a C compiler. it's a very nice an
valuable extension, but i won't like to encurage to use it for this
particular problem.
The suggestions offered by respondents to my original post were almost all of a "Use threads, and poll as needed" flavor. You're right...I need to learn threads as applied to com ports.
if you realy want to do async programming, have a look at twisted
( http://twistedmatrix.com). it does not only provide async access to the
serial port (trough pyserial + some code in twisted) it also delivers some
nice utility functions, classes etc, like the reactor, defereds, thread
pools (if you can't resist ;-) and many protocol handlers.
chris
--
Chris <cl******@gmx.net>
On Fri, 14 Jan 2005 23:25:21 -0500, Peter Hansen <pe***@engcorp.com> wrote: engsol wrote: I didn't fully think through my application before posting my question. Async com port routines to handle com port interrups only work well if one has access to the low level operating system. In that case the receive buffer interrupt would cause a jump to an interrupt service routine.. I don't believe that Python provides that capabilty directly. The solution then would be to write a C extention?
Maybe, but I doubt that you can or would really want to do this with modern operating systems anyway. With DOS, and similar primitive things, glomming onto an interrupt or hooking yourself into the interrupt table was pretty easy. I don't think either Windows or Linux is structured such that you just "write a C extension" to intercept interrupts. Instead, you must write relatively complicated drivers which have to be loaded at system startup (more or less) and be tied into the kernel at a relatively low level. Think "rocket science", at least in comparison to writing a simple C extension. :-)
The suggestions offered by respondents to my original post were almost all of a "Use threads, and poll as needed" flavor. You're right...I need to learn threads as applied to com ports.
At least on Windows, I'm fairly sure you can configure the read timeouts so that you get behaviour on reads that for all intents and purposes is about as good as an interrupt, without the difficulties inherent in that approach, but provided you are willing to dedicate a thread to the task.
On Linux, it's possible the read timeouts capabilities are a little less flexible (but I've only just barely glanced at this area), but as I recall you were on Windows anyway.
BTW, another post pointed you to USPP. As far as I know, it hasn't been updated recently and, while I can't say how it compares to PySerial, I believe it's fair to say at this point in time that PySerial is the _de facto_ standard way to do serial port stuff in Python. If it doesn't do what you need, it's probably a good idea to at least point that out in its mailing list so that it can be improved.
-Peter
Peter, thanks for the input...good advice. I took a look at USPP,
and as you observed, it seems to be a bit dated.
Actually, I've violated one of my basic rules: do it the simple way
first, then determine what needs to be expanded, improved, speeded up,
etc.
Norm B
On Sat, 15 Jan 2005 19:38:19 +0000 (UTC), Chris Liechti <cl******@gmx.net> wrote: engsol <en********@peak.org> wrote in news:15********************************@4ax.com :
I didn't fully think through my application before posting my question. Async com port routines to handle com port interrups only work well if one has access to the low level operating system. In that case the receive buffer interrupt would cause a jump to an interrupt service routine.. I don't believe that
i would not go that route... the operating system provides sync and async methods to access the serial port. it would make sense to use these before hacking the operating system. (also see below)
Python provides that capabilty directly. The solution then would be to write a C extention?
ctypes can do many things without a C compiler. it's a very nice an valuable extension, but i won't like to encurage to use it for this particular problem.
The suggestions offered by respondents to my original post were almost all of a "Use threads, and poll as needed" flavor. You're right...I need to learn threads as applied to com ports.
if you realy want to do async programming, have a look at twisted (http://twistedmatrix.com). it does not only provide async access to the serial port (trough pyserial + some code in twisted) it also delivers some nice utility functions, classes etc, like the reactor, defereds, thread pools (if you can't resist ;-) and many protocol handlers.
chris
Chris, thanks for the pointer to twisted. I'm a bit snow bound, so it's a
good time to actually read some docs...:)
Norm B This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mathew |
last post by:
I am looking to write a program with Microsoft Visual Basic 6 that
writes out to the com port. After the inital Connection. I will be
connecting at 9600, 8 data bits, with hardware flow control. ...
|
by: engsol |
last post by:
Has anyone done a script that will rspond to the serial com port(s)
receive buffer interrupt, as opposed to polling and timeouts?
Win2000 is the main interest right now.
Thanks
Norm B
|
by: Keith |
last post by:
I am trying to write a simple FTP client, but I am having
trouble with the PORT Command. Does anyone know how to
Get an IP Address and port number to establish a data port
for the server to...
|
by: Larry Woods |
last post by:
I have multiple Calendar controls on my page and I want the user to select
various dates, then press a Submit button. Is there a way to disable the
interrupts from the Calendar controls?
TIA,
...
|
by: Liu Ju |
last post by:
Dear members:
I need to write a program in Visual C++ platform that trasmit data
through the COM port.
The task would be as follows:
Whenever the peripheral device sents 1 byte to the computer...
|
by: CdiVer |
last post by:
how do we programme other ports outthere than THe printer port and how
do we know the CONTROL PINS READING PINS AND OUTPUT PINS and also I
there a way to programme the USB PORTS
|
by: Rob |
last post by:
Hi all,
I am fairly new to python, but not programming and embedded. I am
having an issue which I believe is related to the hardware, triggered
by the software read I am doing in pySerial. I...
|
by: Gabriel Genellina |
last post by:
En Mon, 21 Apr 2008 01:09:59 -0300, kapardhi bvn <kapardhib@gmail.comescribió:
See pyparallel (part of the pyserial package)
--
Gabriel Genellina
|
by: JKaur |
last post by:
hello frnds,
please tell me the difference between DOS interrupts and interrupts invoked using int86() function in C (are those 8086 intrupts?). In some text i have read these are different, but...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |