File tree 2 files changed +21
-6
lines changed
2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -558,23 +558,23 @@ int HWCDC::available(void) {
558
558
return uxQueueMessagesWaiting (rx_queue);
559
559
}
560
560
561
- int HWCDC::peek ( void ) {
561
+ int HWCDC::_peek (TickType_t timeout ) {
562
562
if (rx_queue == NULL ) {
563
563
return -1 ;
564
564
}
565
565
uint8_t c;
566
- if (xQueuePeek (rx_queue, &c, 0 )) {
566
+ if (xQueuePeek (rx_queue, &c, timeout )) {
567
567
return c;
568
568
}
569
569
return -1 ;
570
570
}
571
571
572
- int HWCDC::read ( void ) {
572
+ int HWCDC::_read (TickType_t timeout ) {
573
573
if (rx_queue == NULL ) {
574
574
return -1 ;
575
575
}
576
576
uint8_t c = 0 ;
577
- if (xQueueReceive (rx_queue, &c, 0 )) {
577
+ if (xQueueReceive (rx_queue, &c, timeout )) {
578
578
return c;
579
579
}
580
580
return -1 ;
Original file line number Diff line number Diff line change @@ -48,6 +48,17 @@ class HWCDC : public Stream {
48
48
static bool deinit (void *busptr);
49
49
static bool isCDC_Connected ();
50
50
51
+ protected:
52
+ int _peek (TickType_t timeout);
53
+ int _read (TickType_t timeout);
54
+
55
+ virtual int timedRead () override {
56
+ return _read (pdMS_TO_TICKS (_timeout));
57
+ }
58
+ virtual int timedPeek () override {
59
+ return _peek (pdMS_TO_TICKS (_timeout));
60
+ }
61
+
51
62
public:
52
63
HWCDC ();
53
64
~HWCDC ();
@@ -63,8 +74,12 @@ class HWCDC : public Stream {
63
74
64
75
int available (void );
65
76
int availableForWrite (void );
66
- int peek (void );
67
- int read (void );
77
+ int peek (void ){
78
+ return _peek (0 );
79
+ }
80
+ int read (void ){
81
+ return _read (0 );
82
+ }
68
83
size_t read (uint8_t *buffer, size_t size);
69
84
size_t write (uint8_t );
70
85
size_t write (const uint8_t *buffer, size_t size);
You can’t perform that action at this time.
0 commit comments