How can we know from Linino that sketch is running ( or arduino is running )

Hi,

May be this is trivial question.

From Linino, how can we tell Arduino/mcu/sketch is running.

Is there a standard pins that I can tap into.

Please any help is highly appreciated. Thanks

Regards
BRE

Use gcc constants "FILE", "DATE", "TIME".

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600); 
 while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo as well as Yun only
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.print("\nArduino is running Sketch: ");
  Serial.println(__FILE__);
  Serial.print("Compiled on: ");
  Serial.print(__DATE__);
  Serial.print(" at ");
  Serial.print(__TIME__);
  Serial.print("\n");
  delay(5000); 

}

Output:

Arduino is running Sketch: SketchName.ino
Compiled on: Feb 23 2014 at 02:32:34

Use Bridge send them to linino.

Dear Sonnyyu,

Thank you very much for the reply,

As advised, We can get this information from the sketch.

But, Is there a way to get this information from C /Python/c++ code running in Linino without going into sketch.

Thank you very much for any pointers.

Sincere Regards,

BRE

Nothing as I know of.

Dear Sonnyyy and NoblePepper,

Pin 13 is the status led light. Is there a way to access the status 0/1 of pin 13 from C/C++/python
code in Linino.

Using GPIOs

Not sure how to do that.

Any thoughts.

Process p;		
  p.begin("sendsketchname.py");	
  p.addParameter(String(__FILE__));

or

Bridge.put("sketchname", String(__FILE__));

Genius

Sonnyyu,

Thank you so much for the reply.
I am not sure, I understand this fully.

Can you give me two word description or simple python snippet that I can run from linino,

I am truly grateful.

BRE

Process p;		
  p.begin("/mnt/sda1/sendsketchname.py");	
  p.addParameter(String(__FILE__));
nano /mnt/sda1/sendsketchname.py

#!/usr/bin/python
import sys
sketchname=sys.argv[1]
print sketchname

chmod 755  /mnt/sda1/sendsketchname.py
Bridge.put("sketchname", String(__FILE__));
#!/usr/bin/python
import time
import sys  
sys.path.insert(0, '/usr/lib/python2.7/bridge/')                                                 
from bridgeclient import BridgeClient as bridgeclient                                                    
value = bridgeclient()                                                                                 
while True:
	sketchname = value.get("sketchname")
	print sketchname
	time.sleep(1)

BREL:
I am not sure, I understand this fully.
Can you give me two word description or simple python snippet that I can run from linino,

FILE macro is expanded at compile time with the name of the compiled sketch. With

Bridge.put("sketchname", String(__FILE__));

your sketch is publishing its name to Bridge storage, so you can call a url like /data/get/sketchname and know which sketch is running on that particular yun

Sonnyyu & Federico,

Please pardon my Ignorance in understanding the code snippet here getting Sketch name details from Linino.

Process p;		
  p.begin("/mnt/sda1/sendsketchname.py");	
  p.addParameter(String(__FILE__));

Process object ( c or C++) runs the Python Script /mnt/sda1/sendsketchname.py and gets the information about the sketch Right ?
Is this information cannot be accessed by only python script ? without C/C++ code

Regarding the second code snippet.
I am not sure I understand the combination of

Bridge.put("sketchname", String(__FILE__));

and

#!/usr/bin/python
import time
import sys  
sys.path.insert(0, '/usr/lib/python2.7/bridge/')                                                 
from bridgeclient import BridgeClient as bridgeclient                                                    
value = bridgeclient()                                                                                 
while True:
	sketchname = value.get("sketchname")
	print sketchname
	time.sleep(1)

After I run this, I get this
Traceback (most recent call last):
File "Sketch.py", line 15, in
sketchname = value.get("sketchname")
File "/usr/lib/python2.7/bridge/bridgeclient.py", line 53, in get
json = TCPJSONClient('127.0.0.1', 5700)
File "/usr/lib/python2.7/bridge/tcp.py", line 65, in init
TCPClient.init(self, address, port)
File "/usr/lib/python2.7/bridge/tcp.py", line 38, in init
client.connect((address, port))
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 146] Connection refused

Sorry, if this sounds too obvious and pardon my ignorance here.
Thank you very much

High regards

BRE

BREL:
Sonnyyu & Federico,

Please pardon my Ignorance in understanding the code snippet here getting Sketch name details from Linino.

Process p;		

p.begin("/mnt/sda1/sendsketchname.py");
 p.addParameter(String(FILE));




Process object ( c or C++) runs the Python Script /mnt/sda1/sendsketchname.py and gets the information about the sketch Right ? 
Is this information cannot be accessed by only python script ? without C/C++ code

If with "C/C++ code" you are referring to the sketch running on your Yun's Arduino part, then the answer is no. The above code snippet, which needs to be part of whatever sketch you are running on your Yun, passes the expanded sketch name (through the FILE macro) to the Python script which expects the filename of the sketch as an argument via argv. This is also only an example/code snippet of what you need to include into whatever script you are running on the Linino side that you want to know if the/a sketch is running.
Again, both parts are only (working) snippets to demonstrate the technique with which you can achieve your goal. You seem to take those code samples too literal...

Regarding the second code snippet.
I am not sure I understand the combination of

Bridge.put("sketchname", String(__FILE__));

and

#!/usr/bin/python

import time
import sys  
sys.path.insert(0, '/usr/lib/python2.7/bridge/')                                                
from bridgeclient import BridgeClient as bridgeclient                                                    
value = bridgeclient()                                                                                
while True:
sketchname = value.get("sketchname")
print sketchname
time.sleep(1)




Sorry, if this sounds too obvious and pardon my ignorance here.

Again, those are just (standalone) working snippets of code demonstrating the technique to be used to achieve your goal.

It's the basic principle, just instead of passing the sketch name (as expanded by the compiler through the FILE macro) and pass it is this case through the bridge to a concurrently running Python script.

Ralf