arduino / arduino/ArduinoCore-mbed
Serial.write(c) not returning what it is supposed to
- Dominant language
- C
- Stars
- 411
- Forks
- 225
- PR merge metrics
- No merged PRs in 30d
Description
I'm using a Nano 33 BLE.
[The doc](https://www.arduino.cc/reference/en/language/functions/communication/serial/write/) says:
> write() will return the number of bytes written, though reading that number is optional. Data type: size_t.
But it doesn't seem so, at least when outputting a single byte with USB.
See this test code:
```
void setup() {
Serial.begin(115200);
while (!Serial);
// After the following line, 'count' is supposed to be 1
const int count = Serial.write('A');
// But it isn't
Serial.println(count);
}
```
Console output:
> A65
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the provided Nano 33 BLE sketch and trace the Serial.write('A') entry point used for USB output. Compare the returned value with the documented byte count; the issue is resolved when writing one byte reports a count of 1.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- arduino, c
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100