btstack_uart_posix: add write really

This commit is contained in:
Matthias Ringwald 2016-04-14 12:11:44 +02:00
parent 6f3b19bc84
commit abd4d2eb21
2 changed files with 26 additions and 2 deletions

View File

@ -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;
}
}

View File

@ -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