Re: device IO

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Mon 13 Jun 2005 10:46:20 AM GMT
Message-ID: <42AD63FC.10704@icparc.ic.ac.uk>
Joe Pfeiffer wrote:
> I'm attempting to use legolog
> (http://www.cs.toronto.edu/cogrobo/Legolog/) and eclipse to
> communicate with a Lego RCX, using the Lego USB infrared tower.
> 
> The device is opened as a stream, commands are written to it, and
> sensor values are read from it.  Commands are written using the
> following bottom-level code:
> 
> % putRcxByte(+Ascii): Sends Ascii character to Rcx using infrared tower
> putRcxByte(Ascii) :-
>     rcxStream(Rcx),
>     put(Rcx, Ascii),
>     flush(Rcx).
> 
> flush appears to be implemented internally using an lseek system call
> (based on output of strace).  Unfortunately, the driver for this
> device (as well as other non file-like devices) is not seekable, so
> the flush causes an abort (I have verified that hacking the driver to
> do nothing but return success on an lseek solves the problem, but not
> in an acceptable way).
> 
> So...  is there a way around this?

I suppose you are currently opening the device in update-mode, which
I believe causes this problem.  Try opening two separate streams,
one in read mode, one in write mode, that should reliably stop
Eclipse from trying to seek before flushing.


> I haven't found a flavor of open
> that simply opens the stream with no buffering (this would be my first
> choice);

There is indeed no way to do that currently, I'll take that down
as an enhancement request...


> am I stuck doing the device IO in C?  Note that an implicit
> flush won't help, as commands don't necessarily end with a newline.
> 
> Thanks!
> 


-- 
  Joachim Schimpf              /             phone: +44 20 7594 8187
  IC-Parc                     /      mailto:J.Schimpf@imperial.ac.uk
  Imperial College London    /    http://www.icparc.ic.ac.uk/eclipse
Received on Mon Jun 13 11:51:42 2005

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:37 PM GMT GMT