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?
|