 
   clear_debug_message();
 
-  Serial.begin(115200);
-  Serial.setTimeout(3000);
+  Serial.begin(SERIAL_BAUDRATE);
+  Serial.setTimeout(SERIAL_TEXT_TIMEOUT);
 
   setup_spi_dac();
   setup_tc_sampler();


#include "SerialProtocol.h"

// Command and response terminator
const char SERIAL_TERMINATOR = '\r';


  uint16_t *table = waveform_table(params[0]);
  size_t length = sizeof(uint16_t) * g_waveform_length;

  Serial.setTimeout(SERIAL_BINARY_TIMEOUT);
  respond_data_request(length);
  size_t bytes = Serial.readBytes((char *)table, length);
  Serial.setTimeout(SERIAL_TEXT_TIMEOUT);
  if (bytes < length) {
    respond_error(DFGERR_TIMEOUT);
    return;
