Community
cancel
Showing results for 
Search instead for 
Did you mean: 
idata
Community Manager
1,755 Views

Arduino sketch stops running after 2 mins on Edison

hi eveyone, I am testing the following basic arduino sketch :

void setup() {

Serial1.begin(9600);

}

void loop() {

Serial1.print("1");

delay(1000);

}

this is correctly uploaded and starts regularly during boot; I can see the process running:

/sketch/sketch.elf /dev/ttygc0 /dev/ttygc0

and the data being sent out on UART1

BUT, the program stops after a couple of minutes, and I cannot figure out why..

your help is much appreciated

dan

20 Replies
idata
Community Manager
59 Views

Hi,

 

 

Is the process ended when the program stops responding? You can check the processes running with ps. What image version and IDE version are you using? I'm running the latest image 201606061707 and am using the Arduino IDE 1.6.11. I left the script running for about 15 minutes and the process was still running after that.

 

 

We'll be waiting for your response.

 

 

-Sergio

 

idata
Community Manager
59 Views

Hi Sergio, thanks for your reply.

the process ends after 2 mins, ps wont retrieve it anymore...

the sketch starts properly at startup, automatically... no issues... but it stops very soon.

The signal is correctly generated by the UART1 and monitored with a scope.

the image is : 3.10.98-poky-edison+ # 1 SMP PREEMPT Mon Jun 6 14:32:08 PDT 2016 i68

I have a session open over wifi to check the ps output, and the module is self powered with a 3.7 lithium battery. No usb cable is plugged

I have also noticed that if the usb cable is plugged to the otg port, the script runs continuously without stopping. So, it must be something related to being detached from the laptop, and being able to run wirelessly

what else can I check?

idata
Community Manager
59 Views

Hi Dan,

The OTG port can be used to supply power to the Edison. If an USB cable is connected to that port and the sketch runs continuously then it's possible that the board is not receiving enough power to maintain the sketch running. Can you try to power your board using an external power supply on J1 and see if this problem persists? The external power must be in the range of 7 to 17 V. Also, if possible, use another lithium-ion battery on J2. Make sure this battery is providing between 3.0 and 4.3V when connected.

We'll be waiting for your response.

-Sergio

 

idata
Community Manager
59 Views

Do you still need help with this thread? What were the results of following our previous suggestion?

 

 

-Sergio

 

idata
Community Manager
59 Views

Hi Sergio,

during my tests I used the sparkfun breakout boards. including the power module with the 3.7v lithium battery.

I have purchased another edison with the mini board and I got it just tdy.

Will wire the board to execute a test tmw, and update you by tmw.

take care, and thanks for your support

dan

idata
Community Manager
59 Views

Sergio

my update from today:

  • Edison running on a sparkfun running the usb/otg breakout. Both miniports connected with 2 usb cables to a 5V power source ( no laptop , no RTX lines connected)
  • ifconfig shows lo and wifi only
  • I connect to the module over putty with the wifi ipaddress
  • all starts fine all is good, the sketch autostarts at boot. the autostart has been setup according to this procedure https://software.intel.com/en-us/blogs/2015/08/01/procedure-to-autostart-the-arduino-sketch-on-ediso... Procedure to Autostart the Arduino Sketch on Edison | Intel® Software
  • after 3 mins the sketch stops.
  • using putty, i restart manually the /etc/init.d/automateSketch.sh and it seams to run without stopping

based on this, I would rule out any power issues... perhaps some conflict or issues with ttyGS0?

I haven't installed anything else on the board besides the OS image (3.10.98-poky-edison+) and the sketch

ciao

dan

idata
Community Manager
59 Views

Hi Dan,

 

 

Thank you for providing this description. As I understand from your last reply was that both the first board with the Arduino expansion board, as well as the new Edison module with the mini breakout board have the same behavior, is this correct? I've a couple of questions:

 

 

You mention that after manually restarting automateSketch.sh your script runs without stopping, does this happen with both modules?

 

 

Could you try the mini breakout board test using a different set of USB cables?

 

We'll be waiting for your response.

 

 

-Sergio

 

idata
Community Manager
59 Views

Ciao Sergio,

here my latest findings...

  • I moved the edison from the sparkfun stacked breakouts onto the Intel mini board.
  • No USB cables are connected the module connected over WiFi only
  • On J21 I connected a 12V DC power supply.
  • At start time I open an SSH with putty, and start monitoring with a ps command the processes running.
  • The arduino sketch starts at boot regularly, and stops after 3 mins...
  • After that I start from command line the /sketch/sketch.elf /dev/ttyGS0 /dev/ttyGS0 &
  • the sketch runs without issues forever...
  • the behavior is basically unchanged, so the first instance of the process created at boot stops for unknown reasons within 3 mins...

what would you advice?

br

dan

idata
Community Manager
59 Views

Hi Dan,

 

 

