arduino / arduino/ArduinoCore-avr

Serial_::write tries to send with closed host

Open
#63 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
1.5k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

`Serial_::write` in [CDC.cpp](https://github.com/arduino/ArduinoCore-avr/blob/5755ddea49fa69d6c505c772ebee5af5078e2ebf/cores/arduino/CDC.cpp#L221) checks if the CDC connection is open by checking if DTR or RTS line state is set. The OS usually sets DTR on open and resets it on close. RTS on the other hand is often left as it is. This means that the check against both leads into the assumption of an valid connection even though there is no peer to read the data, which on the other hand leads into 250 ms delays in `USB_Send` after the send buffer got saturated. I suggest to check only if DTR is set.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in cores/arduino/CDC.cpp at Serial_::write, especially the connection check near line 221, and review how USB_Send behaves after the buffer fills. The issue is done when a closed host with RTS still set no longer attempts to send, while an open connection remains supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.