Skip to content

Commit

Permalink
fix serial ring buffer management
Browse files Browse the repository at this point in the history
  • Loading branch information
houkhouk committed Jan 23, 2025
1 parent 40f5715 commit 9ac63b4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions network/serial_network/HAL/NATIVE/serial_network_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,16 @@ void SerialHAL_Send(uint8_t *data, uint16_t size)
// Wait for the buffer to be empty
usleep(1000);
ioctl(serial_port, TIOCOUTQ, &bytes_in_buffer);
bytesWritten = write(serial_port, &data[bytesWritten], size - bytesWritten);
bytesWritten = write(serial_port, &data[totalBytesWritten], size - totalBytesWritten);
if (bytesWritten < 0)
{
printf("Error writing to serial port\n");
close(serial_port);
LUOS_ASSERT(0);
bytesWritten = 0;
size = 0;
totalBytesWritten = 0;
ioctl(serial_port, TIOCOUTQ, &bytes_in_buffer);
break;
}
else
{
Expand Down

0 comments on commit 9ac63b4

Please sign in to comment.