mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-24 22:43:35 +00:00
log warning if posix h4 read/write takes longer than 10 ms
This commit is contained in:
parent
5b9b590f58
commit
838e7f1bb2
@ -222,6 +222,8 @@ static int h4_send_packet(uint8_t packet_type, uint8_t * packet, int size){
|
||||
if (hci_transport_h4->ds == NULL) return -1;
|
||||
if (hci_transport_h4->uart_fd == 0) return -1;
|
||||
|
||||
uint32_t start = run_loop_get_time_ms();
|
||||
|
||||
// store packet type before actual data and increase size
|
||||
char *data = (char*) packet;
|
||||
size++;
|
||||
@ -230,12 +232,19 @@ static int h4_send_packet(uint8_t packet_type, uint8_t * packet, int size){
|
||||
while (size > 0) {
|
||||
int bytes_written = write(hci_transport_h4->uart_fd, data, size);
|
||||
if (bytes_written < 0) {
|
||||
log_info("usleep(5000)");
|
||||
usleep(5000);
|
||||
continue;
|
||||
}
|
||||
data += bytes_written;
|
||||
size -= bytes_written;
|
||||
}
|
||||
|
||||
uint32_t end = run_loop_get_time_ms();
|
||||
if (end - start > 10){
|
||||
log_info("h4_send_packet: write took %u ms", end - start);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -305,6 +314,8 @@ static int h4_process(struct data_source *ds) {
|
||||
if (hci_transport_h4->uart_fd == 0) return -1;
|
||||
|
||||
int read_now = bytes_to_read;
|
||||
|
||||
uint32_t start = run_loop_get_time_ms();
|
||||
|
||||
// read up to bytes_to_read data in
|
||||
ssize_t bytes_read = read(hci_transport_h4->uart_fd, &hci_packet[read_pos], read_now);
|
||||
@ -312,6 +323,11 @@ static int h4_process(struct data_source *ds) {
|
||||
if (bytes_read < 0) {
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
uint32_t end = run_loop_get_time_ms();
|
||||
if (end - start > 10){
|
||||
log_info("h4_process: read took %u ms", end - start);
|
||||
}
|
||||
|
||||
bytes_to_read -= bytes_read;
|
||||
read_pos += bytes_read;
|
||||
|
Loading…
x
Reference in New Issue
Block a user