I'd like to know if it's possible to have a faster method to upload a string to the the transmit buffer.
In my system I have a maximum processing time of 390us. This all works well but when debugging, the amount of text output causes the timing to be exceeded. I was hoping that a larger output buffer would help. It's definitely an improvement over HardwareSerial.
I've been testing with a 29 character message and HardwareSerial took 892us to send the message. Using SerialPort with a transmit buffer size of 32 bytes it's down to 168us. However just doing a memory copy takes 16us.
So I've been wondering if there's a way to allow the SerialPort class to have a fast copy into the transmit buffer?
#include <SerialPort.h>
SerialPort<0, 0, 32> port;
void setup(void)
{
port.begin(115200);
for (int route = 0; route < 11; route++)
{
uint32_t start;
start = micros();
DebugPrintLine("Selecting passenger route x");
ShowMessageTime(start, micros());
start = micros();
DebugPrintLine2("Selecting passenger route x");
ShowMessageTime(start, micros());
}
}
void loop(void)
{
}
void DebugPrintLine(const char* message)
{
while (*message != '\0')
{
port.write(*message++);
}
port.write('\r');
port.write('\n');
}
void DebugPrintLine2(const char* message)
{
char buffer[50];
char* dest = buffer;
while (*dest++ = *message++)
;
*dest++ = '\r';
*dest++ = '\n';
}
void ShowMessageTime(uint32_t start, uint32_t stop)
{
port.print("Message time:");
port.print(stop - start, DEC);
port.println("us");
delay(400);
}
Iain