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: