Sketch compiling get lost

Hey guys,

Sorry if I'm posting something noob, but I really read everything on the website and looked on the topics of the forums trying to find about this issue (also googled a lot).

The thing is, I got Yun working just fine and uploaded my sketch, created shell files without SD card and stuff. But when I turn the Yun off and on again (or just reset) the sketch code doesn't start again like on Uno or mini Pro (I have to upload it again), why is that? Do I need some configuration using a SD to keep the code or something?

Thanks.

It could be several things most likely related to the "virtual" serial port. Post the sketch giving trouble and what does or doesn't happen.

Thanks for the response, the code I made simply run a script in Linino to start a BLE service. The Sketch runs ok and the service starts when I upload the code. But when I restart, the code do not run again until I upload it back again.

This is the code:

#include <Process.h>

void setup() {
  Bridge.begin();   // Initialize the Bridge
  Serial.begin(9600);   // Initialize the Serial

  // Wait until a Serial Monitor is connected.
  while(!Serial);
  
   Process p;
  p.runShellCommand("/root/ble");

  // do nothing until the process finishes, so you get the whole output:
  while(p.running());  

  // Read command output. runShellCommand() should have passed "Signal: xx&":
  while (p.available()) {
    char c = p.read();
    Serial.print(c);
  } 
  delay(5000);
}

void loop() {
}

Thanks

luicaps:
The code I made simply run a script in Linino to start a BLE service.

BLE as in BluetoothLowEnergy??

What does the script /root/ble look like?

Hey wayoda, you're right :), it stands for BlueTooh Low Energy.

I just followed this tutorial (Turn your Arduino YUN into an iBeacon transmitter) to install the software needed, and the script only does the work of starting an iBeacon service. The code looks like this:

#!/bin/ash
hciconfig hci0 up
hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 D2 8C 3C 18 94 5A 49 B5 80 9F D5 C0 9B A0 95 E6 00 00 00 00 C9 00
hciconfig hci0 leadv
hciconfig hci0 noscan

That tutorial explains in a good way how to achieve everything just fine. Anyway, my problem is that I want Yun to start this service whenever it is turned on, but I also intend to use Temboo as a logging service for my beacons. The script works as well as the sketch, the only problem is that the sketch do not run again on restart.

The sketch is probably running, just stuck waiting on something that never happens.

Sprinkle some debugging statements in that will tell you where:

#include <Process.h>

void setup() {
  Bridge.begin();   // Initialize the Bridge
  Serial.begin(9600);   // Initialize the Serial

  // Wait until a Serial Monitor is connected.
  while(!Serial);
  
   Process p;
Serial.println("Starting script on Linino");
  p.runShellCommand("/root/ble");
Serial.println("Waiting on script to start");
  // do nothing until the process finishes, so you get the whole output:
  while(p.running());  
Serial.println("Script started");
  // Read command output. runShellCommand() should have passed "Signal: xx&":
  while (p.available()) {
    char c = p.read();
    Serial.print(c);
  } 
  delay(5000);
}

void loop() {
}

You may be stopping the linino boot process if the sketch sends data on the bridge before uboot gets done or your script may never complete if things aren't ready on the linino side. It is probably in the script expecting a service that isn't available yet.

It does make sense noblepepper. I was trying to log things on loop to find the problem and never thought the setup actually never finished. I'll try your code later when I get back home. Is there any way to make the sketch wait until Linino is ready?

It all depends on what you need. The call to bridge.begin should get you past uboot and such. The last service for ME is the wireless connection which takes 60-70 seconds. Bluetooth may take longer. If nothing else watch your boot process and then put in a delay long enough. Better would be to make the script return a "not ready" signal instead of running forever if it can't find what it needs.