arduino / arduino/ArduinoCore-sam

CDC boolean operator speed issue

Open
#106 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
91
Forks
112
PR merge metrics
No merged PRs in 30d

Description

While looking for a slow USB CDC connection (~30-40kB/s) I found that there is an artifical delay in the boolean operator:
https://github.com/arduino/ArduinoCore-sam/blob/c893c62ec9953ed36a256b5243272fda2e473c14/cores/arduino/USB/CDC.cpp#L314

I can not find a reasoning for this delay. Removing it from the source greatly improved USB Speed for me to about 140kB/s

```
void setup() {
// put your setup code here, to run once:
SerialUSB.begin(2000000) ;
}

byte buffer[512] ;

void loop() {

#if 1
int pos = 0 ;
if (!SerialUSB)
return ;
while (SerialUSB.available())
{
if (pos >= sizeof(buffer))
return ;
buffer[pos++] = SerialUSB.read();
}
if (pos)
SerialUSB.write(buffer, pos);
return ;
#endif
}
```

Does anyone know the reasoning behind this delay?

Thanks in advance,
Tim

Contributor guide

No contributing guide indexed for this repository

Research direction

Inspect cores/arduino/USB/CDC.cpp at the linked boolean operator delay and trace why it is present. Reproduce the USB CDC throughput example, compare behavior with and without the delay, and confirm whether removing it preserves the expected CDC behavior while improving throughput.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
embedded-iot, performance
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.