FT245 HP DVM 3490A Software Notes ------------------------------------- Initial Rev. 28-Dec-2019 Current Rev. 25-Jan-2020 Plan of FT245 Software Steps: ----------------------------- - Do something to see if vinilla linux can see the ft245r at all. - Install the FT D2XX driver and see if it can see the ft245r at all. - Work with the FT Driver Example Simple Write/Read program and see if the data from the HP-3490A looks correct at all. - Work to make a read-only program that: displays the 8 raw hex bytes from the DVM, checks to see if there are any errors in the frame of 8 bytes, display the DVM read out in signed floating point format. - Add recovery from a frame error and partition into a good set of functions to call from a higher level. - Higher level that collects "n" good samples and calculates and displays: highest, lowest, mean, average, 8 bin histogram, DC and AC RMS values. Initial Test with the Built in Linux Driver: -------------------------------------------- From the D2XX Driver Installation Guide: In Linux, the VCP drivers will appear as /dev/ttyUSBx. How to verify the built-in COM port: - Plug in an FTDI based design/module/cable - Open a terminal window, and enter dmesg | grep FTDI The output on the terminal window should contain the following: [10170.987708] USB Serial support registered for FTDI USB Serial Device [10170.987915] ftdi_sio 9-1:1.0: FTDI USB Serial Device converter detected [10170.991172] usb 9-1: FTDI USB Serial Device converter now attached to ttyUSB0 [10170.991219] ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver When I try this I see: [dan@hubwrk FT245_D2XX]$ dmesg | grep FTDI [ 3615.933395] usb 5-1: Manufacturer: FTDI [ 3617.152357] usbserial: USB Serial support registered for FTDI USB Serial Device [ 3617.152687] ftdi_sio 5-1:1.0: FTDI USB Serial Device converter detected [ 3617.157557] usb 5-1: FTDI USB Serial Device converter now attached to ttyUSB0 [dan@hubwrk FT245_D2XX]$ In Linux, the VCP driver and D2XX driver are incompatible with each other. Wh en a FTDI device is plugged in, the VCP driver must be unloaded before a D2XX application can be run. Use the remove module (rmmod) command to do this: sudo rmmod ftdi_sio sudo rmmod usbserial When the FTDI device is power cycled or reset the VCP driver will be reloaded. The rmmod process must be repeated each time this occurs. It is possible to write a simple script that unloads the VCP driver before running the D2XX application. Install the Driver: ------------------- Starting with ft245_d2xx_linux_x86_64-1.4.8.gz in the directory /home/dan/Downloads/FT245_D2XX/D2XX_Driver/ gunzip ft245_d2xx_linux_x86_64-1.4.8.gz tar –xvf ft245_d2xx_linux_x86_64-1.4.8 which creates and builds the drivers and examples in /home/dan/Downloads/FT245_D2XX/D2XX_Driver/release All driver files are copied and symbolic links created using the Linux sudo command for root permissions. sudo cp /releases/build/lib* /usr/local/lib Make the following sym bolic links and permission modifications in /usr/local/lib: cd /usr/local/lib sudo ln -s libftd2xx.so.1.1.12 libftd2xx.so sudo chmod 0755 libftd2xx.so.1.1.12 The symbolic link is used to select a default driver file. Any program can be linked agains t a specific version of the library by using a version numbered library file. Actually did: > pwd /home/dan/Downloads/FT245_D2XX/D2XX_Driver/release > ls -l ./build/lib*ls -l ./build/lib* and see the expected stuff > cp ./build/lib* /usr/local/lib/ cp: omitting directory ‘./build/libftd2xx’ cp: omitting directory ‘./build/libusb’ > > ls -lrt /usr/local/lib/ -rw-r--r--. 1 root root 403442 Dec 31 14:24 libftd2xx.a -rwxr-xr-x. 1 root root 299695 Dec 31 14:24 libftd2xx.so.1.4.8 -rw-r--r--. 1 root root 297 Dec 31 14:24 libftd2xx.txt > # So this looks like the static and run-time shared libraries > cd /usr/local/lib/ # and do the following: > ln –s libftd2xx.so.1.4.8 libftd2xx.so > chmod 0755 libftd2xx.so.1.4.8 # no need to do this # it was already 755 Initial Test with Dynamic Linked Read EEPROM: --------------------------------------------- To verify the D2XX driver install, compile and run the EEPROM read sample program. Make sure the Linux system has the gcc compiler installed. > cd release/examples/ Compile and link the examples. > make -B # Done NOT from ROOT. for n in BitMode EEPROM/erase EEPROM/read EEPROM/write EEPROM/user/read EEPROM/user/size EEPROM/user/write Events LargeRead loopback MultiThread SetVIDPID Simple static Timeouts W32/escapeseq W32/events W32/simple W32/timeouts write ; do "make" -C $n || exit 1; done make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/BitMode' cc main.c -o bitmode -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib -L/usr/local/lib make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/BitMode' make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/EEPROM/erase' cc main.c -o erase -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib -L/usr/local/lib make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/EEPROM/erase' make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/EEPROM/read' cc main.c -o read -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib -L/usr/local/lib make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/EEPROM/read' make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/EEPROM/write' cc main.c -o write -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib -L/usr/local/lib make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/EEPROM/write' make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/EEPROM/user/read' cc main.c -o readua -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib -L/usr/local/lib make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/EEPROM/user/read' make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/EEPROM/user/size' cc main.c -o sizeua -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib -L/usr/local/lib make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/EEPROM/user/size' make[1]: Entering directory `/home/d an/Downloads/FT245_D2XX/D2XX_Driver/release/examples/EEPROM/user/write' cc main.c -o writeua -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib -L/usr/local/lib make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/EEPROM/user/write' make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/Events' cc main.c -o events -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib -L/usr/local/lib make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/Events' make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/LargeRead' cc main.c -o largeread -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib -L/usr/local/lib make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/LargeRead' make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/loopback' cc main.c -o loopback -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib -L/usr/local/lib make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/loopback' make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/MultiThread' cc main.c -o multi -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib -L/usr/local/lib make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/MultiThread' make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/SetVIDPID' cc main.c -o setVIDPID -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib -L/usr/local/lib make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/SetVIDPID' make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/Simple' cc main.c -o simple-static ../../build/libftd2xx.a -Wall -Wextra -lpthread -lrt cc main.c -o simple-dynamic -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/Simple' make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/static' gcc main.c -o static_link ../../build/libftd2xx.a -lpthread -lrt -Wall -Wextra make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/static' make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/Timeouts' cc main.c -o timeouts -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib -L/usr/local/lib make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/Timeouts' make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/W32/escapeseq' cc main.c -o w32_escapeseq -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib -L/usr/local/lib make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/W32/escapeseq' make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/W32/events' cc main.c -o w32_events -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib -L/usr/local/lib make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/W32/events' make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/W32/simple' cc main.c -o w32_simple -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib -L/usr/local/lib -g make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/W32/simple' make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/W32/timeouts' cc main.c -o w32_timeouts -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib -L/usr/local/lib make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/W32/timeouts' make[1]: Entering directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/write' cc main.c -o write -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib -L/usr/local/lib make[1]: Leaving directory `/home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/write' [dan@hubwrk examples]$ Change to the read example directory. > cd eeprom/read/ The name of the executable file is read. Plug in the FTDI based device. Remove the VCP driver as described in section above: > sudo rmmod ftdi_sio # Done from ROOT > > sudo rmmod usbserial # Done from ROOT rmmod: ERROR: Module usbserial is builtin. > Run the sample application: > sudo ./read # Note that this is run from ROOT. The read application will list the configuration descriptors of the attached FTDI device. What I actually see is: Library version = 0x10408 Opening port 0 FT_Open succeeded. Handle is 0x22bb760 FT_GetDeviceInfo succeeded. Device is type 5. FT_EE_Read succeeded. Signature1 = 0 Signature2 = -1 Version = 2 VendorId = 0x0403 ProductId = 0x6001 Manufacturer = FTDI ManufacturerId = FT Description = UM245R SerialNumber = FTC8MGZF MaxPower = 100 PnP = 1 SelfPowered = 0 RemoteWakeup = 1 232R: ----- UseExtOsc = 0x0 HighDriveIOs = 0x0 EndpointSize = 0x40 PullDownEnableR = 0x0 SerNumEnableR = 0x1 InvertTXD = 0x0 InvertRXD = 0x0 InvertRTS = 0x0 InvertCTS = 0x0 InvertDTR = 0x0 InvertDSR = 0x0 InvertDCD = 0x0 InvertRI = 0x0 Cbus0 = 0x1 Cbus1 = 0x1 Cbus2 = 0x1 Cbus3 = 0x1 Cbus4 = 0x5 RIsD2XX = 0x0 Returning 0 [root@hubwrk read]# Notes: - By making a test it appears that just doing rmmod ftdi_sio is enough to get rid of the linux built in FT driver so that the FT D2XX driver can control the ft245r. In any case, as shown above, it appears that the rmmod usbserial just returns with the error, rmmod: ERROR: Module usbserial is builtin. - There appears to be no problem running the EEPROM read program multiple times - from ROOT. - If I try to run the EEPROM read program from a non privileged accound then it fails with: Opening port 0 FT_Open(0) failed [dan@hubwrk read]$ I need to learn how to run these programs from a non privileged account. Initial Test with Static Linked Program: ---------------------------------------- The static library example is simple to run and execute. > cd release/examples/static/ Remove any previous library built for another target. > rm lib* Copy the static library to current directory from the copy in the driver distribution file. This could also be copied from /usr/local/lib or the cross compiler library. > cp ../../build/libftd2xx.a ./ Compile and link the example > make -B gcc main.c -o static_link ../../build/libftd2xx.a -lpthread -lrt -Wall -Wextra > > ls -lrt -rw-rw-r--. 1 dan dan 449 Jun 7 2018 Makefile -rw-rw-r--. 1 dan dan 2855 Jun 7 2018 main.c -rw-r--r--. 1 root root 403442 Jan 1 13:15 libftd2xx.a -rwxr-xr-x. 1 root root 180920 Jan 1 13:20 static_link > Run the test program. > ./static_link # Note run from ROOT. This application will write and read 16 bytes to port 0 of any FTDI USB -> UART device with a loopback connector attached: Device 0 Serial Number - FTC8MGZF Opened device FTC8MGZF FT_Read read 16 bytes Closed device FTC8MGZF Notes: ------ - This program appears to flush the ft245r Transmit FIFO in the sense that after you start the program you must then wait for or cause 2 readings of the DVM before the program goes past the Open line and completes with the 16 bytes read message. That is, even if you have done many readings of the DVM (which must now be sitting in the Transmit FIFO) and then start the program, you must still do two more readings to cause the program to complete. For now I assume that the Open Device causes the flush of the Tx FIFO. - This program has no timeout - that is once you start it it will wait forever to find 16 bytes in the Tx FIFO. - Trying to run this program from a non-privileged account gives: [dan@hubwrk static]$ ./static_link Error: FT_ListDevices returned 2 [dan@hubwrk static]$ Initial Test of the Simple Program: ----------------------------------- [root@hubwrk static]# cd ../Simple/ [root@hubwrk Simple]# ls -l total 208 -rw-rw-r--. 1 dan dan 5296 Jun 7 2018 main.c -rw-rw-r--. 1 dan dan 808 Jun 7 2018 Makefile -rwxrwxr-x. 1 dan dan 13320 Dec 31 14:50 simple-dynamic -rwxrwxr-x. 1 dan dan 181056 Dec 31 14:50 simple-static [root@hubwrk Simple]# cp ../../build/libftd2xx.a ./ [root@hubwrk Simple]# ls -lrt total 604 -rw-rw-r--. 1 dan dan 5296 Jun 7 2018 main.c -rw-rw-r--. 1 dan dan 808 Jun 7 2018 Makefile -rwxrwxr-x. 1 dan dan 181056 Dec 31 14:50 simple-static -rwxrwxr-x. 1 dan dan 13320 Dec 31 14:50 simple-dynamic -rw-r--r--. 1 root root 403442 Jan 1 13:55 libftd2xx.a [root@hubwrk Simple]# mv simple-static simple-static_old [root@hubwrk Simple]# mv simple-dynamic simple-dynamic_old [root@hubwrk Simple]# ls -lrt total 604 -rw-rw-r--. 1 dan dan 5296 Jun 7 2018 main.c -rw-rw-r--. 1 dan dan 808 Jun 7 2018 Makefile -rwxrwxr-x. 1 dan dan 181056 Dec 31 14:50 simple-static_old -rwxrwxr-x. 1 dan dan 13320 Dec 31 14:50 simple-dynamic_old -rw-r--r--. 1 root root 403442 Jan 1 13:55 libftd2xx.a [root@hubwrk Simple]# make -B cc main.c -o simple-static ../../build/libftd2xx.a -Wall -Wextra -lpthread -lrt cc main.c -o simple-dynamic -Wall -Wextra -lftd2xx -lpthread -lrt -Wl,-rpath /usr/local/lib [root@hubwrk Simple]# ls -lrt total 800 -rw-rw-r--. 1 dan dan 5296 Jun 7 2018 main.c -rw-rw-r--. 1 dan dan 808 Jun 7 2018 Makefile -rwxrwxr-x. 1 dan dan 181056 Dec 31 14:50 simple-static_old -rwxrwxr-x. 1 dan dan 13320 Dec 31 14:50 simple-dynamic_old -rw-r--r--. 1 root root 403442 Jan 1 13:55 libftd2xx.a -rwxr-xr-x. 1 root root 181056 Jan 1 13:56 simple-static -rwxr-xr-x. 1 root root 13320 Jan 1 13:56 simple-dynamic DVM 1 reading/sec 100V no input Dispaly -000.002 [root@hubwrk Simple]# ./simple-static Device 0 Serial Number - FTC8MGZF Opened device FTC8MGZF Calling FT_Write with this write-buffer: [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F] Number of bytes in D2XX receive-queue: 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 Got 16 (of 16) bytes. Calling FT_Read with this read-buffer: [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF] FT_Read read 16 bytes. Read-buffer is now: [0x12, 0x10, 0x10, 0x10, 0x10, 0x14, 0x1B, 0x1C, 0x12, 0x10, 0x10, 0x10, 0x10, 0x14, 0x1B, 0x1C] Error: read-buffer does not match write-buffer. [root@hubwrk Simple]# DVM 1 reading/sec 100V V-Box #3 Dispaly +009.999 [root@hubwrk Simple]# ./simple-static Device 0 Serial Number - FTC8MGZF Opened device FTC8MGZF Calling FT_Write with this write-buffer: [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F] Number of bytes in D2XX receive-queue: 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 Got 16 (of 16) bytes. Calling FT_Read with this read-buffer: [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF] FT_Read read 16 bytes. Read-buffer is now: [0x19, 0x19, 0x19, 0x19, 0x10, 0x10, 0x1B, 0x1C, 0x19, 0x19, 0x19, 0x19, 0x10, 0x10, 0x1B, 0x1C] Error: read-buffer does not match write-buffer. [root@hubwrk Simple]# DVM 1 reading/sec 10V V-Box #3 Dispaly +09.5678 [root@hubwrk Simple]# ./simple-static Device 0 Serial Number - FTC8MGZF Opened device FTC8MGZF Calling FT_Write with this write-buffer: [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F] Number of bytes in D2XX receive-queue: 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 Got 16 (of 16) bytes. Calling FT_Read with this read-buffer: [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF] FT_Read read 16 bytes. Read-buffer is now: [0x18, 0x17, 0x16, 0x15, 0x19, 0x10, 0x1C, 0x1C, 0x18, 0x17, 0x16, 0x15, 0x19, 0x10, 0x1C, 0x1C] Error: read-buffer does not match write-buffer. [root@hubwrk Simple]# Initial Test of Simple Read Only Program: ----------------------------------------- Working in /home/dan/Downloads/FT245_D2XX/D2XX_Driver/release/examples/Simple make copy of the original version of main.c and then start the work to make a read-only version of Simple main.c Still need to fix the problem of this only running from ROOT. - This has to do with: /etc/udev/rules.d - See: http://www.reactivated.net/writing_udev_rules.html - On this system see: /etc/udev/rules.d/52-xilinx-digilent-usb.rules - On this system see: /etc/udev/rules.d/52-xilinx-ftdi-usb.rules The > lsusb command shows what devices the linux system currently thinks are connected to it. I've copied: ftd2xx.h and WinTypes.h to the source directory for the "simple read-only main.c" to match the static library that is already there. All three are needed to build the "simple read-only" program. The only module that we need to remove at startup is: > rmmod ftdi_sio Paired down to read only and display of raw hex buffer and display of signed floating point readout. Now work on: checking the integrity of the 8 entries in the buffer, and flushing the buffer and starting over if there is anything screwed up in the current readout frame. Must partition this heave pit into the functions that I want to call from an upper level program. Question - transfer to upper level by writing a file ? 6-Jan-20 The other issue is moving out of the examples directory structure, how to organize this code for long term support work, and how to best organize this code for building, i.e. how to organize the source files. 7-Jan-2020 Start by splitting the source code into a DAQ part and an Analysis part. 8-Jan-2020 Added the Histogram: This is an 8 Bin Histogram. The sum of the counts in the 8 bins should add up to the total number of samles that have been collected. Recall the Histogram of a Sin Wave: for 8 bins it is symmetric positive and negative so: Sin Angle Angle Angle Range Fraction of 90 deg --------- ----- ----------- ------------------ 1.00 90.0 41.41 46.01% 0.75 48.59 18.59 20.66% 0.50 30.0 15.52 17.24% 0.25 14.48 14.48 16.09% 0.00 0.0 Still need to add: - Don't save the sample or increment the recorded samples counter if the sample fails any of the rationality checks: clear the "Failed Rationality Checks Flag" on entering the checks set the FRCF if any of the checks fail pass the FRCF out of the Rationality Checks Function when it comes time to write the DVM sample into the storage array - don't do this if the FRCF is set and don't increment the index of the number of stored samples This has now been added - if the read fails any of the check it is not writen into the Sample Storage Array. - Recover from a timeout getting the Queue Status. If timeout then: bells, Purge FIFO, Back to Try Again If this does not work then Reset the Device I tried FT_ResetDevice and that is not enough to recover this situation. But the FT_ResetDevice was actually working, i.e. it did not make any FT_Status error. I moved to Close - Open and that is working to fix the problem that once and a while the Queue Status call returns 0 entries in the Queue even though there should be 8 or more entries. I need to check in this condition and see of the ft245r is telling the interface hardware that its Transmit Queue is Full and not to clock any more data into the Tx Queue. Building with: cc main.c -o dvm_daq_one_static /usr/local/lib/libftd2xx.a -Wall -Wextra -lpthread -lrt -lm 11-Jan-2020 - Both the count of how many times the DVM Read Failed the Frame Check and the count of how many times a USB Reset was needed have been added to the diagnostic printout at the end of the run. - Movied the Sample Storage Array to 50,005 entries. - Advertize at the start the Max number of Samples that one can ask for (should check this too). - Move the 0.1 sec delay from the middle of the Check Queue Status loop to before the First Check of the Queue Status so that there is a 0.1 sec delay both before the First check and then between checks, i.e. give things a little time to cool down after and FT Read before the First check of Queue Status. 12-Jan-2020 - Need to set things up to run the application from a non-privileged accountl, i.e. udev and rmmod ftdi_sio. =========================================== Temp Junk that I'm saving Starting Read Loop Number = 5044 queue check count = 2 FT_Read read 8 bytes. Read-buffer currently holds: [0x12, 0x15, 0x19, 0x14, 0x14, 0x14, 0x1C, 0x1C] All 8 Data Flags are Hi. The first 5 bytes are all BCD. The 6th byte is one of the 4 legal values. The 7th byte is the correct value. The 8th byte is the correct value. Volts floating = -4.4952 Starting Read Loop Number = 5045 Queue check timed out after 6 seconds queue check count = 60 Bytes in Read FIFO reported by Queue Check = 0 [root@hubwrk Simple]# =========================== cc main.c -o simple-static ../../build/libftd2xx.a -Wall -Wextra -lpthread -lrt -lm ====================== This DVM data collection run took 1001 seconds The number of DVM samples actually collected = 5000 Minimum Sample Value = -5.5196 A Sample Index with the Minimum Sample Value = 291 Maximum Sample Value = 5.4841 A Sample Index with the Maximum Sample Value = 127 Histo Bin from -5.5196 to -4.1441 has 1134 counts Histo Bin from -4.1441 to -2.7687 has 517 counts Histo Bin from -2.7687 to -1.3932 has 437 counts Histo Bin from -1.3932 to -0.0177 has 397 counts Histo Bin from -0.0177 to 1.3577 has 405 counts Histo Bin from 1.3577 to 2.7332 has 433 counts Histo Bin from 2.7332 to 4.1086 has 523 counts Histo Bin from 4.1086 to 5.4841 has 1154 counts The average, aka DC, sample value = 0.00761 The DC RMS of the samples = 3.88425 The AC RMS of the samples = 3.88424 Closed USB Device - FTC8MGZF ================================= This DVM data collection run took 10016 seconds The number of DVM samples actually collected = 10000 Minimum Sample Value = -5.9854 A Sample Index with the Minimum Sample Value = 8928 Maximum Sample Value = 5.8609 A Sample Index with the Maximum Sample Value = 8529 Histo Bin from -5.9854 to -4.5046 has 2242 counts - expect 2301 Histo Bin from -4.5046 to -3.0238 has 1011 counts - expect 1033 Histo Bin from -3.0238 to -1.5430 has 879 counts - expect 862 Histo Bin from -1.5430 to -0.0623 has 804 counts - expect 804 Histo Bin from -0.0623 to 1.4185 has 811 counts Histo Bin from 1.4185 to 2.8993 has 887 counts Histo Bin from 2.8993 to 4.3801 has 1059 counts Histo Bin from 4.3801 to 5.8609 has 2307 counts The average, aka DC, sample value = -0.00418 The DC RMS of the samples = 4.16776 The AC RMS of the samples = 4.16776 Closed USB Device - FTC8MGZF [root@hubwrk Simple]# ================================ # run of 10,000 samples Starting Read Loop Number = 10000 queue check count = 11 FT_Read read 8 bytes. Read-buffer currently holds: [0x17, 0x15, 0x17, 0x19, 0x14, 0x10, 0x1C, 0x1C] All 8 Data Flags are Hi. The first 5 bytes are all BCD. The 6th byte is one of the 4 legal values. The 7th byte is the correct value. The 8th byte is the correct value. Volts floating = 4.9757 This DVM data collection run took 10002 seconds Number of DVM samples actually collected = 10000 Number of DVM read attempts = 10000 Number of DVM Data Frame Errors = 0 Number of USB Resets = 0 Minimum Sample Value = -5.4397 A Sample Index with the Minimum Sample Value = 8567 Maximum Sample Value = 5.3269 A Sample Index with the Maximum Sample Value = 9387 Histo Bin from -5.4397 to -4.0939 has 2227 counts - expect 2301 Histo Bin from -4.0939 to -2.7481 has 1014 counts - expect 1033 Histo Bin from -2.7481 to -1.4022 has 873 counts - expect 862 Histo Bin from -1.4022 to -0.0564 has 811 counts - expect 805 Histo Bin from -0.0564 to 1.2894 has 817 counts Histo Bin from 1.2894 to 2.6352 has 891 counts Histo Bin from 2.6352 to 3.9811 has 1050 counts Histo Bin from 3.9811 to 5.3269 has 2317 counts The average, aka DC, sample value = 0.00443 The DC RMS of the samples = 3.78842 The AC RMS of the samples = 3.78842 Closed USB Device - FTC8MGZF [root@hubwrk DVM_DAQ_One]# ======================================== 12-Jan-2020 2 Hz -e Gen Rad 1 sps HP DVM Starting Read Loop Number = 50000 queue check count = 11 FT_Read read 8 bytes. Read-buffer currently holds: [0x13, 0x19, 0x15, 0x13, 0x13, 0x10, 0x1C, 0x1C] All 8 Data Flags are Hi. The first 5 bytes are all BCD. The 6th byte is one of the 4 legal values. The 7th byte is the correct value. The 8th byte is the correct value. Volts floating = 3.3593 This DVM data collection run took 50065 seconds Number of DVM samples actually collected = 50000 Number of DVM read attempts = 50000 Number of DVM Data Frame Errors = 0 Number of USB Resets = 7 Minimum Sample Value = -5.4419 A Sample Index with the Minimum Sample Value = 13862 Maximum Sample Value = 5.3292 A Sample Index with the Maximum Sample Value = 28051 Histo Bin from -5.4419 to -4.0955 has 11113 counts - expect 11503 Histo Bin from -4.0955 to -2.7491 has 5114 counts - expect 5165 Histo Bin from -2.7491 to -1.4027 has 4324 counts - expect 4310 Histo Bin from -1.4027 to -0.0563 has 4090 counts - expect 4023 Histo Bin from -0.0563 to 1.2900 has 4099 counts Histo Bin from 1.2900 to 2.6364 has 4418 counts Histo Bin from 2.6364 to 3.9828 has 5258 counts Histo Bin from 3.9828 to 5.3292 has 11584 counts The average, aka DC, sample value = 0.00368 The DC RMS of the samples = 3.78850 The AC RMS of the samples = 3.78850 Closed USB Device - FTC8MGZF [root@hubwrk DVM_DAQ_One]# ======================================= 13-Jan-2020 2 Hz - e Gen Rad 5 sps DVM Starting Read Loop Number = 50000 queue check count = 3 FT_Read read 8 bytes. Read-buffer currently holds: [0x12, 0x13, 0x13, 0x17, 0x10, 0x14, 0x1C, 0x1C] All 8 Data Flags are Hi. The first 5 bytes are all BCD. The 6th byte is one of the 4 legal values. The 7th byte is the correct value. The 8th byte is the correct value. Volts floating = -0.7332 This DVM data collection run took 10015 seconds Number of DVM samples actually collected = 50000 Number of DVM read attempts = 50000 Number of DVM Data Frame Errors = 0 Number of USB Resets = 0 Minimum Sample Value = -5.4505 A Sample Index with the Minimum Sample Value = 9683 Maximum Sample Value = 5.3382 A Sample Index with the Maximum Sample Value = 10255 Histo Bin from -5.4505 to -4.1019 has 11135 counts - expect 11503 Histo Bin from -4.1019 to -2.7533 has 5099 counts - expect 5165 Histo Bin from -2.7533 to -1.4047 has 4352 counts - expect 4310 Histo Bin from -1.4047 to -0.0562 has 4069 counts - expect 4023 Histo Bin from -0.0562 to 1.2924 has 4121 counts Histo Bin from 1.2924 to 2.6410 has 4396 counts Histo Bin from 2.6410 to 3.9896 has 5258 counts Histo Bin from 3.9896 to 5.3382 has 11570 counts The average, aka DC, sample value = 0.00098 The DC RMS of the samples = 3.79497 The AC RMS of the samples = 3.79497 Closed USB Device - FTC8MGZF [root@hubwrk DVM_DAQ_One]# ======================================= Same 2 Hz - e Gen Rad 5 sps DVM as above run This DVM data collection run took 10023 seconds Number of DVM samples actually collected = 50000 Number of DVM read attempts = 50000 Number of DVM Data Frame Errors = 0 Number of USB Resets = 1 Minimum Sample Value = -5.4588 A Sample Index with the Minimum Sample Value = 5473 Maximum Sample Value = 5.3456 A Sample Index with the Maximum Sample Value = 297 Histo Bin from -5.4588 to -4.1082 has 11138 counts - expect 11503 Histo Bin from -4.1082 to -2.7577 has 5099 counts - expect 5165 Histo Bin from -2.7577 to -1.4071 has 4354 counts - expect 4310 Histo Bin from -1.4071 to -0.0566 has 4061 counts - expect 4023 Histo Bin from -0.0566 to 1.2940 has 4126 counts Histo Bin from 1.2940 to 2.6445 has 4391 counts Histo Bin from 2.6445 to 3.9951 has 5265 counts Histo Bin from 3.9951 to 5.3456 has 11566 counts The average, aka DC, sample value = 0.00109 The DC RMS of the samples = 3.80059 The AC RMS of the samples = 3.80059 Closed USB Device - FTC8MGZF ======================================= 14-Jan-2020 Same 2 Hz - e Gen Rad 5 sps DVM as above runs This DVM data collection run took 10015 seconds Number of DVM samples actually collected = 50000 Number of DVM read attempts = 50000 Number of DVM Data Frame Errors = 0 Number of USB Resets = 0 Minimum Sample Value = -5.4621 A Sample Index with the Minimum Sample Value = 39748 Maximum Sample Value = 5.3492 A Sample Index with the Maximum Sample Value = 45284 Histo Bin from -5.4621 to -4.1107 has 11140 counts - expect 11503 Histo Bin from -4.1107 to -2.7593 has 5117 counts - expect 5165 Histo Bin from -2.7593 to -1.4079 has 4319 counts - expect 4310 Histo Bin from -1.4079 to -0.0565 has 4074 counts - expect 4023 Histo Bin from -0.0565 to 1.2950 has 4114 counts Histo Bin from 1.2950 to 2.6464 has 4406 counts Histo Bin from 2.6464 to 3.9978 has 5268 counts Histo Bin from 3.9978 to 5.3492 has 11562 counts The average, aka DC, sample value = 0.00100 The DC RMS of the samples = 3.80233 The AC RMS of the samples = 3.80233 Closed USB Device - FTC8MGZF [root@hubwrk DVM_DAQ_One]# ================================= 16-Jan-2020 test with the HP 33210A generator at 713 mHz 2.0 Vrms No Load DVM set for lowest sampling rate 0.625 sps Starting Read Loop Number = 50000 queue check count = 17 FT_Read read 8 bytes. Read-buffer currently holds: [0x16, 0x11, 0x17, 0x13, 0x12, 0x10, 0x1C, 0x1C] All 8 Data Flags are Hi. The first 5 bytes are all BCD. The 6th byte is one of the 4 legal values. The 7th byte is the correct value. The 8th byte is the correct value. Volts floating = 2.3716 This DVM data collection run took 80058 seconds Number of DVM samples actually collected = 50000 Number of DVM read attempts = 50000 Number of DVM Data Frame Errors = 0 Number of USB Resets = 7 Minimum Sample Value = -5.6481 A Sample Index with the Minimum Sample Value = 39272 Maximum Sample Value = 5.6475 A Sample Index with the Maximum Sample Value = 120 Histo Bin from -5.6481 to -4.2362 has 11496 counts - expect 11503 Histo Bin from -4.2362 to -2.8242 has 5173 counts - expect 5165 Histo Bin from -2.8242 to -1.4123 has 4310 counts - expect 4310 Histo Bin from -1.4123 to -0.0003 has 4020 counts - expect 4023 Histo Bin from -0.0003 to 1.4116 has 4019 counts Histo Bin from 1.4116 to 2.8236 has 4321 counts Histo Bin from 2.8236 to 4.2355 has 5160 counts Histo Bin from 4.2355 to 5.6475 has 11501 counts The average, aka DC, sample value = -0.00030 The DC RMS of the samples = 3.99322 The AC RMS of the samples = 3.99322 Closed USB Device - FTC8MGZF [root@hubwrk DVM_DAQ_One]# ============================== 17-Jan-2020 test with the HP 33210A generator at 713 mHz 2.0 Vrms No Load DVM set for lowest sampling rate 0.625 sps Starting Read Loop Number = 40000 queue check count = 17 FT_Read read 8 bytes. Read-buffer currently holds: [0x11, 0x18, 0x16, 0x14, 0x15, 0x10, 0x1C, 0x1C] All 8 Data Flags are Hi. The first 5 bytes are all BCD. The 6th byte is one of the 4 legal values. The 7th byte is the correct value. The 8th byte is the correct value. Volts floating = 5.4681 This DVM data collection run took 64056 seconds Number of DVM samples actually collected = 40000 Number of DVM read attempts = 40000 Number of DVM Data Frame Errors = 0 Number of USB Resets = 7 Minimum Sample Value = -5.6480 A Sample Index with the Minimum Sample Value = 3288 Maximum Sample Value = 5.6471 A Sample Index with the Maximum Sample Value = 398 Histo Bin from -5.6480 to -4.2361 has 9194 counts Histo Bin from -4.2361 to -2.8242 has 4134 counts Histo Bin from -2.8242 to -1.4123 has 3452 counts Histo Bin from -1.4123 to -0.0005 has 3223 counts Histo Bin from -0.0005 to 1.4114 has 3215 counts Histo Bin from 1.4114 to 2.8233 has 3451 counts Histo Bin from 2.8233 to 4.2352 has 4136 counts Histo Bin from 4.2352 to 5.6471 has 9195 counts The average, aka DC, sample value = 0.00002 The DC RMS of the samples = 3.99310 The AC RMS of the samples = 3.99310 Closed USB Device - FTC8MGZF [root@hubwrk DVM_DAQ_One]# ============================== 17-Jan-2020 test with the HP 33210A generator at 123 mHz 2.0 Vrms No Load DVM set for lowest sampling rate 0.625 sps Starting Read Loop Number = 4000 queue check count = 17 FT_Read read 8 bytes. Read-buffer currently holds: [0x10, 0x11, 0x10, 0x11, 0x15, 0x10, 0x1C, 0x1C] All 8 Data Flags are Hi. The first 5 bytes are all BCD. The 6th byte is one of the 4 legal values. The 7th byte is the correct value. The 8th byte is the correct value. Volts floating = 5.1010 This DVM data collection run took 6407 seconds Number of DVM samples actually collected = 4000 Number of DVM read attempts = 4000 Number of DVM Data Frame Errors = 0 Number of USB Resets = 1 Minimum Sample Value = -5.6592 A Sample Index with the Minimum Sample Value = 222 Maximum Sample Value = 5.6582 A Sample Index with the Maximum Sample Value = 885 Histo Bin from -5.6592 to -4.2445 has 921 counts Histo Bin from -4.2445 to -2.8299 has 414 counts Histo Bin from -2.8299 to -1.4152 has 342 counts Histo Bin from -1.4152 to -0.0005 has 321 counts Histo Bin from -0.0005 to 1.4142 has 322 counts Histo Bin from 1.4142 to 2.8288 has 346 counts Histo Bin from 2.8288 to 4.2435 has 414 counts Histo Bin from 4.2435 to 5.6582 has 920 counts The average, aka DC, sample value = 0.00171 The DC RMS of the samples = 4.00152 The AC RMS of the samples = 4.00152 Closed USB Device - FTC8MGZF [root@hubwrk DVM_DAQ_One]# ============================== 21-Jan-2020 test with the HP 33210A generator at 73 mHz 2.0 Vrms No Load DVM set for lowest sampling rate 0.625 sps Starting Read Loop Number = 50000 queue check count = 17 FT_Read read 8 bytes. Read-buffer currently holds: [0x13, 0x18, 0x13, 0x17, 0x10, 0x10, 0x1C, 0x1C] All 8 Data Flags are Hi. The first 5 bytes are all BCD. The 6th byte is one of the 4 legal values. The 7th byte is the correct value. The 8th byte is the correct value. Volts floating = 0.7383 This DVM data collection run took 80058 seconds Number of DVM samples actually collected = 50000 Number of DVM read attempts = 50000 Number of DVM Data Frame Errors = 0 Number of USB Resets = 7 Minimum Sample Value = -5.6600 A Sample Index with the Minimum Sample Value = 163 Maximum Sample Value = 5.6591 A Sample Index with the Maximum Sample Value = 56 Histo Bin from -5.6600 to -4.2451 has 11498 counts - expect 11503 Histo Bin from -4.2451 to -2.8302 has 5163 counts - expect 5165 Histo Bin from -2.8302 to -1.4153 has 4310 counts - expect 4310 Histo Bin from -1.4153 to -0.0005 has 4029 counts - expect 4023 Histo Bin from -0.0005 to 1.4144 has 4022 counts Histo Bin from 1.4144 to 2.8293 has 4310 counts Histo Bin from 2.8293 to 4.2442 has 5168 counts Histo Bin from 4.2442 to 5.6591 has 11500 counts The average, aka DC, sample value = -0.00007 The DC RMS of the samples = 4.00131 The AC RMS of the samples = 4.00131 Closed USB Device - FTC8MGZF [root@hubwrk DVM_DAQ_One]# ============================== 24-Jan-2020 test with the HP 33210A generator at 23 mHz 2.0 Vrms No Load DVM set for lowest sampling rate 0.625 sps Starting Read Loop Number = 50000 queue check count = 17 FT_Read read 8 bytes. Read-buffer currently holds: [0x10, 0x13, 0x11, 0x13, 0x11, 0x14, 0x1C, 0x1C] All 8 Data Flags are Hi. The first 5 bytes are all BCD. The 6th byte is one of the 4 legal values. The 7th byte is the correct value. The 8th byte is the correct value. Volts floating = -1.3130 This DVM data collection run took 80020 seconds Number of DVM samples actually collected = 50000 Number of DVM read attempts = 50000 Number of DVM Data Frame Errors = 0 Number of USB Resets = 1 Minimum Sample Value = -5.6600 A Sample Index with the Minimum Sample Value = 18385 Maximum Sample Value = 5.6584 A Sample Index with the Maximum Sample Value = 6091 Histo Bin from -5.6600 to -4.2452 has 11497 counts - expect 11503 Histo Bin from -4.2452 to -2.8304 has 5161 counts - expect 5165 Histo Bin from -2.8304 to -1.4156 has 4311 counts - expect 4310 Histo Bin from -1.4156 to -0.0008 has 4028 counts - expect 4023 Histo Bin from -0.0008 to 1.4140 has 4020 counts Histo Bin from 1.4140 to 2.8288 has 4311 counts Histo Bin from 2.8288 to 4.2436 has 5168 counts Histo Bin from 4.2436 to 5.6584 has 11504 counts The average, aka DC, sample value = 0.00024 The DC RMS of the samples = 4.00109 The AC RMS of the samples = 4.00109 Closed USB Device - FTC8MGZF [root@hubwrk DVM_DAQ_One]# ============================== 25-Jan-2020 Input to DVM shorted DVM at maximum read rate i.e. 5 sps Starting Read Loop Number = 50000 queue check count = 3 FT_Read read 8 bytes. Read-buffer currently holds: [0x12, 0x10, 0x10, 0x10, 0x10, 0x14, 0x1C, 0x1C] All 8 Data Flags are Hi. The first 5 bytes are all BCD. The 6th byte is one of the 4 legal values. The 7th byte is the correct value. The 8th byte is the correct value. Volts floating = -0.0002 This DVM data collection run took 10030 seconds Number of DVM samples actually collected = 50000 Number of DVM read attempts = 50000 Number of DVM Data Frame Errors = 0 Number of USB Resets = 2 Minimum Sample Value = -0.0003 A Sample Index with the Minimum Sample Value = 12498 Maximum Sample Value = -0.0001 A Sample Index with the Maximum Sample Value = 32 The average, aka DC, sample value = -0.00020 The DC RMS of the samples = 0.00020 The AC RMS of the samples = 0.00002 Closed USB Device - FTC8MGZF [root@hubwrk DVM_DAQ_One]# ============================== ==============================