diff --git a/grbl/config.h b/grbl/config.h index b039de4..e0ff8cc 100644 --- a/grbl/config.h +++ b/grbl/config.h @@ -456,7 +456,7 @@ // 115200 baud will take 5 msec to transmit a typical 55 character report. Worst case reports are // around 90-100 characters. As long as the serial TX buffer doesn't get continually maxed, Grbl // will continue operating efficiently. Size the TX buffer around the size of a worst-case report. -// #define RX_BUFFER_SIZE 128 // (1-254) Uncomment to override defaults in serial.h +// #define RX_BUFFER_SIZE 1024 // Uncomment to override defaults in serial.h // #define TX_BUFFER_SIZE 100 // (1-254) // A simple software debouncing feature for hard limit switches. When enabled, the interrupt diff --git a/grbl/report.c b/grbl/report.c index 7dd26af..4fbe457 100644 --- a/grbl/report.c +++ b/grbl/report.c @@ -502,7 +502,7 @@ void report_realtime_status() printPgmString(PSTR("|Bf:")); print_uint8_base10(plan_get_block_buffer_available()); serial_write(','); - print_uint8_base10(serial_get_rx_buffer_available()); + print_uint32_base10(serial_get_rx_buffer_available()); } #endif diff --git a/grbl/serial.c b/grbl/serial.c index 420db7d..9e1fa1b 100644 --- a/grbl/serial.c +++ b/grbl/serial.c @@ -33,8 +33,8 @@ #define TX_RING_BUFFER (TX_BUFFER_SIZE+1) uint8_t serial_rx_buffer[RX_RING_BUFFER]; -uint8_t serial_rx_buffer_head = 0; -volatile uint8_t serial_rx_buffer_tail = 0; +uint16_t serial_rx_buffer_head = 0; +volatile uint16_t serial_rx_buffer_tail = 0; uint8_t serial_tx_buffer[TX_RING_BUFFER]; uint8_t serial_tx_buffer_head = 0; @@ -50,9 +50,9 @@ void legacy_ISR(uint8_t data); uint8_t arm_rx_buf[1]; // Returns the number of bytes available in the RX serial buffer. -uint8_t serial_get_rx_buffer_available() +uint16_t serial_get_rx_buffer_available() { - uint8_t rtail = serial_rx_buffer_tail; // Copy to limit multiple calls to volatile + uint16_t rtail = serial_rx_buffer_tail; // Copy to limit multiple calls to volatile if (serial_rx_buffer_head >= rtail) { return(RX_BUFFER_SIZE - (serial_rx_buffer_head-rtail)); } return((rtail-serial_rx_buffer_head-1)); } @@ -60,9 +60,9 @@ uint8_t serial_get_rx_buffer_available() // Returns the number of bytes used in the RX serial buffer. // NOTE: Deprecated. Not used unless classic status reports are enabled in config.h. -uint8_t serial_get_rx_buffer_count() +uint16_t serial_get_rx_buffer_count() { - uint8_t rtail = serial_rx_buffer_tail; // Copy to limit multiple calls to volatile + uint16_t rtail = serial_rx_buffer_tail; // Copy to limit multiple calls to volatile if (serial_rx_buffer_head >= rtail) { return(serial_rx_buffer_head-rtail); } return (RX_BUFFER_SIZE - (rtail-serial_rx_buffer_head)); } @@ -201,7 +201,7 @@ void legacy_TX_ISR(void* SERIAL_UDRE) // Fetches the first byte in the serial read buffer. Called by main program. uint8_t serial_read() { - uint8_t tail = serial_rx_buffer_tail; // Temporary serial_rx_buffer_tail (to optimize for volatile) + uint16_t tail = serial_rx_buffer_tail; // Temporary serial_rx_buffer_tail (to optimize for volatile) if (serial_rx_buffer_head == tail) { return SERIAL_NO_DATA; } else { @@ -218,7 +218,7 @@ uint8_t serial_read() //Legacy ISR, slightly modified to receive data from ARM callback (serialInterrupt) above. void legacy_ISR(uint8_t data) { - uint8_t next_head; + uint16_t next_head; // Pick off realtime command characters directly from the serial stream. These characters are // not passed into the main buffer, but these set system state flag bits for realtime execution. diff --git a/grbl/serial.h b/grbl/serial.h index 5a3f776..5c4b238 100644 --- a/grbl/serial.h +++ b/grbl/serial.h @@ -24,7 +24,7 @@ #ifndef RX_BUFFER_SIZE - #define RX_BUFFER_SIZE 128 + #define RX_BUFFER_SIZE 1024 #endif #ifndef TX_BUFFER_SIZE #ifdef USE_LINE_NUMBERS @@ -49,11 +49,11 @@ uint8_t serial_read(); void serial_reset_read_buffer(); // Returns the number of bytes available in the RX serial buffer. -uint8_t serial_get_rx_buffer_available(); +uint16_t serial_get_rx_buffer_available(); // Returns the number of bytes used in the RX serial buffer. // NOTE: Deprecated. Not used unless classic status reports are enabled in config.h. -uint8_t serial_get_rx_buffer_count(); +uint16_t serial_get_rx_buffer_count(); // Returns the number of bytes used in the TX serial buffer. // NOTE: Not used except for debugging and ensuring no TX bottlenecks.