On Wed, 2011-11-23 at 10:22 -0800, Bill Long wrote:
> I assume that the Fortran I/O run time system is expecting to see a file
> system, rather than a hardware device. If you copy a file to the USB
> device, it will probably cause the creation of a file system and
> directory structure. It might then have enough infrastructure to allow
> an OPEN (10,file="/dev/ttyACM0/myfile.txt", status="new", ...).
The device is not a thumb drive. It doesn't have a file system. It has
a tiny computer (a PIC microcontroller) that accepts five messages, and
provides a response to two of them.
> If you want to read after writing, you need to either close and reopen
> the file or rewind it.
Rewind produces "Seek error."
>
> Cheers,
> Bill
>
> On 11/23/11 1:06 AM, Van Snyder wrote:
> > I'm trying to communicate with a USB device in Linux using gfortran 4.4.
> >
> > I don't know what this means, but the device is "ACM compliant." When I
> > plug it in, the system (CentOS 5.5) creates a device /dev/ttyACM0. I
> > can successfully
> > communicate with the device using minicom.
> >
> > The guts of the program are
> >
> > line = '/dev/ttyACM0'
> > open ( 10, file=trim(line), status='old', access='sequential',
> > & form='formatted', iostat=id, iomsg=msg, action='readwrite' )
> > do
> > read ( *, '(a)', end=9 ) line
> > write ( 10, '(a)' ) trim(line) // new_line(line)
> > print *, 'Wrote the line'
> > read ( 10, '(a)', advance='yes' ) line
> > write ( *, '(a)' ) '< ' // trim(line)
> > end do
> > 9 continue
> >
> > Executing the write(10,...) statement produced an "Illegal seek" message.
> >
> > I changed the open statement to
> >
> > open ( 10, file=trim(line), status='old', access='stream',&
> > & form='formatted', iostat=id, iomsg=msg, action='readwrite' )
> >
> > Having done that, the write(10,...) statement appears to have
> > completed. At least, the print statement was executed. The device
> > connected to the USB port was sent a string to which it ought to have
> > responded, and to which it does respond when accessed using minicom.
> >
> > The read(10,...) statement appears not to have completed. At least the
> > statement
> >
> > write ( *, '(a)' ) '< ' // trim(line)
> >
> > was not executed. I tried putting advance='no' in the read(10,...)
> > statement, but that didn't make any difference.
> >
> > Any ideas?
>
|