5 years, 8 months ago.

TCPSocket call speed TOO LOW

Hi all,

I recently bought a DISCO-L475VG-IOT01A (STM32 micro) and wrote some simple socket program to send data over TCP, with the "TCPSocket" library.

I measured the time it took for calling the "socket.send()" function and the result was an average of 13 ms (which I personally think is A LOT and should result in microseconds).

Is there any other library I can rely on? Is there a way to speed up the function call? I really need to send data at a higher rate.

Thanks in advance!

Have you searched TCP Socket on Mbed, there are quite a few. However are you looking for Ethernet or Wi-Fi and OS2 or OS5, your board supports both. Which library are you using?

If it is Wi-Fi then there may be problems there, I had to re-write the ESP8266 Wi-Fi driver (for OS2) as the Mbed version was too slow particularly for Dynamic Web pages. It may be the same situation for the ST board.

posted by Paul Staron 04 Mar 2019

As I said, I'm using the TCPSocket library. The connection is over WiFi. I don't really care about OS2 or OS5, speed is all it matters for me now. Do you mind sharing the driver you wrote for the ESP? I might have to rewrite some code for the ST-DISCO as well :(

posted by Luis Cavanillas 04 Mar 2019

1 Answer

5 years, 8 months ago.

Luis, I have just checked the send speed that I'm getting using the ESP8266. The serial port speed to this is 115200. To send 48 bytes (NTP call) takes 4ms, that's using this simple function;

serial data to ESP8266

void ESP8266::sendMemArrayToEsp(const char*str, unsigned int len)
{
    while(len--)
        esp.putc(*str++);
}

Total function time is 6.6ms including the send command handshaking.

send function

bool ESP8266::send(int id, const void *data, uint32_t amount)
{
    t.reset();t.start();
    sprintf(ATcmd,"AT+CIPSEND=%d,%d", id, amount);        
    SendCMD(ATcmd);
    while(getESPreply()!=1);  // wait for OK response  
    while(getESPreply()!=5);  // wait for Ready To Send response
    //t.reset();t.start();
    sendMemArrayToEsp((char*)data,amount); 
    
    t.stop();
    debug_if(1, "AT<  Send Time %f Seconds\r\n",t.read());            
    return true;
}

Your board uses SPI connection to the Wi-Fi module so it could be faster.

https://os.mbed.com/teams/ST/code/DISCO_L475VG_IOT01A_wifi/file/c61a93635433/es_wifi_io.c/

Line 159 is indicating 10Mhz. Try changing this to SPI_BAUDRATEPRESCALER_5; that should give you 16Mhz.

HI again!

Thanks for your answer, however, it didn't solve my problem as I am already using the "ISM43362Interface" library (Driver for the ISM43362 wifi module). This library already uses 20MHz (Max speed for wifi) clk and is A LOT FASTER than the one you provided:

Average time with "es_wifi" libraries -> 140 ms. Average time with "ISM43362Interface" libraries -> 13 ms.

One magnitude faster! Is there any way you could help me modify the ISM43362Interface code for a faster call? I am really no that experienced in hardware programming (eg. SPI connections).

Thanks again!

posted by Luis Cavanillas 05 Mar 2019

Luis, I assume this is the driver that you are using, create a 'New Issue' here, these guys develop the driver so should be able to help.

https://github.com/ARMmbed/wifi-ism43362

posted by Paul Staron 06 Mar 2019