Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Limit TcpSocket bit rate?



  • I have a microcontroller with a wifi chip communicating over 112500 baud serial. I am developing a desktop application to talk to this microcontroller. Unfortunately, TcpSocket is sending raw characters to it faster than serial works, causing 1/3rd of characters to be lost. I would like to limit the rate at which bits are sent. Is there any way to do this?


  • Lifetime Qt Champion

    @StevenD By just sending the chars in small chunks with idle times in between.

    I'm nevertheless surprised. Where exactly get the chars lost?

    Have you monitored the TCP connection with Wireshark and the serial connection (e.g. with logic analyzer)?

    Which Chip is that exactly? And how is your protocoll (the commands you send to MC).

    Regards



  • Yeah, this kind of bothers my sensibilities.

    Has the OP implemented a real TCP/IP stack on the uC?
    Is the transmission of TCP/IP over the serial link being properly wrapped in a PPP wrapper?...and really, how is a TCP socket talking over a serial connection in the first place?


  • Lifetime Qt Champion

    @Kent-Dorfman I guess the OP is running a Wifi-Serial bridge like this one, where the whole network logic is inside this chip. The microcontroller only sees serial.


  • Moderators

    @aha_1980 jep, pretty much like I run a serial connection via BlueTooth LowEnergy



  • @StevenD you may want to look at rate controller from Qt Torrent client example could help you somehow



  • yeah, we're still kind of speculating unless the OP posts real information about the configuration. TCP is meant to be transported over packetized networks. Serial is character stream oriented. Without something to packetize and manage the serial stream they are not gonna be "compatible"...whether that management occurs in PPP, or as part of the bluetooth stack, or in a hardware protocol converter, or whatever...



  • What @aha1980 posted about my setup is correct.

    I had found the Qt Torrent client example but that limits download speed, whereas I want to limit upload.

    I can send in small chunks, but that would be a lot of work wasted if there's a more elegant solution.


  • Lifetime Qt Champion

    @StevenD then please answer my other questions above.

    You need some handshake protocol between PC an MC, and all will work stable.



  • @aha_1980 said in Limit TcpSocket bit rate?:

    I'm nevertheless surprised. Where exactly get the chars lost?

    In the wifi chip

    Have you monitored the TCP connection with Wireshark and the serial connection (e.g. with logic analyzer)?

    I have monitored the TCP connection with Wireshark, the characters are being sent just fine. I cannot access the serial connection easily as it's part of a custom PCB. I also don't have easy access to a logic analyzer, and wouldn't exactly know how to use one anyway.

    Which Chip is that exactly? And how is your protocol (the commands you send to MC).

    I'm not sure which chip it is exactly, but I may be able to find out. I haven't developed a protocol yet, I'm literally just writing 0123456789 to it and observing which numbers don't make it.


Log in to reply