Skip to content
Snippets Groups Projects
Commit e4f7bf51 authored by Sandeep Mistry's avatar Sandeep Mistry Committed by Cristian Maglie
Browse files

Add private availableForStore method, and use in Serial_::accept

parent cea1d20f
No related branches found
No related tags found
No related merge requests found
...@@ -351,6 +351,17 @@ bool Serial_::rts() { ...@@ -351,6 +351,17 @@ bool Serial_::rts() {
return _usbLineInfo.lineState & 0x2; return _usbLineInfo.lineState & 0x2;
} }
int Serial_::availableForStore(void) {
ring_buffer *buffer = &cdc_rx_buffer;
if (buffer->full)
return 0;
else if (buffer->head >= buffer->tail)
return CDC_SERIAL_BUFFER_SIZE - 1 - buffer->head + buffer->tail;
else
return buffer->tail - buffer->head - 1;
}
Serial_ SerialUSB(USBDevice); Serial_ SerialUSB(USBDevice);
#endif #endif
...@@ -168,6 +168,8 @@ public: ...@@ -168,6 +168,8 @@ public:
}; };
private: private:
int availableForStore(void);
USBDeviceClass &usb; USBDeviceClass &usb;
RingBuffer *_cdc_rx_buffer; RingBuffer *_cdc_rx_buffer;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment