I finally found out what the problem was with this. It seems that the
Windows driver for the CH340/CH341 USB to serial adapter on the
arduino clone that I was using is faulty. When I tried an 'official'
arduino with an FTDI adapter, I had no problems at all. Thanks to Uwe
and Martin Ling for helping me out with tips about the driver.

I think it's worth mentioning that these clone arduinos with the CH340
adapter do actually work fine for most other purposes, so it could be
partially an issue within libserialport that causes the problem.

fwiw the default driver loaded by Windows7 is shown in the attached
screenshot. There is also a newer version out there (updated in 2011)
which can be found by searching the net for "ch340 driver", but that
gave the same result.

On Wed, Sep 7, 2016 at 8:31 PM, Chris Campbell <iforc...@gmail.com> wrote:
> Hello! I am using libserialport to connect to an Arduino Uno which
> controls a motor and returns some sensor data. On Linux everything
> works fine. On Windows the program stutters and freezes when sending
> and receiving data. The connection is running at 9600 baud.
> I am using sp_blocking_write to send data, and a loop like below to
> receive data:
> while ( sp_input_waiting(m_connectedPort) ) {
>         int read = sp_blocking_read_next(m_connectedPort, buf, 256, 2);
>         ...
> }
> The 'loop' is done with a QTimer triggering at 16ms or approximately
> 60 frames per second. I am also drawing a graph in an OpenGL view in
> this 'loop' but commenting that out makes no difference.
> I built the Windows libserialport with msys2 following the
> instructions on the sigrok wiki, using a git clone (Mon 5 Sep 2016)
> and the Linux version was built from a git clone around April 2016.
> All hardware is exactly the same in both cases (I'm dual booting
> between Linux and Windows on the same computer).
> You can get a full description of this setup here:
> https://www.youtube.com/watch?v=V3kxl4dHAwE
> For the most part the receiving of data seems to be ok. When
> connected, the arduino is sending sensor data non-stop and pretty much
> saturates the connection. Looking at the graph as it's being drawn,
> there could be some very small stutters, but this is not such a big
> issue for now because...
> The worst problem is when sending from the computer to the arduino,
> the whole program can freeze for anywhere from half a second or so, up
> to 8-10 seconds and can even show "not responding" in the window title
> bar.
> The sent data is very small, it's just a few bytes (usually a 7 byte
> packet) to set the motor speed, and is sent a few times per second if
> being controlled manually, or at most 60 times a second when the
> computer is automatically controlling the motor speed.
> I also tried sp_nonblocking_write. The freezing and stuttering was
> cured, but the data was not sent correctly. When I look at the
> transmission line with an oscilloscope, I see only a single pulse,
> instead of doing the full 7 byte transmission (photo attached).
> Any ideas about other things I could try?
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
sigrok-devel mailing list

Reply via email to