Commit 85cf2027 authored by Dean Camera's avatar Dean Camera
Browse files

Fixed USBtoSerial and XPLAINBridge demos discarding data from the PC if the...

Fixed USBtoSerial and XPLAINBridge demos discarding data from the PC if the send buffer becomes full.
parent 8f9b5ae0
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
#define __ENDPOINT_STREAM_H__ #define __ENDPOINT_STREAM_H__
/* Includes: */ /* Includes: */
#include <avr/io.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <avr/eeprom.h> #include <avr/eeprom.h>
#include <stdbool.h> #include <stdbool.h>
......
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
#define __PIPE_STREAM_H__ #define __PIPE_STREAM_H__
/* Includes: */ /* Includes: */
#include <avr/io.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <avr/eeprom.h> #include <avr/eeprom.h>
#include <stdbool.h> #include <stdbool.h>
......
...@@ -93,6 +93,7 @@ ...@@ -93,6 +93,7 @@
* - Fixed random enumeration failure while in device mode due to interrupts causing the Set Address request to exceed maximum timings * - Fixed random enumeration failure while in device mode due to interrupts causing the Set Address request to exceed maximum timings
* - Fixed MIDI_Host_Flush() not aborting early when the specified MIDI host interface was not configured * - Fixed MIDI_Host_Flush() not aborting early when the specified MIDI host interface was not configured
* - Fixed MIDI class driver send routines silently discarding packets if the endpoint or pipe is busy (thanks to Robin Green) * - Fixed MIDI class driver send routines silently discarding packets if the endpoint or pipe is busy (thanks to Robin Green)
* - Fixed USBtoSerial and XPLAINBridge demos discarding data from the PC if the send buffer becomes full
* *
* \section Sec_ChangeLog100807 Version 100807 * \section Sec_ChangeLog100807 Version 100807
* <b>New:</b> * <b>New:</b>
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
* *
* \section Sec_InDevelopment Latest In-Development Source Code * \section Sec_InDevelopment Latest In-Development Source Code
* Issue Tracker: http://www.lufa-lib.org/tracker \n * Issue Tracker: http://www.lufa-lib.org/tracker \n
* Bazaar Access: http://www.lufa-lib.org/bzr \n
* SVN Access: http://www.lufa-lib.org/svn \n * SVN Access: http://www.lufa-lib.org/svn \n
* Git Access: http://www.lufa-lib.org/git \n * Git Access: http://www.lufa-lib.org/git \n
* Mercurial Access: http://www.lufa-lib.org/hg \n * Mercurial Access: http://www.lufa-lib.org/hg \n
......
...@@ -81,15 +81,21 @@ int main(void) ...@@ -81,15 +81,21 @@ int main(void)
for (;;) for (;;)
{ {
/* Read bytes from the USB OUT endpoint into the USART transmit buffer */ /* Only try to read in bytes from the CDC interface if the transmit buffer is not full */
int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface); if (!(RingBuffer_IsFull(&USBtoUSART_Buffer)))
if (!(ReceivedByte < 0) && !(RingBuffer_IsFull(&USBtoUSART_Buffer))) {
RingBuffer_Insert(&USBtoUSART_Buffer, ReceivedByte); int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);
/* Read bytes from the USB OUT endpoint into the USART transmit buffer */
if (!(ReceivedByte < 0))
RingBuffer_Insert(&USBtoUSART_Buffer, ReceivedByte);
}
/* Check if the UART receive buffer flush timer has expired or the buffer is nearly full */ /* Check if the UART receive buffer flush timer has expired or the buffer is nearly full */
RingBuff_Count_t BufferCount = RingBuffer_GetCount(&USARTtoUSB_Buffer); RingBuff_Count_t BufferCount = RingBuffer_GetCount(&USARTtoUSB_Buffer);
if ((TIFR0 & (1 << TOV0)) || (BufferCount > 200)) if ((TIFR0 & (1 << TOV0)) || (BufferCount > 200))
{ {
/* Clear flush timer expiry flag */
TIFR0 |= (1 << TOV0); TIFR0 |= (1 << TOV0);
/* Read bytes from the USART receive buffer into the USB IN endpoint */ /* Read bytes from the USART receive buffer into the USB IN endpoint */
......
...@@ -119,15 +119,21 @@ void UARTBridge_Task(void) ...@@ -119,15 +119,21 @@ void UARTBridge_Task(void)
if (USB_DeviceState != DEVICE_STATE_Configured) if (USB_DeviceState != DEVICE_STATE_Configured)
return; return;
/* Read bytes from the USB OUT endpoint into the UART transmit buffer */ /* Only try to read in bytes from the CDC interface if the transmit buffer is not full */
int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface); if (!(RingBuffer_IsFull(&USBtoUART_Buffer)))
if (!(ReceivedByte < 0) && !(RingBuffer_IsFull(&USBtoUART_Buffer))) {
RingBuffer_Insert(&USBtoUART_Buffer, ReceivedByte); int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);
/* Read bytes from the USB OUT endpoint into the UART transmit buffer */
if (!(ReceivedByte < 0))
RingBuffer_Insert(&USBtoUART_Buffer, ReceivedByte);
}
/* Check if the UART receive buffer flush timer has expired or buffer is nearly full */ /* Check if the UART receive buffer flush timer has expired or buffer is nearly full */
RingBuff_Count_t BufferCount = RingBuffer_GetCount(&UARTtoUSB_Buffer); RingBuff_Count_t BufferCount = RingBuffer_GetCount(&UARTtoUSB_Buffer);
if ((TIFR0 & (1 << TOV0)) || (BufferCount > 200)) if ((TIFR0 & (1 << TOV0)) || (BufferCount > 200))
{ {
/* Clear flush timer expiry flag */
TIFR0 |= (1 << TOV0); TIFR0 |= (1 << TOV0);
/* Read bytes from the UART receive buffer into the USB IN endpoint */ /* Read bytes from the UART receive buffer into the USB IN endpoint */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment