mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-25 16:43:28 +00:00
platform/posix: exit on none existing uart device, terminate if uart is unplugged
This commit is contained in:
parent
683d7c6847
commit
7bab55ed9a
@ -145,11 +145,11 @@ static void btstack_uart_block_posix_process_read(btstack_data_source_t *ds) {
|
||||
}
|
||||
if (bytes_read == 0){
|
||||
log_error("read zero bytes\n");
|
||||
return;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (bytes_read < 0) {
|
||||
log_error("read returned error\n");
|
||||
return;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
btstack_uart_block_read_bytes_len -= bytes_read;
|
||||
@ -311,12 +311,12 @@ static int btstack_uart_posix_open(void){
|
||||
int fd = open(device_name, flags);
|
||||
if (fd == -1) {
|
||||
log_error("Unable to open port %s", device_name);
|
||||
return -1;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (tcgetattr(fd, &btstack_uart_block_termios) < 0) {
|
||||
log_error("Couldn't get term attributes");
|
||||
return -1;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
cfmakeraw(&btstack_uart_block_termios); // make raw
|
||||
|
||||
@ -339,7 +339,7 @@ static int btstack_uart_posix_open(void){
|
||||
|
||||
if(tcsetattr(fd, TCSANOW, &btstack_uart_block_termios) < 0) {
|
||||
log_error("Couldn't set term attributes");
|
||||
return -1;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// store fd in data source
|
||||
@ -347,7 +347,7 @@ static int btstack_uart_posix_open(void){
|
||||
|
||||
// also set baudrate
|
||||
if (btstack_uart_posix_set_baudrate(baudrate) < 0){
|
||||
return -1;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// set up data_source
|
||||
|
Loading…
x
Reference in New Issue
Block a user