-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Add USB Serial Port Callbacks #2469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Can one of the admins verify this patch? |
arduino/Arduino#2469 Weak implementation sounds usefull but takes 6 more bytes of flash/ function (12). Even more, if we would also pass the line states but the user can read this with Serial.dtr() for example. arduino/Arduino#1179 Should we inline the Serial.dtr() functuions etc? But then we need to move the line info to the header as well, also the definition. These optional functions only take flash if they are used. Virtual isnt used, because this would take more flash for no reason. Syntax like this: https://www.pjrc.com/teensy/td_serial.html
A similar implementation can be found here: |
I would advise caution when considering interrupt callbacks. Such callbacks are seductive, since they promise very immediate response, and because they're so easy to implement. But exposing end users to interrupt context should be avoided, if possible. Interrupt context is a nightmare of thorny programming, requiring very careful design to properly share any data with other parts of the code that aren't interrupt based. Even experts often get it wrong. Bugs tend to be subtle and almost impossible to diagnose. A good portion of the Arduino API also isn't safe to use from interrupt context. |
This may be closed with the new API now. |
Fixed with #3343. |
arduino/Arduino#2469 Weak implementation sounds usefull but takes 6 more bytes of flash/ function (12). Even more, if we would also pass the line states but the user can read this with Serial.dtr() for example. arduino/Arduino#1179 Should we inline the Serial.dtr() functuions etc? But then we need to move the line info to the header as well, also the definition. These optional functions only take flash if they are used. Virtual isnt used, because this would take more flash for no reason. Syntax like this: https://www.pjrc.com/teensy/td_serial.html
arduino/Arduino#2469 Weak implementation sounds usefull but takes 6 more bytes of flash/ function (12). Even more, if we would also pass the line states but the user can read this with Serial.dtr() for example. arduino/Arduino#1179 Should we inline the Serial.dtr() functuions etc? But then we need to move the line info to the header as well, also the definition. These optional functions only take flash if they are used. Virtual isnt used, because this would take more flash for no reason. Syntax like this: https://www.pjrc.com/teensy/td_serial.html
These edits allow the functions lineCodingEvent and lineStateEvent to be used in sketches to know when the virtual serial port's control lines or baud rate changes.
They are needed for creating sketches that act as a USB->Serial Port interface or interfacing with software that uses these signals as controls.
They were originally authored by Peter Van Hoyweghen http://petervanhoyweghen.wordpress.com/2012/11/08/using-the-leonardo-as-usb-to-serial-converter/