Tian stops working after some hours

Hi all,

I'm having a very strange problem. I have a Tian that is programmed to send out sensor data to a server
every x seconds.
My program run well but after 14,15 hours of operation it stops working and I don't receive datas. The program is fast at the beginning, then after 2 to 3 hours before stopping, it becomes more and more slow with the message "timeout".

I think maybe a misuse of the Ciao library on my part could be at the root of the problem. Or maybe a modification at the program level could correct the problem. So if I can have some help about this..
(the problem doesn't come from the use of String, I have already tested use of array with cstrings and it doesn't work).

Here is the part of the program that I think is problematic (there is another CiaoReadWrite nearly similar to the first) :

void CiaoReadWrite1()
{
    CiaoData data = Ciao.read("restserver");
    if (!data.isEmpty()) 
    {
      String id = data.get(0);
      String sender = data.get(1);
      String message = data.get(2);
       
      splitString(message,"=",LtT2,9);
        
      gen            =LtT2[0].toInt(); LtT2[0]="";
      belt           =LtT2[1].toInt(); LtT2[1]="";
      genReady       =LtT2[2].toInt(); LtT2[2]="";
      hvOnOff        =LtT2[3].toInt(); LtT2[3]="";
      beep           =LtT2[4].toInt(); LtT2[4]="";
      heart1         =LtT2[5].toInt(); LtT2[5]="";
      sendConf       =LtT2[6].toInt(); LtT2[6]="";
      heart2FB       =LtT2[7].toInt(); LtT2[7]="";
      
      beepFB         =beep;
      heart1FB       =heart1;
      sendConfFB     =sendConf;
       
      Ciao.writeResponse("restserver",id, String(baroAlti*100)+"="+baroHumi*10+"="+baroPres+"="+baroTemp*10+"="+beepFB+"="+heart1FB+"="+heart2+"="+sendConfFB+"="+
                                          secCust1+"="+secCust2+"="+secEmrgSW+"="+secloop+"="+secLoop1+"="+secLoop2+"="+gndSwGnd+"="+gndSwUGnd+"="+statusA1+"="+
                                          statusA2+"="+statusA3+"="+beltStat1+"="+beltStat2+"="+beltStat3+"="+beltStat4+"="+request+"=");
      request++;
    }
}

Thanks

I know nothing about the Tian but it is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. Just use cstrings - char arrays terminated with 0.

Your symptoms could be caused by memory becoming corrupted after a large number of String operations.

...R

Robin2:
I know nothing about the Tian but it is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. Just use cstrings - char arrays terminated with 0.

Your symptoms could be caused by memory becoming corrupted after a large number of String operations.

...R

Thank you, but can I have at least one example for its use?

Your code snippet is not independent enough from the rest of your code to analyse it but, if you suspect that particular piece is the problem, then what you can do is modify your code so to see if the problem changes or goes away:

void CiaoReadWrite1()
{
if (!data.isEmpty())
{

// dummy is a globally defined Sting which has a plausible set of values so the remainder of your
// code still works.
Ciao.writeResponse("restserver",id, dummy );
request++;
}
}

I guess you are using an ESP8266 based Arduino Uno WiFi Edit: see post #9.
Since the Ciao.writeResponse() method uses Strings, you are stuck with these. If, however, these are the problem, you could possibly restructure your code to make less intensive use of them.

Newuserfr:
Thank you, but can I have at least one example for its use?

Have a look at the examples in Serial Input Basics. They are probably not directly relevant to your project but they do use cstrings.

...R

6v6gt:
Your code snippet is not independent enough from the rest of your code to analyse it but, if you suspect that particular piece is the problem, then what you can do is modify your code so to see if the problem changes or goes away:

void CiaoReadWrite1()
{
if (!data.isEmpty())
{

// dummy is a globally defined Sting which has a plausible set of values so the remainder of your
// code still works.
Ciao.writeResponse("restserver",id, dummy );
request++;
}
}