It's hard to say why your sketch stops. Again, I've tested the code provided above and left it running for around 20 minutes. Ps still shows the sketch.elf running as a process the whole time. I ran the code on both Arduino IDE 1.6.11 and 1.6.5. I used the latest image where the output of cat /etc/version is 201606061707. If you're using the mini breakout board then 12V applied to J21 is good. I've a few questions:We'll be waiting for your response.

 

-Sergio

 

idata
Community Manager
59 Views

Hi Sergio,

  • I can confirm that I have the same version as you do: 201606061707
  • the battery provides the proper voltage.

new findings

  • I have done a further test, I wrote a simple program in C uart.c and made it loop infinitely to output the "Hello Mraa!". same issues it stops.
  • then I decided to write under /etc/init.d the simplest script ever:

mytest.sh

-------------

# !/bin/sh

while :

do

date >> /home/root/mylog

sleep 10

done

-------------

and executed : update-rc.d mytest.sh defaults (***)

  • rebooted the edison ... and...
  • the mylog file STOPS being updated after 5min .... the process dies...

so, there must be something that stops processes being set to startup in the way I do with (***) ( https://software.intel.com/en-us/blogs/2015/08/01/procedure-to-autostart-the-arduino-sketch-on-ediso... Procedure to Autostart the Arduino Sketch on Edison | Intel® Software )

any suggestions?

br

dan

idata
Community Manager
59 Views

Sergio,

I managed to get the startup script running continuously at all times creating a service instead.

Hence the information reported at https://software.intel.com/en-us/blogs/2015/08/01/procedure-to-autostart-the-arduino-sketch-on-ediso... Procedure to Autostart the Arduino Sketch on Edison | Intel® Software is not a solution.

I am very happy now

ciao

dan

idata
Community Manager
59 Views

Hi Dan,

 

 

Thank your lettings us know you managed to resolve this issue. If you have any other issues with the Edison don't hesitate to open a new thread to get help from the community.

 

 

-Sergio

 

idata
Community Manager
59 Views

Hi damsan,

I'm having the same problem as you with my intel edison (cat /etc/version is 201606061707).

After x mins the sketch is stopped. I'm not sure if the problem is in the code. While I resolve this, I have made a scketch that write in a text file the result of the 'ps' command and then look if the sketch is started.

The problem is that this sketch will also stop after x mins.

Please, can you explain how creating a service instead? You had more problem reset with you solution?

Thanks in advance.

Javier.

idata
Community Manager
59 Views

Hi Javier,

 

 

You can find a very useful document to create services here /docs/DOC-111103 https://communities.intel.com/docs/DOC-111103 .

 

 

Let us know if this was helpful.

 

 

-Sergio

 

idata
Community Manager
59 Views

Hi Sergio. Thank you for the response. I will look at the documentation and will try to do an example.

Thank you

idata
Community Manager
59 Views

Keep us updated in your progress.

 

 

-Sergio

 

idata
Community Manager
59 Views

Hi Javier,

yes, indeed. By creating an entry in the init.d dir and with the commit through update-rc.d I was unable to solve the issue.

By creating a service as mentioned in /docs/DOC-111103 https://communities.intel.com/docs/DOC-111103 I was indeed able to permanently solve the unwanted shutdown of the script.

let me know if you need further help

Dan Sam

idata
Community Manager
59 Views

Hi Dan Sam. Thanks to all for the help. I explain what I've done so far:

1. I wrote a sketch called irrigationwatchdog.elf that the result of running the "ps" command is stored in a text file.

Then read (every 5 minutes) this file and find if it is running irrigationSketch.elf (program that controls the irrigation valves). If not, run irrigationSketch.

2. I made a small script (startsketch.sh) in my home/root directory on the intel edison I can use to start Arduino sketches, obtained from this link

3. I wrote under /etc/init.d the simplest script ever:

startIrrigationControl.sh

-------------

# !/bin/sh

./startsketch irrigationwatchdog.elf

-------------

and executed : update-rc.d startIrrigationControl.sh defaults

The problem is that sometimes, after a few minutes,all the sketch stop running. irrigationwatchdog.elf is stopped and irrigation valves are not controlled.

I want to move the code of irrigationwatchdog.elf to a service, but can not find information on the Internet how to do it.

That is, how to read a text file every 5 minutes, read its contents and look if a process is running.

Know any examples about managing files in service and how to do this last?. Thank you very much for the help.

Javier.

idata
Community Manager
59 Views

Hi javilez,

 

 

The first thing to do is having the startIrrigationControl.sh ready. You already have this part so you can move on, and create a service as explained here /docs/DOC-111103 https://communities.intel.com/docs/DOC-111103 . The service file has to be stored in /lib/systemd/system, but instead of having the node.js in the service you need to have your startIrrigationControl.sh. Run the chmod command as explained in the guide. Further customization can be done with the service with systemctl. You can see more information here: https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and... https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and... .

 

 

-Sergio

 

idata
Community Manager
32 Views

Hi Sergio. I will try to follow the steps you mention.

Thank you

Reply