Open eejd opened 5 years ago
Further investigation reveals that this problem occurs only on Windows, but not on MacOS (identical Anaconda Python distributions, pyFirmata versions). The best I have been able to gather is that it's in the serial byte reading code, but I haven't determined the cause. Observing the LSB and MSB reads, they are not correct.
I have tried to read a 14-bit value from the analog pin using pyFirmata (1.1.0) and Firmata (2.5.8) on an Arduino Mega. The values appear to not be converting even the two byte (protocol 2.0) messages correctly. This is not using EXTENDED_ANALOG. I can read the values correctly from the Arduino if I use another protocol parser (example, Bonsai C# Aurduino Fermata node, C++ reference code). I am trying to locate the error in the code to submit a patch, but I am unclear on the state of the pyFirmata support for protocol >= 2.0. The _handle_analog_message assumes the 1.0 max value of 1024 and doesn't seem to be doing message interrogation necessary to support EXTENDED_ANALOG. Output of a straight value extraction (loop polling analog pin 1) shows value jumps that appear to be reading extra bits incorrectly. (I.e. values above 1.0 with the assumed 1024 integer range). Is this a known problem/restriction?