I guess you are using an ESP8266 based Arduino Uno WiFi. Since the Ciao.writeResponse() method uses Strings, you are stuck with these. If, however, these are the problem, you could possibly restructure your code to make less intensive use of them.

Ok, thank you, I will take it (I will launch it and see tomorrow morning if it run or stop).

I made several commands on the Linux terminal on Arduino OS to try to see what is happening and I deduce that : Probably the process is consuming more virtual memory than there is available RAM, so is swapping...

I put as attachment the screen of the result at the linux board after it stop running

Please display your image in your post so we can see it without downloading it. See this Simple Image Guide

...R

Robin2:
Please display your image in your post so we can see it without downloading it. See this Simple Image Guide

...R

At the begin of the run :

Just after it stop :

I use Linux all the time but I haven't a clue what the data in your pictures tells us. In any case I presume you asked a question here because the problem is in your Arduino program rather than in Linux.

Can you put some code in your program that prints messages at regular intervals from different parts of the program. Then when the program crashes you may get some idea where the cause of the problem lies. However if the problem is due to memory corruption due to the use of the String class I would expect the problem to occur in a somewhat random fashion.

...R

I've just looked up the Arduino Tian. Like most of these exotic Arduino boards, they are already retired before I hear about then.
It is a dual processor board with an Atmel SAMD21 MCU (32 bit Arm Cortex M0+) processor and a Qualcomm Atheros MIPS processor. A Linux variant called Linino runs on the Atherios. It also has WiFi.
Ciao is a connectivity architecture, and in this case, the CIAO core is running on the Linux (Linino). The sketch itself, which uses CIAO services, runs on the SAMD21.

Anyway, back the the OP's problem. I guess the first thing is to try to narrow down where it is failing, in the CIAO core on the Linino Atheros or in the sketch which is running on the SAMD21.

The Linino screen shot taken just after a failure does appear to indicate that the CIAO core has run out of memory (maybe a memory leak). I'd guess now that any use of the String class in the sketch which runs on the SAMD21 would have no impact on the Linino side.

I've never experimented with these dual processor boards, Yun Tian, Uno-Wifi etc. so I can't really offer much more advice.

I have a Yun hiding, unused, in the bottom of a drawer somwhere. I had not realized a Tian also had a Linux side.

The Yun was a good idea ruined by the way it was implemented. Making an even more complex version was probably stretching the Arduino folks too far :slight_smile:

I still have no idea what the OP's Linux messages mean but the fact that they might be relevant just makes the debugging even more complex.

...R

Do you believe that the solution would be to periodically empty datas (on Linux)?

Newuserfr:
Do you believe that the solution would be to periodically empty datas (on Linux)?

I have no idea. And I don't have the hardware to do any testing.

...R

How can we contact the develoopers of the ciao.py, since I tried to send already a mail to Giuseppe, Andrea and Sergio, who are mentionned in the ciao.py. the problem is, that all the communication and all, what we would like to do is working fine, except, that after a sporadic time the communication to the PC trough the restserver quits the service. I have been investigation this now over 2 weeks. At first I thouhgt, it might be a problem on the programmation side of the Atmel, but several testings did not show a clear pattern for the fault. Than I checked deeper and analized the linux-side and I did find out, that the ciao and restserver increase the memory demand over the time and when the memory is "full" and the linux begins to swap, the communication to the PC slows down immediatley and drastically and after a few requests from the PC the Tian would quit the service and hang up. So I did make several testings over there as well and the pattern with differen programs is alwas the same. Once the linux begins to swap, the Tian quits service. So there must be some maybe "bad" code int he ciao.py and restserver.py, which does not take in account to clear the memory.... The Tian is such a nice thing and with the ciao and restserver so many things could be done, but if the memory is not cleaned and the Tian is at one moment running out of memory and quits the service, it is just not usable, since everyone would like to have a stable running machine or service. So, this is a bit over my knowledge, to change all the pyton programs and I would need some help form the Arduino developpers to fix this. I am sure, there are other people, who have the same problem and also on the forum here, I did find people with similar problems. However, nobody seems to me to have analized the problem in the deph I did and I did think at first as well, it might be a problem of the Atmel-programming side. I was not thinking, it could be on the linux side. However, today, I am almost certain, that it is on the linux ciao.py and restserver.py. Please all, help!

