-
Notifications
You must be signed in to change notification settings - Fork 125
Fix the bug that analogRead and digitalRead doesn't work on Leonardo. #69
Conversation
The DTR should be enable. Other wise serial read cannot work.
Hi @jimaobian, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
Hi there @jimaobian. Have you tested this on an Arduino Uno? |
Actually the DTR signal will cause a hardware reset on the Uno. On the contrary the DTR signal will only cause the hardware reset on the Leonardo, but not run the boot loader. So there is no data loss problem. However if DTR signal is not set on Leonardo, data cannot send from Leonardo to Raspberry Pi, which cause my issue.
|
I have not had a chance to test your changes yet, but it is better to add an event to RemoteDevice's DeviceReady event rather than the IStream object's ConnectionEstablished. The reason is that there is some handshaking that occurs between RemoteDevice and the Arduino. It will repeat the process up to 30 times until the handshaking is successful, or it will report an error if failed (through DeviceConnectionFailed event). |
Great! It works
|
The code works both on Uno and Leonardo. |
Tested well on Uno (restart confirmed), Leo, and DFRobot Bluno. After a discussion with the team, we are not concerned with the rebooting on Uno. Nice work @jimaobian! |
@@ -329,6 +329,7 @@ UsbSerial::connectToDeviceAsync( | |||
// Configure the device properties | |||
_serial_device->Handshake = SerialHandshake::None; | |||
_serial_device->BaudRate = _baud; | |||
_serial_device->IsDataTerminalReadyEnabled = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change these 2 tabs to 8 spaces and I will accept your PR!
Done |
Fix the bug that analogRead and digitalRead doesn't work on Leonardo.
Excellent catch! I'm happy to see this get fixed! Thanks! |
The DTR should be enable. Other wise serial read cannot work on Leonardo.