This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

pc-ble-driver-py - Maximum data rate

Hi,

Just been testing the data rate of write without response commands, I'm only getting about 250 bytes / second which seems incredibly slow?

I've just got a simple little loop sending 20 bytes (max mtu limitation for the v2 api)

timeBefore = time.perf_counter()
bytesSent = 0
for i in range(100):
    try:
        adapter.write_cmd(conn, bulkDataUuid, bytes(20))
        adapter.evt_sync[conn].wait(BLEEvtID.evt_tx_complete)
        bytesSent += 20
    except NordicSemiException as error:
        print(str(i) + " failed")
        print(error)
print("sending %d bytes took %f seconds, %f b/s" % (bytesSent, time.perf_counter() - timeBefore, bytesSent / (time.perf_counter() - timeBefore)))

I tried enabling the high bandwidth mode with this:

    def ble_high_bw(self):
        bwOption = driver.ble_opt_t()
        bwOption.common_opt.conn_bw.conn_bw.conn_bw_rx = driver.BLE_CONN_BW_HIGH
        bwOption.common_opt.conn_bw.conn_bw.conn_bw_tx = driver.BLE_CONN_BW_HIGH

        driver.sd_ble_opt_set(self.rpc_adapter, driver.BLE_COMMON_OPT_CONN_BW, bwOption)

but that didn't seem to change the speed at all, the baud rate of the serial link is at the default 1Mbaud.

Is this just the expected speed cap because of all the python and uart stuff going on under the hood or is there anything else I can do?

Many thanks,

Peter

Parents Reply Children
  • Hi, apologies for the slow response, I've changed the test to this:

        timeBefore = time.perf_counter()
        bytesSent = 0
        for i in range(100):
            try:
                adapter.write_cmd(conn, bulkDataUuid, bytes(20))
                bytesSent += 20
            except NordicSemiException as error:
                if error.error_code == BLE_ERROR_NO_TX_PACKETS:
                    adapter.evt_sync[conn].wait(BLEEvtID.evt_tx_complete)
                else:
                    print(str(i) + " failed" + error)
    
        print("sending %d bytes took %f seconds, %f b/s" % (bytesSent, time.perf_counter() - timeBefore, bytesSent / (time.perf_counter() - timeBefore)))

    Is this the sort of thing you meant? It is a little bit faster, about 300 bytes / second on average. 

    Edit: Just thought I'd add that I can't find a define for BLE_ERROR_NO_TX_PACKETS in the python BLE drivers at all so I just added BLE_ERROR_NO_TX_PACKETS = 12292 in my file.

  • There is a significant overhead using serialization, but only 300 bytes/ second is lower than what is expected. There are more reports about pc_ble_driver_py being slow, e.g in this post. We are looking into what is causing this.

Related