Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29236 Discussions

How do I read in USB data from an external device?

WSinc
New Contributor I
951 Views
I was wondering if there is a special set of routines for that.

Would one use an OPEN of the USB port, or READ statements to get the raw bytes in,
or is something special needed?

Is this even possible using Fortran 2003?

Maybe an article broaching that subject is out there already?

Thanks; Bill S.
0 Kudos
4 Replies
Paul_Curtis
Valued Contributor I
951 Views
Windows virtualizes USB and similar storage devices so they may be accessed in exactly the same manner as disk drives. From fortran, use the complete path name to the device as the filename, ie
OPEN (unit=unit_id, file='e:\myfile.ext',...)
0 Kudos
Steven_L_Intel1
Employee
951 Views
What type of external device is this? Indeed, for a USB disk drive it is just another drive, but for anything else (say, a GPS receiver or scanner), access through a device driver will be needed. Unless it appears as a named drive or device in Windows, you won't be able to just open it.
0 Kudos
WSinc
New Contributor I
951 Views
In this case, it is a MIDI keyboard sending bytes over thru the USB port.


Anyway, as you said, ir's not referenced like a file on a disk drive, it's a stream of raw data.

The same would be true if it were, for example, a GPS receiver.


It isn't clear how the Fortran compiler would reference the device driver involved, although I can find out WHAT that is - - -

Maybe someone has posted an article or has a test example I could look at?

Thanks; Bill

0 Kudos
Steven_L_Intel1
Employee
951 Views
If you need to talk to the driver, you'll be making Win32 calls, not Fortran I/O. I suggest that you look at the MSDN documentation on interfacing with devices.
0 Kudos
Reply