-->
Page 1 of 3

Trying to make a real time system

PostPosted: Tue Jun 20, 2017 11:13 am
by Oliver Buchmann
Hi community !

I trying to programm an real time system to control Model railroads.

The Problem is that with the non-Os sdk i am to slow with the sending data.
I send a testpaket like this "char testpaket[4] = {122,5,5,122};"

I try it with this code:

for(int i = 0 ; i < MAXSC ; i++)
{
int stamp = 0;

for(int j = 0 ; j < 200 ; j++)
{


testpaket[5] = 1 + j;
beforesend = millis();
/*
function send paket to the Station
*/
TKDClient[i].println(testpaket);
TKDClient[i].flush();
delay(10);
/*
time mesurement
*/
aftersend = millis() - beforesend;
testpaket[4] = millis() - beforesend;

stamp += aftersend;
Serial.println(stamp);

if(stamp > 1000)
{
Serial.println("bin raus");
int stamp = 0;
break;
}
The Result is i send 4 Packets in 1 second. This is very slow.
After this i read i shold take the freeRTOS.

Now my questions are:

How many packets can i send with this sdk in 1 second. Is there any docu our else i can read what is possible?

Hi community !
Thx for the answers gbafamily. :D

Okay now i can send 8 Pakets within a second. Great but the problem is i ned more, exactly i need 100. :shock:

now my questons are:

1. Is this posible to send 100 or more packets with 5 Byte within a second.
2. Is there any documentation who can I read what the maximal package rate is. (in real workspace)
3. Is it better to use a RTOS to send more packets in one second.

The for your attention !

Oliver

Re: Trying to make a real time system

PostPosted: Tue Jun 20, 2017 4:15 pm
by QuickFix
I've never really worked with the standard NONOS- or RTOS-SDK's, so I can't help you with that.

Have you tried better ESP8266 development platforms, like Arduino or Lua?
That way you have full and faster control over the chip.

Re: Trying to make a real time system

PostPosted: Tue Jun 20, 2017 6:57 pm
by gbafamily1
If you are using Arduino ESP8266, try calling setNoDelay(true) on each WiFiClient before reading or writing. For example, do it after WiFiClient is connected.

The code writes past the end of the testpaket array which is a major problem. testpaket has 4 elements but there are writes to testpaket[4] and testpaket[5].

To write to the client socket, use write instead of println.

//TKDClient[i].println(testpaket);
TKDClient[i].write(testpaket, sizeof(testpaket));

Remove the delay(10). I do not see a need for it and it slows down the loop. The flush is also probably not needed once NoDelay is set true.

If using ESP8266 Arduino 2.3.0, try the git version which has fixes and improvements.

Re: Trying to make a real time system

PostPosted: Tue Jun 20, 2017 7:02 pm
by rudy
I don't know if this is your problem but it is worth a look. I know that it can be disabled allowing for faster sends.

http://searchnetworking.techtarget.com/ ... -algorithm