Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-rabault committed Aug 29, 2023
1 parent 011ee19 commit 01031a5
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions network/serial_network/HAL/NATIVE/serial_network_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,16 +282,14 @@ void SerialHAL_Init(uint8_t *rx_buffer, uint32_t buffer_size)
if (ioctl(serial_port, TIOCGSERIAL, &ser_info) < 0)
{
perror("Error getting serial info");
close(serial_fd);
close(serial_port);
return 1;
}

ser_info.baudrate = SERIAL_NETWORK_BAUDRATE;
ser_info.flags &= ~ASYNC_SPD_MASK; // Clear current baud rate
ser_info.flags |= ASYNC_SPD_CUST; // Set custom baud rate
ser_info.custom_divisor = ser_info.baud_base / 9600; // Set desired baud rate
ioctl(serial_port, TIOCSSERIAL, &ser_info);
if (ioctl(serial_port, IOSSIOSPEED, &speed) < 0)
ser_info.flags &= ~ASYNC_SPD_MASK; // Clear current baud rate
ser_info.flags |= ASYNC_SPD_CUST; // Set custom baud rate
ser_info.custom_divisor = ser_info.baud_base / SERIAL_NETWORK_BAUDRATE; // Set desired baud rate
if (ioctl(serial_port, TIOCSSERIAL, &ser_info) < 0)
{
printf("Error setting baudrate attributes\n");
printf("Error code: %d\n", errno);
Expand Down

0 comments on commit 01031a5

Please sign in to comment.