Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39101 > unrolled thread
| Started by | mikprog@gmail.com |
|---|---|
| First post | 2013-02-18 07:12 -0800 |
| Last post | 2013-02-19 05:39 -0800 |
| Articles | 6 on this page of 26 — 7 participants |
Back to article view | Back to comp.lang.python
improving performance of writing into a pipe mikprog@gmail.com - 2013-02-18 07:12 -0800
Re: improving performance of writing into a pipe Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-18 15:21 +0000
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-18 08:31 -0800
Re: improving performance of writing into a pipe Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-02-18 17:49 +0100
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-18 09:00 -0800
Re: improving performance of writing into a pipe Michael Torrie <torriem@gmail.com> - 2013-02-18 11:12 -0700
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 01:24 -0800
Re: improving performance of writing into a pipe Peter Otten <__peter__@web.de> - 2013-02-19 10:55 +0100
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 02:27 -0800
Re: improving performance of writing into a pipe Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-19 11:15 +0000
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 02:27 -0800
Re: improving performance of writing into a pipe Michael Torrie <torriem@gmail.com> - 2013-02-19 10:47 -0700
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-20 09:54 -0800
Re: improving performance of writing into a pipe John Gordon <gordon@panix.com> - 2013-02-20 18:39 +0000
Re: improving performance of writing into a pipe Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-20 22:05 +0000
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-20 09:54 -0800
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 01:24 -0800
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-18 08:31 -0800
Re: improving performance of writing into a pipe Serhiy Storchaka <storchaka@gmail.com> - 2013-02-18 21:29 +0200
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 04:10 -0800
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 04:10 -0800
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 05:39 -0800
Re: improving performance of writing into a pipe Peter Otten <__peter__@web.de> - 2013-02-19 14:57 +0100
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 06:38 -0800
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 06:38 -0800
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 05:39 -0800
Page 2 of 2 — ← Prev page 1 [2]
| From | mikprog@gmail.com |
|---|---|
| Date | 2013-02-19 04:10 -0800 |
| Message-ID | <mailman.2017.1361275844.2939.python-list@python.org> |
| In reply to | #39119 |
On Monday, February 18, 2013 7:29:09 PM UTC, Serhiy Storchaka wrote:
> On 18.02.13 17:12, mikprog@gmail.com wrote:
>
> > on an embedded linux system (BeagleBoard) I am writing data coming from bluetooth dongle into a pipe.
>
> > The function is the following one:
>
> >
>
> >
>
> > def write_to_pipe(line):
>
> >
>
> > # next line ensures that bytes like '0x09' are not translated into '\t' for
>
> > #example, and they are sent as such
>
> > hexbytes = "\\x" + "\\x".join([hex(ord(c))[2:].zfill(2) for c in line])
>
> > wrap = ["echo -en '", "' > /tmp/mypipe"]
>
> > msg = hexbytes.join(wrap)
>
> > print "DBG: sending: ", msg
>
> >
>
> > try:
>
> > os.popen( msg )
>
> > except:
>
> > print "Error: write_to_pipe has failed!"
>
> >
>
> >
>
> > Now I typically receive 4 bytes from the bluetooth dongle and that is fine.
>
> > However when I receive many more than that it seems that the writing into the pipe is too slow.
>
> >
>
> > Is there any clever/obvious way to improve the code above?
>
> > (I am quite sure there is to be honest).
>
>
>
> def write_to_pipe(line):
>
> hexbytes = ''.join('\\x%02x' % ord(c) for c in line)
>
> with open('/tmp/mypipe', 'w') as f:
>
> f.write(hexbytes)
I'll take your hexbytes = '' line (which is surely more efficient than mine).
However whit this approach open + write it seems the pipe doesn't get the data...
I am not sure what is going on.
At this point I suspect it could be a problem on the pipe itself (which I inherited).
It is just weird that the pipe accept this correctly:
wrap = ["echo -en '", "' > /tmp/midi"]
msg = hexbytes.join(wrap)
os.popen( msg )
but seems to be careless of approach open + write.
I need to investigate there.
Thanks a lot, to you and to everyone else.
Mik
[toc] | [prev] | [next] | [standalone]
| From | mikprog@gmail.com |
|---|---|
| Date | 2013-02-19 05:39 -0800 |
| Message-ID | <80a7799b-5a4b-488c-8d8e-8508f13d431a@googlegroups.com> |
| In reply to | #39119 |
>
> def write_to_pipe(line):
>
> hexbytes = ''.join('\\x%02x' % ord(c) for c in line)
>
> with open('/tmp/mypipe', 'w') as f:
>
> f.write(hexbytes)
Update:
with a fix in the pipe THIS was the right way to do it, and it now works.
Thanks a lot Serhiy to you and to everyone else.
Mik
[toc] | [prev] | [next] | [standalone]
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2013-02-19 14:57 +0100 |
| Message-ID | <mailman.2026.1361282390.2939.python-list@python.org> |
| In reply to | #39218 |
mikprog@gmail.com wrote:
>> def write_to_pipe(line):
>> hexbytes = ''.join('\\x%02x' % ord(c) for c in line)
I thought this was only needed to have 'echo' except your data.
>> with open('/tmp/mypipe', 'w') as f:
>> f.write(hexbytes)
> Update:
> with a fix in the pipe THIS was the right way to do it, and it now works.
> Thanks a lot Serhiy to you and to everyone else.
Do you mind telling us what fix you applied?
[toc] | [prev] | [next] | [standalone]
| From | mikprog@gmail.com |
|---|---|
| Date | 2013-02-19 06:38 -0800 |
| Message-ID | <e94968f6-66e8-444a-9723-83754d1b4ac7@googlegroups.com> |
| In reply to | #39223 |
> > Thanks a lot Serhiy to you and to everyone else. > > > Do you mind telling us what fix you applied? Oh, apologies Peter, I thought it was clear as I posted it after the lines written by Serhiy. So it was what Serhiy suggest in addition to some (?minor?) modification to the pipe itself, which I cannot comment about as I don't have access to it. But apparently the problem of not being able to open it was due to it. (It does not help much I am afraid... but that's all I know). Mik
[toc] | [prev] | [next] | [standalone]
| From | mikprog@gmail.com |
|---|---|
| Date | 2013-02-19 06:38 -0800 |
| Message-ID | <mailman.2027.1361284717.2939.python-list@python.org> |
| In reply to | #39223 |
> > Thanks a lot Serhiy to you and to everyone else. > > > Do you mind telling us what fix you applied? Oh, apologies Peter, I thought it was clear as I posted it after the lines written by Serhiy. So it was what Serhiy suggest in addition to some (?minor?) modification to the pipe itself, which I cannot comment about as I don't have access to it. But apparently the problem of not being able to open it was due to it. (It does not help much I am afraid... but that's all I know). Mik
[toc] | [prev] | [next] | [standalone]
| From | mikprog@gmail.com |
|---|---|
| Date | 2013-02-19 05:39 -0800 |
| Message-ID | <mailman.2022.1361281202.2939.python-list@python.org> |
| In reply to | #39119 |
>
> def write_to_pipe(line):
>
> hexbytes = ''.join('\\x%02x' % ord(c) for c in line)
>
> with open('/tmp/mypipe', 'w') as f:
>
> f.write(hexbytes)
Update:
with a fix in the pipe THIS was the right way to do it, and it now works.
Thanks a lot Serhiy to you and to everyone else.
Mik
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.python
csiph-web