mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-18 19:21:54 +00:00
btstack_uart_posix: add write really
This commit is contained in:
parent
6f3b19bc84
commit
abd4d2eb21
@ -48,7 +48,7 @@
|
||||
|
||||
#include <termios.h> /* POSIX terminal control definitions */
|
||||
#include <fcntl.h> /* File control definitions */
|
||||
// #include <unistd.h> /* UNIX standard function definitions */
|
||||
#include <unistd.h> /* UNIX standard function definitions */
|
||||
// #include <stdio.h>
|
||||
// #include <string.h>
|
||||
|
||||
@ -180,4 +180,20 @@ int btstack_uart_posix_set_parity(int fd, int parity){
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Generic helper
|
||||
void btstack_uart_posix_write(int fd, const uint8_t * data, int size){
|
||||
// log_info("btstack_uart_posix_write (%u bytes)", size);
|
||||
// log_info_hexdump(data, size);
|
||||
while (size > 0) {
|
||||
int bytes_written = write(fd, data, size);
|
||||
if (bytes_written < 0) {
|
||||
usleep(5000);
|
||||
continue;
|
||||
}
|
||||
data += bytes_written;
|
||||
size -= bytes_written;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,4 +73,12 @@ int btstack_uart_posix_set_baudrate(int fd, uint32_t baudrate);
|
||||
*/
|
||||
int btstack_uart_posix_set_parity(int fd, int parity);
|
||||
|
||||
/**
|
||||
* @brief Blocking write
|
||||
* @param fd
|
||||
* @param data
|
||||
* @param size
|
||||
*/
|
||||
void btstack_uart_posix_write(int fd, const uint8_t * data, int size);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user