rx buffer size = 1024

This commit is contained in:
Todd Fleming 2017-01-10 17:03:14 -05:00
parent 37db018c70
commit c7a4b77e47
4 changed files with 13 additions and 13 deletions

View File

@ -456,7 +456,7 @@
// 115200 baud will take 5 msec to transmit a typical 55 character report. Worst case reports are // 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 // 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. // 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) // #define TX_BUFFER_SIZE 100 // (1-254)
// A simple software debouncing feature for hard limit switches. When enabled, the interrupt // A simple software debouncing feature for hard limit switches. When enabled, the interrupt

View File

@ -502,7 +502,7 @@ void report_realtime_status()
printPgmString(PSTR("|Bf:")); printPgmString(PSTR("|Bf:"));
print_uint8_base10(plan_get_block_buffer_available()); print_uint8_base10(plan_get_block_buffer_available());
serial_write(','); serial_write(',');
print_uint8_base10(serial_get_rx_buffer_available()); print_uint32_base10(serial_get_rx_buffer_available());
} }
#endif #endif

View File

@ -33,8 +33,8 @@
#define TX_RING_BUFFER (TX_BUFFER_SIZE+1) #define TX_RING_BUFFER (TX_BUFFER_SIZE+1)
uint8_t serial_rx_buffer[RX_RING_BUFFER]; uint8_t serial_rx_buffer[RX_RING_BUFFER];
uint8_t serial_rx_buffer_head = 0; uint16_t serial_rx_buffer_head = 0;
volatile uint8_t serial_rx_buffer_tail = 0; volatile uint16_t serial_rx_buffer_tail = 0;
uint8_t serial_tx_buffer[TX_RING_BUFFER]; uint8_t serial_tx_buffer[TX_RING_BUFFER];
uint8_t serial_tx_buffer_head = 0; uint8_t serial_tx_buffer_head = 0;
@ -50,9 +50,9 @@ void legacy_ISR(uint8_t data);
uint8_t arm_rx_buf[1]; uint8_t arm_rx_buf[1];
// Returns the number of bytes available in the RX serial 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()
{ {
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)); } if (serial_rx_buffer_head >= rtail) { return(RX_BUFFER_SIZE - (serial_rx_buffer_head-rtail)); }
return((rtail-serial_rx_buffer_head-1)); 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. // Returns the number of bytes used in the RX serial buffer.
// NOTE: Deprecated. Not used unless classic status reports are enabled in config.h. // 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); } if (serial_rx_buffer_head >= rtail) { return(serial_rx_buffer_head-rtail); }
return (RX_BUFFER_SIZE - (rtail-serial_rx_buffer_head)); 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. // Fetches the first byte in the serial read buffer. Called by main program.
uint8_t serial_read() 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) { if (serial_rx_buffer_head == tail) {
return SERIAL_NO_DATA; return SERIAL_NO_DATA;
} else { } else {
@ -218,7 +218,7 @@ uint8_t serial_read()
//Legacy ISR, slightly modified to receive data from ARM callback (serialInterrupt) above. //Legacy ISR, slightly modified to receive data from ARM callback (serialInterrupt) above.
void legacy_ISR(uint8_t data) 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 // 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. // not passed into the main buffer, but these set system state flag bits for realtime execution.

View File

@ -24,7 +24,7 @@
#ifndef RX_BUFFER_SIZE #ifndef RX_BUFFER_SIZE
#define RX_BUFFER_SIZE 128 #define RX_BUFFER_SIZE 1024
#endif #endif
#ifndef TX_BUFFER_SIZE #ifndef TX_BUFFER_SIZE
#ifdef USE_LINE_NUMBERS #ifdef USE_LINE_NUMBERS
@ -49,11 +49,11 @@ uint8_t serial_read();
void serial_reset_read_buffer(); void serial_reset_read_buffer();
// Returns the number of bytes available in the RX serial 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. // Returns the number of bytes used in the RX serial buffer.
// NOTE: Deprecated. Not used unless classic status reports are enabled in config.h. // 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. // Returns the number of bytes used in the TX serial buffer.
// NOTE: Not used except for debugging and ensuring no TX bottlenecks. // NOTE: Not used except for debugging and ensuring no TX bottlenecks.