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 241c5d0 commit 011ee19
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions network/serial_network/HAL/NATIVE/serial_network_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,26 @@ void SerialHAL_Init(uint8_t *rx_buffer, uint32_t buffer_size)
LUOS_ASSERT(0);
}
#else
// Get the baud rate
baudrate = cfsetspeed(&options, SERIAL_NETWORK_BAUDRATE);

// Check if the baud rate is supported
if (baudrate == SERIAL_NETWORK_BAUDRATE)
// Set the baudrate
struct serial_struct ser_info;
if (ioctl(serial_port, TIOCGSERIAL, &ser_info) < 0)
{
printf("The baud rate of 1000000 is supported.\n");
perror("Error getting serial info");
close(serial_fd);
return 1;
}
else

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)
{
printf("The baud rate of 1000000 is not supported.\n");
printf("Error setting baudrate attributes\n");
printf("Error code: %d\n", errno);
close(serial_port);
LUOS_ASSERT(0);
}
#endif
#endif
Expand Down

0 comments on commit 011ee19

Please sign in to comment.