On 12/03/14 00:27, Jef Driesen wrote:
Even a sleep of just 1ms per packet is pretty bad. If I remember correctly, the resolution of the Windows Sleep() function is in the order of 10-15ms only. So that would still be a delay of approximately 40.96 seconds.
I wonder if this is another case where the tcdrain() function isn't waiting properly until all bytes have been send out. We had a similar problem with Suunto devices before. There we implemented a workaround with serial_set_halfduplex() function. Could you try that as well? Just call it somewhere in the oceanic_atom2_device_open() function, but before the call to the oceanic_atom2_device_open() function.
I don't see any change.
How many wires does the Oceanic interface have? Just two or more?
Three.
I have been looking at the kernel history for the ftdi usb-serial driver, and there have been some changes related to waiting until the TX buffer is empty, so there could be something there as well. Which kernel version do you have (uname -a)?
I had 3.2.54 but after reading Linus's email as well I upgraded to 3.12.9 but I don't see any change there either. With regard to the FTDI latency issue you mentioned earlier, in 3.12.9 it seems the default is already set to the minimum:
$ cat /sys/bus/usb-serial/devices/ttyUSB0/latency_timer 1
PS: Don't forget to attach the logfiles. I want to have a look at the timings.
Here's it running with the half duplex change:
[0.000032] DATETIME 2014-03-11T23:50:21Z (1394581821) [0.000055] VERSION 0.4.2 [0.000058] DEVICE=/dev/ttyUSB0 [0.000063] oceanic_atom2_device_open [0.000854] INFO: Configure: baudrate=38400, databits=8, parity=0, stopbits=1, flowcontrol=0 [0.001001] INFO: Timeout: value=3000 [0.001011] INFO: Sleep: value=100 [0.101086] INFO: Flush: queue=3, input=0, output=0 [0.101478] INFO: Sleep: value=3 [0.104540] INFO: Write: size=2, data=8400 [0.104551] INFO: Read: size=1, data=5A [0.106774] INFO: Read: size=17, data=4F43452056543320523244203531324BBF [0.106785] dc_device_dump [0.109560] INFO: Sleep: value=1 [0.110624] INFO: Write: size=4, data=B1000000 [0.110634] INFO: Read: size=1, data=A5 [0.110637] ERROR: Unexpected answer start byte(s). [in oceanic_atom2.c:339 (oceanic_atom2_send)] [0.110639] INFO: Sleep: value=100 [0.210709] INFO: Flush: queue=1, input=0, output=0 [0.213559] INFO: Sleep: value=1 [0.214622] INFO: Write: size=4, data=B1000000 [0.214630] INFO: Read: size=1, data=5A [0.223108] INFO: Read: size=17, data=0416041120081001425800730000000075 [0.225561] INFO: Sleep: value=1 [0.226626] INFO: Write: size=4, data=B1000100 [3.229650] INFO: Read: size=0, data= [3.229662] ERROR: Failed to receive the answer. [in oceanic_atom2.c:333 (oceanic_atom2_send)] [3.229667] INFO: Sleep: value=100 [3.329737] INFO: Flush: queue=1, input=0, output=0 [3.333561] INFO: Write: size=4, data=B1000100 [3.333572] INFO: Read: size=1, data=5A [3.342815] INFO: Read: size=17, data=6701DA064204E506E206DC06FF0FAAFBF6 [3.345590] INFO: Sleep: value=1 [3.346656] INFO: Write: size=4, data=B1000200 [3.346665] INFO: Read: size=1, data=A5 [3.346667] ERROR: Unexpected answer start byte(s). [in oceanic_atom2.c:339 (oceanic_atom2_send)] [3.346670] INFO: Sleep: value=100 [3.446738] INFO: Flush: queue=1, input=0, output=0 [3.449561] INFO: Sleep: value=1 [3.450627] INFO: Write: size=4, data=B1000200 [3.450637] INFO: Read: size=1, data=5A [3.459179] INFO: Read: size=17, data=0000DC06FF0FDC06FF0F00000000AA8A14 [3.461560] INFO: Sleep: value=1 [3.462625] INFO: Write: size=4, data=B1000300 [6.465647] INFO: Read: size=0, data= [6.465658] ERROR: Failed to receive the answer. [in oceanic_atom2.c:333 (oceanic_atom2_send)] [6.465662] INFO: Sleep: value=100 [6.565732] INFO: Flush: queue=1, input=0, output=0 [6.569559] INFO: Write: size=4, data=B1000300 [6.569570] INFO: Read: size=1, data=5A [6.578829] INFO: Read: size=17, data=890E370D00011B0B670542053250AAE1C2 [6.581562] INFO: Sleep: value=1 [6.582626] INFO: Write: size=4, data=B1000400 [6.582636] INFO: Read: size=1, data=A5 [6.582638] ERROR: Unexpected answer start byte(s). [in oceanic_atom2.c:339 (oceanic_atom2_send)] [6.582640] INFO: Sleep: value=100 [6.682709] INFO: Flush: queue=1, input=0, output=0 [6.685558] INFO: Sleep: value=1 [6.686618] INFO: Write: size=4, data=B1000400 [6.686626] INFO: Read: size=1, data=5A [6.695494] INFO: Read: size=17, data=300220028003500530BEB0BB0000000085 [6.697557] INFO: Sleep: value=1 [6.698616] INFO: Write: size=4, data=B1000500 [6.698622] INFO: Read: size=1, data=A5 [6.698623] ERROR: Unexpected answer start byte(s). [in oceanic_atom2.c:339 (oceanic_atom2_send)] [6.698626] INFO: Sleep: value=100 [6.798693] INFO: Flush: queue=1, input=0, output=0 [6.801560] INFO: Sleep: value=1 [6.802626] INFO: Write: size=4, data=B1000500 [6.802636] INFO: Read: size=1, data=5A [6.810993] INFO: Read: size=17, data=A014000300002C01980805A0022100024E [6.813590] INFO: Sleep: value=1 [6.814656] INFO: Write: size=4, data=B1000600 [9.817693] INFO: Read: size=0, data= [9.817717] ERROR: Failed to receive the answer. [in oceanic_atom2.c:333 (oceanic_atom2_send)] [9.817723] INFO: Sleep: value=100 [9.917791] INFO: Flush: queue=1, input=0, output=0 [9.921590] INFO: Write: size=4, data=B1000600 [9.921602] INFO: Read: size=1, data=5A [9.930645] INFO: Read: size=17, data=3899000099003102E9050400000000008F [9.933561] INFO: Sleep: value=1 [9.934620] INFO: Write: size=4, data=B1000700 [9.934626] INFO: Read: size=1, data=A5 [9.934628] ERROR: Unexpected answer start byte(s). [in oceanic_atom2.c:339 (oceanic_atom2_send)] [9.934631] INFO: Sleep: value=100 [10.034727] INFO: Flush: queue=1, input=0, output=0 [10.037561] INFO: Sleep: value=1 [10.038626] INFO: Write: size=4, data=B1000700 [10.038637] INFO: Read: size=1, data=5A [10.047154] INFO: Read: size=17, data=0906290000000000003C00000100000277 [10.049588] INFO: Sleep: value=1 [10.050663] INFO: Write: size=4, data=B1000800 [13.053576] INFO: Read: size=0, data= [13.053592] ERROR: Failed to receive the answer. [in oceanic_atom2.c:333 (oceanic_atom2_send)] [13.053598] INFO: Sleep: value=100 [13.153679] INFO: Flush: queue=1, input=0, output=0 [13.157561] INFO: Write: size=4, data=B1000800 [13.157571] INFO: Read: size=1, data=5A [13.166564] INFO: Read: size=17, data=A9A6C9AAAAAAAAAAAA0000000000000014 [13.169566] INFO: Sleep: value=1 [13.170625] INFO: Write: size=4, data=B1000900 [13.170632] INFO: Read: size=1, data=A5 [13.170634] ERROR: Unexpected answer start byte(s). [in oceanic_atom2.c:339 (oceanic_atom2_send)] [13.170637] INFO: Sleep: value=100 [13.270704] INFO: Flush: queue=1, input=0, output=0 [13.273560] INFO: Sleep: value=1 [13.274626] INFO: Write: size=4, data=B1000900 [13.274636] INFO: Read: size=1, data=5A [13.283203] INFO: Read: size=17, data=6400000300001400980805A00251000215 [13.285561] INFO: Sleep: value=1 [13.286626] INFO: Write: size=4, data=B1000A00 [16.289661] INFO: Read: size=0, data= [16.289679] ERROR: Failed to receive the answer. [in oceanic_atom2.c:333 (oceanic_atom2_send)] [16.289693] INFO: Sleep: value=100 [16.389770] INFO: Flush: queue=1, input=0, output=0 [16.393579] INFO: Write: size=4, data=B1000A00 [16.393600] INFO: Read: size=1, data=5A [16.402613] INFO: Read: size=17, data=0000000000000000000000000000000000 [16.405595] INFO: Sleep: value=1 [16.406670] INFO: Write: size=4, data=B1000B00 [16.406689] INFO: Read: size=1, data=A5 [16.406693] ERROR: Unexpected answer start byte(s). [in oceanic_atom2.c:339 (oceanic_atom2_send)] [16.406698] INFO: Sleep: value=100 [16.506773] INFO: Flush: queue=1, input=0, output=0 [16.509576] INFO: Sleep: value=1 [16.510658] INFO: Write: size=4, data=B1000B00 [16.510680] INFO: Read: size=1, data=5A [16.519117] INFO: Read: size=17, data=42056EA46350460014AA1001438348204F [16.521562] INFO: Sleep: value=1 [16.522627] INFO: Write: size=4, data=B1000C00 [19.525664] INFO: Read: size=0, data= [19.525683] ERROR: Failed to receive the answer. [in oceanic_atom2.c:333 (oceanic_atom2_send)] [19.525689] INFO: Sleep: value=100 [19.625760] INFO: Flush: queue=1, input=0, output=0 [19.629589] INFO: Write: size=4, data=B1000C00 [19.629601] INFO: Read: size=1, data=5A [19.638596] INFO: Read: size=17, data=43142CA56F40510015AA541324064720DF [19.641565] INFO: Sleep: value=1 [19.642636] INFO: Write: size=4, data=B1000D00 [19.642649] INFO: Read: size=1, data=A5 [19.642652] ERROR: Unexpected answer start byte(s). [in oceanic_atom2.c:339 (oceanic_atom2_send)] [19.642658] INFO: Sleep: value=100 [19.742726] INFO: Flush: queue=1, input=0, output=0 [19.745589] INFO: Sleep: value=1 [19.746655] INFO: Write: size=4, data=B1000D00 [19.746665] INFO: Read: size=1, data=5A [19.755186] INFO: Read: size=17, data=4414FEA35D40450015AA240440114D2080 [19.757560] INFO: Sleep: value=1 [19.758622] INFO: Write: size=4, data=B1000E00 [22.761642] INFO: Read: size=0, data= [22.761653] ERROR: Failed to receive the answer. [in oceanic_atom2.c:333 (oceanic_atom2_send)] [22.761657] INFO: Sleep: value=100 [22.861725] INFO: Flush: queue=1, input=0, output=0 [22.865565] INFO: Write: size=4, data=B1000E00 [22.865575] INFO: Read: size=1, data=5A [22.874812] INFO: Read: size=17, data=4524B9A46840450015AA530119824B20CC [22.877568] INFO: Sleep: value=1 [22.878629] INFO: Write: size=4, data=B1000F00 [22.878635] INFO: Read: size=1, data=A5 [22.878637] ERROR: Unexpected answer start byte(s). [in oceanic_atom2.c:339 (oceanic_atom2_send)] [22.878640] INFO: Sleep: value=100
Occasionally even the very first command (get version) fails. I have just the original 100 ms delay after open in now.
[0.000044] DATETIME 2014-03-12T00:00:24Z (1394582424) [0.000075] VERSION 0.4.2 [0.000079] DEVICE=/dev/ttyUSB0 [0.000086] oceanic_atom2_device_open [0.000793] INFO: Configure: baudrate=38400, databits=8, parity=0, stopbits=1, flowcontrol=0 [0.000993] INFO: Timeout: value=3000 [0.001001] INFO: Sleep: value=100 [0.101090] INFO: Flush: queue=3, input=263, output=0 [0.101407] INFO: Sleep: value=3 [0.104481] INFO: Write: size=2, data=8400 [0.104504] INFO: Read: size=1, data=00 [0.104508] ERROR: Unexpected answer start byte(s). [in oceanic_atom2.c:339 (oceanic_atom2_send)] [0.104517] INFO: Sleep: value=100 [0.204588] INFO: Flush: queue=1, input=118, output=0 [0.204898] INFO: Sleep: value=3 [0.207960] INFO: Write: size=2, data=8400 [0.207970] INFO: Read: size=1, data=5A [0.209921] INFO: Read: size=17, data=4F43452056543320523244203531324BBF [0.209935] dc_device_dump
Hamish