Is this you ?

If not, maybe an answer appears there which you can use.

The customer comments at the bottom of the linked page are rather uninspiring:

I have a problem that I encounter with my arduino program and the use of OpenWRT linino. I can't really find a solution for several days. (I use Arduino TIAN) I have already sent emails to arduino support and posted questions about it on the forum but it was never convincing.

Indeed, my program works well but after 14,15 hours of operation it stops working and I don't receive datas. The program is fast at the beginning, then after 2 to 3 hours before stopping, it becomes more and more slow with the message "timeout" (on Laview). All the communication and all, what we would like to do is working fine, except, that after a sporadic time the communication to the PC trough the restserver quits the service.

At first I thouhgt, it might be a problem on the programmation side of the Atmel, but several testings did not show a clear pattern for the fault. Than I checked deeper and analized the linux based linino-side and I did find out, that probably the process is consuming more virtual memory than there is available RAM, so is swapping… And stop... The ciao and restserver increase the memory demand over the time and when the memory is "full" and the linux begins to swap, the communication to the PC slows down immediatley and drastically and after a few requests from the PC the Tian would quit the service and hang up. So there must be some maybe "bad" code in the ciao.py and restserver.py, which does not take in account to clear the memory...,? Or a bad configuration of this ?

So I think maybe a modification at the program level could correct the problem or maybe several commands on the linino side ?

I put here the linux commands that allowed me to deduce this (I highlighted them to make it more visible)

At the begin of the run :

Just after it stop :

And here is the part of the program who communicate intuitively with the Linux (there is another CiaoReadWrite nearly similar to the first on my program called CiaoReadWrite2) :

void CiaoReadWrite1()
{
    CiaoData data = Ciao.read("restserver");
    if (!data.isEmpty())
    {
      String id = data.get(0);
      String sender = data.get(1);
      String message = data.get(2);
       
      splitString(message,"=",LtT2,9);
       
      gen            =LtT2[0].toInt(); LtT2[0]="";
      belt           =LtT2[1].toInt(); LtT2[1]="";
      genReady       =LtT2[2].toInt(); LtT2[2]="";
      hvOnOff        =LtT2[3].toInt(); LtT2[3]="";
      beep           =LtT2[4].toInt(); LtT2[4]="";
      heart1         =LtT2[5].toInt(); LtT2[5]="";
      sendConf       =LtT2[6].toInt(); LtT2[6]="";
      heart2FB       =LtT2[7].toInt(); LtT2[7]="";
     
      beepFB         =beep;
      heart1FB       =heart1;
      sendConfFB     =sendConf;
       
      Ciao.writeResponse("restserver",id, String(baroAlti*100)+"="+baroHumi*10+"="+baroPres+"="+baroTemp*10+"="+beepFB+"="+heart1FB+"="+heart2+"="+sendConfFB+"="+
                                          secCust1+"="+secCust2+"="+secEmrgSW+"="+secloop+"="+secLoop1+"="+secLoop2+"="+gndSwGnd+"="+gndSwUGnd+"="+statusA1+"="+
                                          statusA2+"="+statusA3+"="+beltStat1+"="+beltStat2+"="+beltStat3+"="+beltStat4+"="+request+"=");
      request++;
    }
}

It would good if I could have some help or documentation that can help me to advance

Please don't double post. This is the exact same problem as in your other Thread. I will suggest to the Moderator to merge them so we have all the info in one place.

...R