Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app/src/processing/app/debug/AvrdudeUploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,12 @@ private boolean uploadViaBootloader(String buildPath, String className)
long timeout = System.currentTimeMillis() + 2000;
while (timeout > System.currentTimeMillis()) {
List<String> portList = Serial.list();
if (portList.contains(Preferences.get("serial.port"))) {
uploadPort = Preferences.get("serial.port");
if (portList.contains(uploadPort)) {
// Remove the magic baud rate (1200bps) to avoid future unwanted board resets
int serialRate = Preferences.getInteger("serial.debug_rate");
System.out.println("Set baud rate to " + serialRate);
Serial.touchPort(uploadPort, serialRate);
break;
}
try {
Expand Down
10 changes: 8 additions & 2 deletions hardware/arduino/cores/arduino/CDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,22 @@ void Serial_::end(void)
void Serial_::accept(void)
{
ring_buffer *buffer = &cdc_rx_buffer;
int c = USB_Recv(CDC_RX);
int i = (unsigned int)(buffer->head+1) % SERIAL_BUFFER_SIZE;

// if we should be storing the received character into the location
// just before the tail (meaning that the head would advance to the
// current location of the tail), we're about to overflow the buffer
// and so we don't write the character or advance the head.
if (i != buffer->tail) {

// while we have room to store a byte
while (i != buffer->tail) {
int c = USB_Recv(CDC_RX);
if (c == -1)
break; // no more data
buffer->buffer[buffer->head] = c;
buffer->head = i;

i = (unsigned int)(buffer->head+1) % SERIAL_BUFFER_SIZE;
}
}

Expand Down
2 changes: 1 addition & 1 deletion hardware/arduino/cores/arduino/USBCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ ISR(USB_GEN_vect)
{
#ifdef CDC_ENABLED
USB_Flush(CDC_TX); // Send a tx frame if found
while (USB_Available(CDC_RX)) // Handle received bytes (if any)
if (USB_Available(CDC_RX)) // Handle received bytes (if any)
Serial.accept();
#endif

Expand Down