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

USB Read

JohnNichols
Geschätzter Beitragender III
2.907Aufrufe
Dear Steve:

How do I connect to a USB port from Fortran.

Regards

John Nichols
0 Kudos
14 Antworten
Steven_L_Intel1
Mitarbeiter
2.907Aufrufe
Typically there is a device driver that interacts with the USB port - you don't read the port directly. What sort of device are you using? Sometimes the device driver will create a COM port that maps to the USB device and you can open that with FILE="COM4:", etc., but you would need to understand what the specific device's driver provides.
JohnNichols
Geschätzter Beitragender III
2.907Aufrufe
Steve:

A small company in Iowa has a nice device that I would like to communicate with directly as I noted before. I went looking and found a device driver INF file which notes that they are using WINUSB as the interface package, as shown in the attached file.

I would like to access this from Fortran, can I do it? Or do i ahve to use something like C#

Regards

JMN
Paul_Curtis
Geschätzter Beitragender I
2.907Aufrufe
MS provides detailed instructions on how to access a WinUSB device:
http://msdn.microsoft.com/en-us/windows/hardware/gg487341.aspx

Once the initialization is done, you get a file handle for the device and then use the standard ReadFile() and WriteFile() API functions. All of this can be done directly from IVF, but you may have to create your own F90 interfaces for the WinUSB API functions.
JohnNichols
Geschätzter Beitragender III
2.907Aufrufe
Paul:

Thanks a lot for the help.

life was simpler when one only had 2 floppies, a serial port, a printer port and black hair.

Did you all know that the first Mirosft Fortran could run on two 5.25 inch floppies on the original compaq portable sewing machine. (It looked like a sewing machine.)

Those were better times, one had time to drink a beer in comfort as the program was compiling.

Ah for a simple life.

JMN
Steven_L_Intel1
Mitarbeiter
2.907Aufrufe
Heck, I rememeber running DEC PDP-11 FORTRAN-D from an 8-inch floppy under RT-11. In 40K of core. No USB ports back then.
anthonyrichards
Neuer Beitragender III
2.907Aufrufe
40k of core?
You were LUCKY!
Les_Neilson
Geschätzter Beitragender II
2.907Aufrufe
At my age I just wish I could remember anything :-)

Les
jparsly1
Neuer Beitragender I
2.907Aufrufe
IBM 1620, 20K digits
The Fortran II compiler was on a deck of cards.
jimdempseyatthecove
Geehrter Beitragender III
2.907Aufrufe
For me DEC PDP-8I running TSS/8 with 4K word (12-bit) virtual machines and programming in FORTRAN-D.
We also ran FORTRAN-II in O/S 8 on that same machine, initially with 12K word of Core memory. We had 3 fixed head hard drives each 256KB (you read it right KB). We also ran the FORTRAN-D on a 4K word PDP-8L with "mass storage" as 10 character per second paper tape. In those days you kept your programs short (short symbol name choice) and you tended to program without error.

Now I have to have at least 1,000,000 as much memory anddisk. You couldn't run what we do now but the point to drive home is you can get a lot done in a small amount of memory.

Jim Dempsey
jimdempseyatthecove
Geehrter Beitragender III
2.907Aufrufe
>>The Fortran II compiler was on a deck of cards.

I bet it was a lot of fun if you dumped that sucker on the floor.
Usually you would diagonal mark the edge with a majic marker but you had to hand sort it in the event of the oops.

Jim
Steven_L_Intel1
Mitarbeiter
2.907Aufrufe
That's what sequence numbers and a card sorter were for.
jimdempseyatthecove
Geehrter Beitragender III
2.907Aufrufe
That's what sequence numbers and a card sorter were for.


I will bet the FORTRAN-II compiler was in binary format as opposet to text (Hollerith). Binary cards did not have sequence numbers.

At shool we also had a card reader on our PDP-8I and you could load binary programs. The cards had 12 rows which fit in nicely with the 12-bit word length of that machine. You would toggle in a few word program to suck in the first card and overwrite the code you toggled in. That 80-word program would be a larger loader program that read in the rest of the loader, then loader was followed by a control program that managed the compiler.

Our FORTRAN-II compiler (on paper tape)was a three pass compiler which wrote assembly source code to an output device (paper tape or card punch). The load process was toggle in a smallbootstrap that would load in a tape containing the RIM loader (Read In Mode), this tape was followed by the BIN (Binary)loader, then you loaded the tape with the FORTRAN-II compiler. Three passes of your source code through the compilerto produce a tape with assembler source.Then you had to toggle in the loader again and load in the SABR assembler, three passes later again and your had the binary for the program (six passes now plus the tree tapes to get the compiler going and the three tapes to get the assembler going). Next you had to toggle in the loader again, and load in your binary program together with runtime libraries. On a 10cps paper tape it could be several hours before you get to see your program burp and crash. This is why you tended to do your coding right the first time. I am glad I do not have to go through that any more.

Jim Dempsey

paulwdent
Einsteiger
2.907Aufrufe
Yes I also remember using the PDP8 Fortran in 4K x 12bits. a 2-pass compiler. Previously my programs were on 5-hole paper tape pepared on Creed teleprinters. So a first task was to write a program to read 5-hole tape on an 8-hole tape reader and do conversion from Murrsay Code to ASCII. This program I entered on the front panel on the switches - bit at a time!

Now back to USB via FORTAN:

I have a USB-GPIB interface to some lab instruments. It works fine with Agilent's software, but I want to address the instruments via Compaq Visual Fortran which is somewhat the same as IVF.

Agilent only gives examples in C++ or VB, which might as well be Latin as far as enlighteniing me any!

They say write ID = iopen ("gpib0,23") in either VB or C++

They don't give the value or type of the variable gpib0, or how it gets defined.

I guess this translates to a Fortran OPEN statement, but what would the arguments in a Fortran OPEN statement be?

All clues are appreciated.
jimdempseyatthecove
Geehrter Beitragender III
2.907Aufrufe
If you have a C++ sample program that works, then convert it or a portion of it into a function (remove C/C++ main/winmain,...) and make the entry point have C calling convention.

Then you can call the C function form your Fortran code.

Once you can call the sample program (as subroutine) from fortran, then you can start modifying it.
The sample program can do something simple like identyfy device.

iopen is likely a function included in the Agilent library (which you may be able to link with your Fortran application).

Jim Dempsey
Antworten