flipped '\n' and char storing statement, to not write '\n' into buffer and then overwriting it with '\0'
This commit is contained in:
@@ -73,6 +73,14 @@ static void read_serial_line_task(void *params){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(c == '\n'){
|
||||||
|
buf[it] = '\0';
|
||||||
|
it = 0;
|
||||||
|
|
||||||
|
xQueueSendToBack(serial_queue, buf, portMAX_DELAY);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if(it < MAX_COMMAND_LENGTH - 1){
|
if(it < MAX_COMMAND_LENGTH - 1){
|
||||||
buf[it++] = (char)c;
|
buf[it++] = (char)c;
|
||||||
}
|
}
|
||||||
@@ -80,13 +88,6 @@ static void read_serial_line_task(void *params){
|
|||||||
printf_sync("Command too long, discarding\n");
|
printf_sync("Command too long, discarding\n");
|
||||||
it = 0;
|
it = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(c == '\n'){
|
|
||||||
buf[it] = '\0';
|
|
||||||
it = 0;
|
|
||||||
|
|
||||||
xQueueSendToBack(serial_queue, buf, portMAX_DELAY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -42,7 +42,7 @@ namespace ResponseTester
|
|||||||
{
|
{
|
||||||
Console.WriteLine("Starting response tester...");
|
Console.WriteLine("Starting response tester...");
|
||||||
|
|
||||||
var portName = "COM30";
|
var portName = "/dev/cu.usbmodem101";
|
||||||
var baudrate = 115200;
|
var baudrate = 115200;
|
||||||
|
|
||||||
using var serialPort = new SerialPort(portName, baudrate, Parity.None, 8, StopBits.One);
|
using var serialPort = new SerialPort(portName, baudrate, Parity.None, 8, StopBits.One);
|
||||||
@@ -72,7 +72,8 @@ namespace ResponseTester
|
|||||||
Console.WriteLine($"Sent command: {command.Trim()}");
|
Console.WriteLine($"Sent command: {command.Trim()}");
|
||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
if (counter % burst == 0) {
|
if (counter % burst == 0)
|
||||||
|
{
|
||||||
Thread.Sleep(10);
|
Thread.Sleep(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,4 +99,4 @@ namespace ResponseTester
|
|||||||
Console.WriteLine($"Average Latency: {averageLatency.TotalMilliseconds} ms");
|
Console.WriteLine($"Average Latency: {averageLatency.TotalMilliseconds} ms");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user