I am the author of pymata-aio <https://github.com/MrYsLab/pymata-aio/wiki>, 
an asyncio library for communicating with Arduino boards. The example code 
below is a "fix" for a problem encountered only on Windows, and I don't 
know if this is expected behavior or a bug.

The code uses pymata-aio to configure an Arduino for analog input on 2 pins 
and digital input input on 2 other pins. The Arduino reports analog and 
digital input data updates asynchronously approximately every 17 ms. To 
have the code work properly on Windows, the user must start python with the 
-u option and in addition, add the flush=True option to the print 
statement. If this is not done, the data that is being printed lags behind 
the actual data changes.

Neither the -u option nor the flush=True are required for Linux/Mac 
operation. I suspect the differences between the OS's event loop 
implementations is at the root of the problem.

The code may be viewed here: 
https://gist.github.com/MrYsLab/c3a69625cf844cbeb9e0.

Any thoughts if this is a bug or not?






Reply via email to