Print

Print


Van and Everyone Else:

            I am not familiar with any of the various flavors of Linux nor with USB
devices, but here are a few thoughts about your problem.  I hope that you find at least
some of them to be useful.

 

            Linux-USB Web Site.  I did a Google search on "ACM compliant USB device".
Among the first few listings is an entire web site devoted to how to use USB devices under
Linux.  It is:  http://www.linux-usb.org/.   On this site, the specific web page,
http://www.linux-usb.org/USB-guide/c122.html,  contains information about "How to get USB
devices working under Linux; Basic USB Configuration".  Other pages on this web site may
also prove to be useful.

 

            Meaning of ACM.  The web site, www.jungo.com, has a page that says that ACM
means, "Abstract Control Model".  Jungo also contains a lot of other useful information.

 

            Kind of USB Device.  What kind of USB device are you using?  Your message does
not say.  Is it a thumb drive?  IF so, it should have a file structure.  If it's some
other kind of device, then you need to RTFM for that device.

 

            Use IOSTAT and IOMSG.  You should be using the IOSTAT and IOMSG keywords with
their appropriate variables on all of your I/O statements.  I noticed that you are not
using them on the READ and WRITE statements.  You should include these keywords and write
out their values to standard output after each I/O operation so that you can see what is
going on.

 

            Rewind Needed?  I noticed that your READ statement from unit 10 is attempting
to read beyond what you wrote in your write statement.  Does the behavior of your program
change if you have a REWIND statement after the WRITE statement and before the READ
statement?

 

            Hope this helps.  Please feel free to contact me at any time with any
questions or concerns that you may have.  I am looking forward to hearing from you soon.

 

Sincerely,

Craig T. Dedo

17130 W. Burleigh Place

P. O. Box 423                         Mobile Phone:  (414) 412-5869

Brookfield, WI   53008-0423    E-mail:  < <mailto:[log in to unmask]> [log in to unmask]>

USA

Linked-In:   <http://www.linkedin.com/in/craigdedo> http://www.linkedin.com/in/craigdedo

> -----Original Message-----

> From: Fortran 90 List [mailto:[log in to unmask]] On Behalf Of Van

> Snyder

> Sent: Wednesday, November 23, 2011 01:06

> To: [log in to unmask]

> Subject: Communicate with USB device in Linux using Fortran?

> 

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