Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Com port interrupts again

Reply
Thread Tools

Com port interrupts again

 
 
engsol
Guest
Posts: n/a
 
      01-14-2005
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
 
Reply With Quote
 
 
 
 
wittempj@hotmail.com
Guest
Posts: n/a
 
      01-14-2005
A search on google gave me this library, I haven't tested it though:
http://groups-beta.google.com/group/...1074d7bd94be63

 
Reply With Quote
 
 
 
 
engsol
Guest
Posts: n/a
 
      01-14-2005
Thanks much..

On 14 Jan 2005 12:25:43 -0800, "" <> wrote:

>A search on google gave me this library, I haven't tested it though:
>http://groups-beta.google.com/group/...1074d7bd94be63


 
Reply With Quote
 
Peter Hansen
Guest
Posts: n/a
 
      01-15-2005
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
 
Reply With Quote
 
Chris Liechti
Guest
Posts: n/a
 
      01-15-2005
engsol <> wrote in
news::

> 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 <>

 
Reply With Quote
 
engsol
Guest
Posts: n/a
 
      01-15-2005
On Fri, 14 Jan 2005 23:25:21 -0500, Peter Hansen <> 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

 
Reply With Quote
 
engsol
Guest
Posts: n/a
 
      01-15-2005
On Sat, 15 Jan 2005 19:38:19 +0000 (UTC), Chris Liechti <> wrote:

>engsol <> wrote in
>news: :
>
>> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
NAT table entries generate Interrupts? anybody43@hotmail.com Cisco 0 10-31-2005 11:06 AM
Microblaze XPS Gpio not working with interrupts guru10 VHDL 1 08-18-2005 07:25 PM
pyserial and com port interrupts engsol Python 8 01-13-2005 01:37 PM
MicroBlaze User Peripheral with 2 interrupts Ciaran VHDL 12 02-27-2004 01:37 PM
Interrupts in VB (API) D.Sn ASP .Net 2 01-12-2004 03:56 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57