-->
Page 1 of 1

How to send packets every 10ms per TCP

PostPosted: Tue Sep 07, 2021 2:04 pm
by Banditoka
Hi,

i have written a Code which sends Sensordata to Matlab and saves it there for plotting etc. .

My Problem is i want a sending rate of at least 10ms but the fastest transmission rate i can reach is 60-70ms per Packet. I already disabled Nagle but nothing changed.

I post the relevant parts:

Code: Select allvoid loop()
{

  client = server.available();

  //Check if client is available

  if (client)
  {

    Serial.println("Client vorhanden");

    // while client is connected
    while (client.connected())
    {
      startStopTransmission();

      if (transmission)
      {

        if (tenmsFlag)
        {
          readSensorData();

          double Values[] = {acc_x, acc_y, acc_z, eul_x, eul_y, eul_z};

          client.write((uint8_t *)Values, sizeof Values);

          client.flush();

          tenmsFlag = false;
        }
      }
    }
  }
}


It seems like there is a hardcoded delay in the library.

Thank you for your help.

Re: How to send packets every 10ms per TCP

PostPosted: Thu Sep 23, 2021 12:15 pm
by prgvitor
Banditoka wrote:Hi,

i have written a Code which sends Sensordata to Matlab and saves it there for plotting etc. .

My Problem is i want a sending rate of at least 10ms but the fastest transmission rate i can reach is 60-70ms per Packet. I already disabled Nagle but nothing changed.

I post the relevant parts:

Code: Select allvoid loop()
{

  client = server.available();

  //Check if client is available

  if (client)
  {

    Serial.println("Client vorhanden");

    // while client is connected
    while (client.connected())
    {
      startStopTransmission();

      if (transmission)
      {

        if (tenmsFlag)
        {
          readSensorData();

          double Values[] = {acc_x, acc_y, acc_z, eul_x, eul_y, eul_z};

          client.write((uint8_t *)Values, sizeof Values);

          client.flush();

          tenmsFlag = false;
        }
      }
    }
  }
}


It seems like there is a hardcoded delay in the library.

Thank you for your help.



Hello,

There really could be a delay at the library. I advise you not to use the libraries provided. Send AT commands directly over the USART, you're not tied to any library and I guarantee it's easy to use. Espressif has many documents explaining step by step. But note that the manufacturer itself specifies a value of 20ms between the command to send data via TCP/UDP. Even so, time has already diminished considerably.

Take a test. Send via serial "AT\r\n" or "AT\n\r", either will do. After sending the command read the data from the Usart and print them with "println". The word received must be "OK". Don't forget to set the BaudRate correctly with that of the module (factory default 115200). Once you are able to perform these steps, search Google for "Esp8266 example at commands", in it you will find how to establish a UDP/TCP connection. It's simple and there are a maximum of 5 commands to establish the connection.

Ty

Thanks.

Re: How to send packets every 10ms per TCP

PostPosted: Fri Sep 24, 2021 3:33 am
by QuickFix
prgvitor wrote:I advise you not to use the libraries provided. Send AT commands directly over the USART, you're not tied to any library and I guarantee it's easy to use.

That's a bald statement.
Perhaps you can give us an actual example of the advantages of the default AT firmware over firmware written for a specific task.

Re: How to send packets every 10ms per TCP

PostPosted: Mon Sep 27, 2021 7:03 am
by prgvitor
QuickFix wrote:
prgvitor wrote:I advise you not to use the libraries provided. Send AT commands directly over the USART, you're not tied to any library and I guarantee it's easy to use.

That's a bald statement.
Perhaps you can give us an actual example of the advantages of the default AT firmware over firmware written for a specific task.


I think AT firmware might be valid for some cases. For quick module setups and simple tasks. Suppose you don't use Arduino, you don't find library compatible with the module, it would be a valid option to use AT commands via USART. You can create your own library based on AT firmware. It would be simpler as there is all documentation and examples of use. For quick and practical use I think it's valid. That's my opinion. Feel free to provide a solution. I think the purpose of the forum is to look for solutions to problems, not contest answers without any solution to the topic. I'm on hold, so I can learn too. Thanks.