Re: Threaded access to serial port under Windows
- From: "Jason Sheets" <jason.sheets@xxxxxx>
- Date: Wed, 21 Mar 2007 17:07:32 -0600
Thanks for the reply
Maybe you can help with a better design, I am talking to a hardware device
in an async way, I need to have fileevent work without blocking the
execution of the main thread. . The hardware device both responds to our
commands and can also send unsolicited pushes which we must handle
So basically the first thread only does writing and the second thread does
mostly reading.
The way we got that to happen was to do this:
<Main Script is started>
- Spins off read thread that uses fileevent to be notified when data
appears on the serial port, uses thread shared variables to give data back
to main thread
<Test Execution occurs here>
We found fileevent only calls us back when in the event loop.
Thanks,
Jason
It works on Linux and HP-UX beautifully but not Windows because we can't
open the port twice.
"Alexandre Ferrieux" <alexandre.ferrieux@xxxxxxxxx> wrote in message
news:1174517891.574172.55050@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Mar 21, 11:33 pm, "Jason Sheets" <jason.she...@xxxxxx> wrote:
Dear TCL Community,
We are developing a tool that needs to have access to a serial port from
two
threads within TCL.
...
Basically I need read/write access to the serial port in 2 threads on
Windows.
It doesn't make sense to have 'simultaneous r/w access' over a common
channel.
Indeed, there is no automagical muxing/demuxing of requests. Writes
may be randomly interleaved (in which case your data granularity had
better be no larger than one byte), but concurrent reads are
completely uncontrollable (which thread gets what bytes ?)
So I guess you mean that each of your 2 threads, in turn, does a
complete transaction, including a write and a read, and that no
unsollicited event comes down the wire outside the transactions. In
this case you'd better do all your I/O on the channel in thread A, and
when B needs it, delegate to A via normal Tcl interthread
communication.
-Alex
.
- Follow-Ups:
- Re: Threaded access to serial port under Windows
- From: Rolf Schroedter
- Re: Threaded access to serial port under Windows
- From: Uwe Klein
- Re: Threaded access to serial port under Windows
- From: Massimo Manghi
- Re: Threaded access to serial port under Windows
- From: Alexandre Ferrieux
- Re: Threaded access to serial port under Windows
- References:
- Threaded access to serial port under Windows
- From: Jason Sheets
- Re: Threaded access to serial port under Windows
- From: Alexandre Ferrieux
- Threaded access to serial port under Windows
- Prev by Date: Re: Threaded access to serial port under Windows
- Next by Date: Re: Efficiency of associative arrays?
- Previous by thread: Re: Threaded access to serial port under Windows
- Next by thread: Re: Threaded access to serial port under Windows
- Index(es):
Relevant Pages
|