Skip to content

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

Closed
wants to merge 3 commits into from
Closed

Conversation

embmicro
Copy link
Contributor

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/

@ArduinoBot
Copy link
Contributor

Can one of the admins verify this patch?

NicoHood pushed a commit to NicoHood/HID that referenced this pull request Dec 9, 2014
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
@NicoHood
Copy link
Contributor

NicoHood commented Feb 9, 2015

A similar implementation can be found here:
https://github.com/NicoHood/HID

@PaulStoffregen
Copy link
Contributor

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.

@cmaglie cmaglie added feature request A request to make an enhancement (not a bug fix) Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) Component: USB Device Opposed to USB Host. Related to the USB subsystem (SerialUSB, HID, ...) labels Apr 15, 2015
@facchinm facchinm added the USB: CDC serial Serial interface used by MCUs with native USB (e.g. Leonardo) to communicate with the computer label Jul 10, 2015
@NicoHood
Copy link
Contributor

This may be closed with the new API now.

@cmaglie
Copy link
Member

cmaglie commented Nov 4, 2015

Fixed with #3343.

@cmaglie cmaglie closed this Nov 4, 2015
@ffissore ffissore modified the milestone: Release 1.6.7 Nov 6, 2015
obra pushed a commit to keyboardio/Kaleidoscope that referenced this pull request Dec 14, 2023
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
obra pushed a commit to keyboardio/Kaleidoscope that referenced this pull request Dec 14, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) Component: USB Device Opposed to USB Host. Related to the USB subsystem (SerialUSB, HID, ...) feature request A request to make an enhancement (not a bug fix) USB: CDC serial Serial interface used by MCUs with native USB (e.g. Leonardo) to communicate with the computer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants