I am having trouble running ulDaqInScan on the USB-CTR08 at rates greater than 1000 Hz with UL for Linux. It works fine with cbDaqInScan on UL for Windows.
I have written a test program to demonstrate the problem.
https://github.com/epics-modules/measComp/blob/UL_for_Linux_Direct/measCompApp/src/test_USB_CTR.cpp
These are the comments at the beginning of the program that explain how to run it, and the problem I observe.
Does a DaqInScan on a USB-CTR04/08 to test problems with rates >1000 Hz on Linux.
Runs on both Windows and Linux.
It reads all of the counters and the DIO.
For best diagnostic results make the following physical connections:
- Timer 0 connected to Counter 0 (TMR0 to C0IN). The program configures this for 1 MHz square wave.
- Timer 1 connected to Counter 1 (TMR1 to C1IN). The program configures this for 100 kHz square wave.
- Timer 2 connected to Digital input 0 (TMR2 to DIO0). The program configures this for 10 Hz square wave.
Program requires 3 arguments:
1) The UnigueID of the device (serial number for USB, MAC address for Ethernet)
2) The scan rate in Hz
3) The sleep time in seconds between reading and printing the scan data
The program works as expected on Windows.
On Linux it works as expected when rate <= 1000 Hz.
Above 1 kHz (e.g. 2 kHz) it works the first time it is run at that rate.
However, on subsequent runs the data is not in the right order, and the scan never stops.
This is the output running the program on Windows with rate=1000 Hz and sleep time = 50 ms. It works as expected. Counter 0 has 1000 counts in each scan point (1 MHz input), Counter 1 has 100 counts (100 kHz input), and DIO0 toggles between 0 and 1 (10 Hz input).
J:\epics\devel\measComp>bin\windows-x64-static\test_USB_CTR.exe 1E538A2 1000 .05
Found 6 DAQ device(s)
Running on Windows
Connecting to device type=USB-CTR08 serial number=1E538A2
ctrStatus=1, ctrCount=384, ctrIndex=369, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=896, ctrIndex=882, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=1280, ctrIndex=1269, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=1792, ctrIndex=1782, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=2304, ctrIndex=2295, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=2816, ctrIndex=2799, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=3200, ctrIndex=3186, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=3712, ctrIndex=3699, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=4224, ctrIndex=4212, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=4608, ctrIndex=4599, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=5120, ctrIndex=5103, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=5632, ctrIndex=5616, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=6016, ctrIndex=6003, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=6528, ctrIndex=6516, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=7040, ctrIndex=7029, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=7424, ctrIndex=7407, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=7936, ctrIndex=7920, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=8448, ctrIndex=8433, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=8832, ctrIndex=8820, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=0, ctrCount=9000, ctrIndex=8991, counts=1000 100 0 0 0 0 0 0 0x0
This is the output on Windows when the scan rate is increase to 2000 Hz. The program is run twice, and both times the output is as expected. Counter 0 is 500, Counter 1 is 50, and DIO0 toggles between 0 and 1.
J:\epics\devel\measComp>bin\windows-x64-static\test_USB_CTR.exe 1E538A2 2000 .05
Found 6 DAQ device(s)
Running on Windows
Connecting to device type=USB-CTR08 serial number=1E538A2
ctrStatus=1, ctrCount=768, ctrIndex=756, counts=500 50 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=1792, ctrIndex=1782, counts=500 50 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=2560, ctrIndex=2547, counts=500 50 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=3584, ctrIndex=3573, counts=500 50 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=4608, ctrIndex=4599, counts=500 50 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=5376, ctrIndex=5364, counts=500 50 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=6400, ctrIndex=6390, counts=500 50 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=7424, ctrIndex=7407, counts=500 50 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=8192, ctrIndex=8181, counts=500 50 0 0 0 0 0 0 0x0
ctrStatus=0, ctrCount=9000, ctrIndex=8991, counts=500 50 0 0 0 0 0 0 0x1
J:\epics\devel\measComp>bin\windows-x64-static\test_USB_CTR.exe 1E538A2 2000 .05
Found 6 DAQ device(s)
Running on Windows
Connecting to device type=USB-CTR08 serial number=1E538A2
ctrStatus=1, ctrCount=768, ctrIndex=756, counts=500 50 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=1792, ctrIndex=1782, counts=500 50 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=2560, ctrIndex=2547, counts=500 50 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=3584, ctrIndex=3573, counts=500 50 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=4608, ctrIndex=4599, counts=500 50 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=5632, ctrIndex=5616, counts=500 50 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=6400, ctrIndex=6390, counts=500 50 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=7424, ctrIndex=7407, counts=500 50 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=8448, ctrIndex=8433, counts=500 50 0 0 0 0 0 0 0x1
ctrStatus=0, ctrCount=9000, ctrIndex=8991, counts=500 50 0 0 0 0 0 0 0x0
This is the output when the program is run on Linux with rate=1000 Hz. It works fine, just like on Windows. I can run it many times and it always works.
> ../../bin/linux-x86_64-ub18/test_USB_CTR 01E538A2 1000 .05
Found 7 DAQ device(s)
Running on Linux
Connecting to device type=USB-CTR08 serial number=01E538A2
ctrStatus=1, ctrCount=459, ctrIndex=450, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=909, ctrIndex=900, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=1368, ctrIndex=1359, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=1818, ctrIndex=1809, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=2277, ctrIndex=2268, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=2727, ctrIndex=2718, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=3186, ctrIndex=3177, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=3636, ctrIndex=3627, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=4086, ctrIndex=4077, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=4545, ctrIndex=4536, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=4995, ctrIndex=4986, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=5454, ctrIndex=5445, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=5904, ctrIndex=5895, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=6354, ctrIndex=6345, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=6813, ctrIndex=6804, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=7263, ctrIndex=7254, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=7722, ctrIndex=7713, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=8172, ctrIndex=8163, counts=1000 100 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=8631, ctrIndex=8622, counts=1000 100 0 0 0 0 0 0 0x0
ctrStatus=0, ctrCount=9000, ctrIndex=8991, counts=1000 100 0 0 0 0 0 0 0x1
This is the output on Linux when the rate is increased to 2000 Hz. The first time the program is run with this rate it works fine, and the results are the same as Windows.
> ../../bin/linux-x86_64-ub18/test_USB_CTR 01E538A2 2000 .05
Found 7 DAQ device(s)
Running on Linux
Connecting to device type=USB-CTR08 serial number=01E538A2
ctrStatus=1, ctrCount=768, ctrIndex=756, counts=500 50 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=1792, ctrIndex=1782, counts=500 50 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=2560, ctrIndex=2547, counts=500 50 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=3584, ctrIndex=3573, counts=500 50 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=4352, ctrIndex=4338, counts=500 50 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=5376, ctrIndex=5364, counts=500 50 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=6144, ctrIndex=6129, counts=500 50 0 0 0 0 0 0 0x0
ctrStatus=1, ctrCount=7168, ctrIndex=7155, counts=500 50 0 0 0 0 0 0 0x1
ctrStatus=1, ctrCount=7936, ctrIndex=7920, counts=500 50 0 0 0 0 0 0 0x0
ctrStatus=0, ctrCount=9000, ctrIndex=8991, counts=500 50 0 0 0 0 0 0 0x1
However, if the program is run again then the results are incorrect. The data are not in the correct position in the array, and the scan never stops, because ctrStatus never goes to 0 and crtCount never reaches 9000. It only reaches 8872.
TahoeU18:/corvette/home/epics/devel/measComp/iocBoot/iocUSBCTR> ../../bin/linux-x86_64-ub18/test_USB_CTR 01E538A2 2000 .05
Found 7 DAQ device(s)
Running on Linux
Connecting to device type=USB-CTR08 serial number=01E538A2
ctrStatus=1, ctrCount=768, ctrIndex=756, counts=0 0 0 0 0 0 0 500 0x32
ctrStatus=1, ctrCount=1536, ctrIndex=1521, counts=0 0 0 0 0 0 1 500 0x32
ctrStatus=1, ctrCount=2560, ctrIndex=2547, counts=0 0 0 0 0 0 0 500 0x32
ctrStatus=1, ctrCount=3328, ctrIndex=3312, counts=0 0 0 0 0 0 1 500 0x32
ctrStatus=1, ctrCount=4352, ctrIndex=4338, counts=0 0 0 0 0 0 0 500 0x32
ctrStatus=1, ctrCount=5120, ctrIndex=5103, counts=0 0 0 0 0 0 1 500 0x32
ctrStatus=1, ctrCount=6144, ctrIndex=6129, counts=0 0 0 0 0 0 0 500 0x32
ctrStatus=1, ctrCount=6912, ctrIndex=6903, counts=0 0 0 0 0 0 1 500 0x32
ctrStatus=1, ctrCount=7936, ctrIndex=7920, counts=0 0 0 0 0 0 0 500 0x32
ctrStatus=1, ctrCount=8872, ctrIndex=8856, counts=0 0 0 0 0 0 1 500 0x32
ctrStatus=1, ctrCount=8872, ctrIndex=8856, counts=0 0 0 0 0 0 1 500 0x32
ctrStatus=1, ctrCount=8872, ctrIndex=8856, counts=0 0 0 0 0 0 1 500 0x32
ctrStatus=1, ctrCount=8872, ctrIndex=8856, counts=0 0 0 0 0 0 1 500 0x32
ctrStatus=1, ctrCount=8872, ctrIndex=8856, counts=0 0 0 0 0 0 1 500 0x32
ctrStatus=1, ctrCount=8872, ctrIndex=8856, counts=0 0 0 0 0 0 1 500 0x32
ctrStatus=1, ctrCount=8872, ctrIndex=8856, counts=0 0 0 0 0 0 1 500 0x32
ctrStatus=1, ctrCount=8872, ctrIndex=8856, counts=0 0 0 0 0 0 1 500 0x32
ctrStatus=1, ctrCount=8872, ctrIndex=8856, counts=0 0 0 0 0 0 1 500 0x32
If I go back to 1000 Hz it fails the first time, but then works the second time and on subsequent runs at 1000 Hz.
Is there something I am neglecting to do in Linux that is causing this problem, or is there a problem with UL for Linux?