9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] python read problem
@ 2010-08-27  0:18 Michaelian Ennis
  2010-08-27  0:34 ` erik quanstrom
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Michaelian Ennis @ 2010-08-27  0:18 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

I've noticed some behaviors I can't explain with python and plan9.  I
am using contrib/installed bichued/python.  Trying to read from a
serial port I would suspect I would have to use f.read() if I want to
be able to catch a specific string where there is no newline.

For instance:
When my firewall is finished booting it end with this output:

Type help or '?' for a list of available commands.
firewall>

"firewall>" being the command prompt.  I would expect to see the same from:

import sys
f = open("/dev/eia0","r")
while (True):
     sys.stdout.write(f.read(1))

Yet this only yields:
Type help or '?' for a list of available commands.

Which makes me think it is still looking for a newline.  Cons exhibits
the expected behavior with the same appliance. That is the prompt is
included.

ian



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] python read problem
  2010-08-27  0:18 [9fans] python read problem Michaelian Ennis
@ 2010-08-27  0:34 ` erik quanstrom
  2010-08-27  2:04 ` Federico G. Benavento
  2010-08-27  9:47 ` Fernan Bolando
  2 siblings, 0 replies; 5+ messages in thread
From: erik quanstrom @ 2010-08-27  0:34 UTC (permalink / raw)
  To: 9fans

> import sys
> f = open("/dev/eia0","r")
> while (True):
>      sys.stdout.write(f.read(1))
>
> Yet this only yields:
> Type help or '?' for a list of available commands.

have you tried redirecting the output of this to
a file, then using xd / wc to make sure that funny characters
aren't causing ... funny output?

- erik



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] python read problem
  2010-08-27  0:18 [9fans] python read problem Michaelian Ennis
  2010-08-27  0:34 ` erik quanstrom
@ 2010-08-27  2:04 ` Federico G. Benavento
  2010-08-27 16:31   ` Michaelian Ennis
  2010-08-27  9:47 ` Fernan Bolando
  2 siblings, 1 reply; 5+ messages in thread
From: Federico G. Benavento @ 2010-08-27  2:04 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

ok, con(1) does more than just dial, read and write,
it might also do rlogin...

does a C version of your script behave as expected?
what about dd -bs 1 -if  /dev/eai0 ?

as for new lines there's also a "rU" mode...

On Thu, Aug 26, 2010 at 9:18 PM, Michaelian Ennis <mennis@corvus.net> wrote:
> I've noticed some behaviors I can't explain with python and plan9.  I
> am using contrib/installed bichued/python.  Trying to read from a
> serial port I would suspect I would have to use f.read() if I want to
> be able to catch a specific string where there is no newline.
>
> For instance:
> When my firewall is finished booting it end with this output:
>
> Type help or '?' for a list of available commands.
> firewall>
>
> "firewall>" being the command prompt.  I would expect to see the same from:
>
> import sys
> f = open("/dev/eia0","r")
> while (True):
>     sys.stdout.write(f.read(1))
>
> Yet this only yields:
> Type help or '?' for a list of available commands.
>
> Which makes me think it is still looking for a newline.  Cons exhibits
> the expected behavior with the same appliance. That is the prompt is
> included.
>
> ian
>
>



-- 
Federico G. Benavento



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] python read problem
  2010-08-27  0:18 [9fans] python read problem Michaelian Ennis
  2010-08-27  0:34 ` erik quanstrom
  2010-08-27  2:04 ` Federico G. Benavento
@ 2010-08-27  9:47 ` Fernan Bolando
  2 siblings, 0 replies; 5+ messages in thread
From: Fernan Bolando @ 2010-08-27  9:47 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Fri, Aug 27, 2010 at 8:18 AM, Michaelian Ennis <mennis@corvus.net> wrote:
> I've noticed some behaviors I can't explain with python and plan9.  I
> am using contrib/installed bichued/python.  Trying to read from a
> serial port I would suspect I would have to use f.read() if I want to
> be able to catch a specific string where there is no newline.
>
> For instance:
> When my firewall is finished booting it end with this output:
>
> Type help or '?' for a list of available commands.
> firewall>
>
> "firewall>" being the command prompt.  I would expect to see the same from:
>
> import sys
> f = open("/dev/eia0","r")
> while (True):
>     sys.stdout.write(f.read(1))
>
> Yet this only yields:
> Type help or '?' for a list of available commands.
>
> Which makes me think it is still looking for a newline.  Cons exhibits
> the expected behavior with the same appliance. That is the prompt is
> included.
>
> ian
>
>

Not sure but might be related.
in C you need do fflush because of the buffered io.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] python read problem
  2010-08-27  2:04 ` Federico G. Benavento
@ 2010-08-27 16:31   ` Michaelian Ennis
  0 siblings, 0 replies; 5+ messages in thread
From: Michaelian Ennis @ 2010-08-27 16:31 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Thu, Aug 26, 2010 at 10:04 PM, Federico G. Benavento
<benavento@gmail.com> wrote:

> what about dd -bs 1 -if  /dev/eai0 ?
This (while ridiculously slow) works correctly.

> as for new lines there's also a "rU" mode...

both
f = open("/dev/eia1","rU")
and
f = open("/dev/eia1","rU",0)

exhibit the same undesirable behavior.  As does when issuing f.flush()
before or after the f.read() in this loop.

ian



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-08-27 16:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-27  0:18 [9fans] python read problem Michaelian Ennis
2010-08-27  0:34 ` erik quanstrom
2010-08-27  2:04 ` Federico G. Benavento
2010-08-27 16:31   ` Michaelian Ennis
2010-08-27  9:47 ` Fernan Bolando

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).