Skip to content

Commit 2975572

Browse files
committed
Improve arduino_serial_platform_read
1 parent 912b1be commit 2975572

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

examples/micro-ros_publisher/micro-ros_publisher.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ rcl_timer_t timer;
2424

2525
void error_loop(){
2626
while(1){
27-
digitalWrite(LED_PIN, !digitalRead(LED_PIN));
28-
delay(100);
27+
// digitalWrite(LED_PIN, !digitalRead(LED_PIN));
28+
delay(300);
29+
SerialUSB.println("Error");
2930
}
3031
}
3132

@@ -82,6 +83,5 @@ void setup() {
8283
}
8384

8485
void loop() {
85-
delay(100);
8686
RCCHECK(rclc_executor_spin_some(&executor, RCL_MS_TO_NS(100)));
8787
}

examples/micro-ros_publisher/transport.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,7 @@ extern "C"
4444
// Place here your reading bytes platform code
4545
// Return number of bytes read (max bytes: len)
4646
(void)errcode;
47-
uint32_t start_time = micros() * 1000;
48-
size_t readed = 0;
49-
50-
while ((readed < len) && ((micros() * 1000) - start_time) < (uint32_t)timeout)
51-
{
52-
if (SerialUSB.available())
53-
{
54-
buf[readed++] = SerialUSB.read();
55-
}
56-
}
57-
58-
return readed;
47+
SerialUSB.setTimeout(timeout);
48+
return SerialUSB.readBytes((char *)buf, len);
5949
}
6050
}

src/cortex-m0plus/libmicroros.a

3.86 MB
Binary file not shown.

0 commit comments

Comments
 (0)