mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-02 16:20:31 +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->ds == NULL) return -1;
|
||||||
if (hci_transport_h4->uart_fd == 0) 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
|
// store packet type before actual data and increase size
|
||||||
char *data = (char*) packet;
|
char *data = (char*) packet;
|
||||||
size++;
|
size++;
|
||||||
@ -230,12 +232,19 @@ static int h4_send_packet(uint8_t packet_type, uint8_t * packet, int size){
|
|||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
int bytes_written = write(hci_transport_h4->uart_fd, data, size);
|
int bytes_written = write(hci_transport_h4->uart_fd, data, size);
|
||||||
if (bytes_written < 0) {
|
if (bytes_written < 0) {
|
||||||
|
log_info("usleep(5000)");
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
data += bytes_written;
|
data += bytes_written;
|
||||||
size -= 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,6 +315,8 @@ static int h4_process(struct data_source *ds) {
|
|||||||
|
|
||||||
int read_now = bytes_to_read;
|
int read_now = bytes_to_read;
|
||||||
|
|
||||||
|
uint32_t start = run_loop_get_time_ms();
|
||||||
|
|
||||||
// read up to bytes_to_read data in
|
// read up to bytes_to_read data in
|
||||||
ssize_t bytes_read = read(hci_transport_h4->uart_fd, &hci_packet[read_pos], read_now);
|
ssize_t bytes_read = read(hci_transport_h4->uart_fd, &hci_packet[read_pos], read_now);
|
||||||
// log_info("h4_process: bytes read %u", bytes_read);
|
// log_info("h4_process: bytes read %u", bytes_read);
|
||||||
@ -313,6 +324,11 @@ static int h4_process(struct data_source *ds) {
|
|||||||
return bytes_read;
|
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;
|
bytes_to_read -= bytes_read;
|
||||||
read_pos += bytes_read;
|
read_pos += bytes_read;
|
||||||
if (bytes_to_read > 0) {
|
if (bytes_to_read > 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user