Unreliable connection through USB

Discussion in 'General' started by Ivan Frade, Aug 23, 2016.

  1. Ivan Frade

    Ivan Frade New Member


    I am trying to read baseband IQ data from the xethru x2m200, plugged to my computer through USB. I can set up the device and receive the baseband IQ lines... but every now and then (randomly, in seconds or minutes) I get a "WindowsError 22" (device doesn't recognize the command, on win32.clearCommError) on the serial. Disconnecting, waiting few seconds and reconnecting allows me to keep reading.

    This is happening on windows with pyserial. Does anybody else have seen this problem?

    I suspect the problem could be a mismatch in the serial configuration... does anybody know the specific params the device is using? Here is the pyserial connect method. The defaults seem to work pretty well, but the connection is not reliable in longer readings.

    For the record, I tried changing the baudrate. Increasing it to 900k didn't help but 200k did a bit... then again, the failures are so random that is difficult to say.

    Maybe anybody using this device with python have seen/fix a problem like this?

  2. Josh Gardiner

    Josh Gardiner New Member

    Not directly had your problem, but similar problems using usb serial on windows 10. win10 would occasionally mess with the usb power management settings, I cant say I ever satisfactorily fixed this, but other people might have suggestions.
  3. Olav Liseth

    Olav Liseth Administrator Staff Member

    stacey likes this.
  4. Josh Gardiner

    Josh Gardiner New Member

    More info:
    Not with python on windows (I'm using Go on Linux), but I have noticed that occasionally the serial from X2M200 will concatenate two packets into one. I have not hooked up the oscilloscope but my guess is that it might not be waiting the required serial clocks(two I think) between frames when using usb. I found this more so when running at higher baud rates and with baseband enabled. My solution was to use a buffer and scan for the frame flags rather than relying on the usb to frame the packets for me.
    I have also seen a situation where the X2M200 will "lock up" after just a short time of streaming. I have no idea of the cause as it happens so rarely (maybe 1 of 50 times).
    I can reliably stream respiration, sleep, and full baseband (52bins) with 115200 baud, but higher baud rates gives me more idle time.

    May help:
    In windows you can set the default baudrate in the properties of the comm port in device manager.