Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #88733 > unrolled thread
| Started by | Travis Griggs <travisgriggs@gmail.com> |
|---|---|
| First post | 2015-04-09 09:14 -0700 |
| Last post | 2015-04-09 16:28 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [SerialConnection] Help Travis Griggs <travisgriggs@gmail.com> - 2015-04-09 09:14 -0700
Re: [SerialConnection] Help Grant Edwards <invalid@invalid.invalid> - 2015-04-09 16:28 +0000
| From | Travis Griggs <travisgriggs@gmail.com> |
|---|---|
| Date | 2015-04-09 09:14 -0700 |
| Subject | Re: [SerialConnection] Help |
| Message-ID | <mailman.172.1428596110.12925.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
> On Apr 7, 2015, at 8:42 AM, Hugo Caldas <hcaldas92@gmail.com> wrote: > > read and write the port values with multi threading Care to elaborate what you mean by this part? In general, serial ports and multi threading don’t mix well. IOW, you’ll need to use multithreading pieces to make sure you serialize your access to your serial port. As other have pointed out, pyserial is the package you want. Documentation is pretty good. We use it a lot.
[toc] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2015-04-09 16:28 +0000 |
| Message-ID | <mg69ba$rsa$1@reader1.panix.com> |
| In reply to | #88733 |
On 2015-04-09, Travis Griggs <travisgriggs@gmail.com> wrote:
>
>> On Apr 7, 2015, at 8:42 AM, Hugo Caldas <hcaldas92@gmail.com> wrote:
>>
>> read and write the port values with multi threading
>
> Care to elaborate what you mean by this part? In general, serial
> ports and multi threading don’t mix well. IOW, you’ll need to use
> multithreading pieces to make sure you serialize your access to your
> serial port.
One thing that does work well (and is used by lots of apps) is to use
one thread for reading and a different thread for writing. If that's
what you want to do, then you don't need to add any mutexes or any
sort of application-level serialization.
At least on Unix, the basic read/write calls should be thread-safe,
_but_not_necessarily_atomic_.
If two threads call write() "at the same time", all the data will go
out, and the order of bytes within each written block will be
preserved, but there's no guarantee that the blocks won't get
interleaved.
If you've got two threads blocking on a read, only one thread will
read any particular byte of data, but there's no guarantee which bytes
will go to which thread.
> As other have pointed out, pyserial is the package you want.
> Documentation is pretty good. We use it a lot.
--
Grant Edwards grant.b.edwards Yow! Don't hit me!! I'm in
at the Twilight Zone!!!
gmail.com
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web