From b2d682bf51b2bba97f0abc321aecb7be076f3a85 Mon Sep 17 00:00:00 2001 From: Jakub Date: Mon, 13 Jun 2022 14:18:29 +0200 Subject: [PATCH] tools/hci_throughput: fix supported octets info --- tools/hci_throughput/hci.py | 2 ++ tools/hci_throughput/hci_commands.py | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/hci_throughput/hci.py b/tools/hci_throughput/hci.py index 072e395e8..69b363745 100644 --- a/tools/hci_throughput/hci.py +++ b/tools/hci_throughput/hci.py @@ -31,6 +31,8 @@ HCI_COMMAND_PACKET = 0x01 HCI_ACL_DATA_PACKET = 0x02 HCI_EVENT_PACKET = 0x04 +L2CAP_HDR_BYTES = 4 + HCI_EV_CODE_DISCONN_CMP = 0x05 HCI_EV_CODE_CMD_CMP = 0x0e HCI_EV_CODE_CMD_STATUS = 0x0f diff --git a/tools/hci_throughput/hci_commands.py b/tools/hci_throughput/hci_commands.py index 2978ab852..286f45060 100644 --- a/tools/hci_throughput/hci_commands.py +++ b/tools/hci_throughput/hci_commands.py @@ -422,10 +422,11 @@ class HCI_Commands(): hci.max_data_len.set(*struct.unpack(" hci.max_data_len.supported_max_tx_octets - 4): - logging.critical(f"Number of bytes to send: {hci.num_of_bytes_to_send}\ - not supported. Closing.") - raise SystemExit("Number of bytes to send not supported. Closing.") + if (hci.num_of_bytes_to_send > hci.max_data_len.supported_max_tx_octets - hci.L2CAP_HDR_BYTES): + logging.critical(f"Number of data bytes to send + 4 bytes of L2CAP header: {hci.num_of_bytes_to_send + 4} " + f"exceeds allowed value of: {hci.max_data_len.supported_max_tx_octets}. Closing.") + raise SystemExit(f"Number of data bytes to send + 4 bytes of L2CAP header: {hci.num_of_bytes_to_send + 4} " + f"exceeds allowed value of: {hci.max_data_len.supported_max_tx_octets}. Closing.") return status() elif ocf == hci.OCF_LE_READ_PHY: