YUN bridge

Hello all,
i have an urgent problem - hopefully it isn’t a very big problem for this community, but it is still for me.

My intention was to pass a string value from the Linux-side to my sketch. But even with a simple sketch and a basic python skript it seems to fail:
my Sketch:


#include <Bridge.h>
#define BTN_1 8

char speech[128];

void setup() {
pinMode(BTN_1, INPUT);
digitalWrite(BTN_1, HIGH);

Bridge.begin();
Mailbox.begin();
}

void loop() {
if (digitalRead(BTN_1) == LOW) {
delay(750);
if (digitalRead(BTN_1) == LOW) {
p.runShellCommand("/mnt/sda1/python-packages/testi.py");
int test = Bridge.get(“test”,speech,128);
Serial.println(test);
p.close();
}
}


the put-part of the python-Script testi.py:



sys.path.insert(0, “/usr/lib/python2.7/bridge/”)
from bridgeclient import BridgeClient

client = BridgeClient()
speech = “Hello World”
client.put(“test”,speech)

Every time I call the script through a button-press this value should be passed to the sketch.
But i get every time the value 0 (zero) so no data was passed on.

Could you help me with this?
Thanks in advance

@m3vision,
the thread next to yours, is doing something similar. You might want to follow along.

Jesse

Custom tone through telnet

Using a web browser, load the URL http://arduino.local/data/get, and see what is returned. Of course, substitute your Yun's name or address for arduino.local as necessary.

Whether the returned data includes the test key, and if there, the value of the key, will let us know if the problem is on the getting or setting side.

Also, are you sure the script is actually run? Have you given the file executable permissions, and does it include the appropriate shebang on the first line? Can you SSH into your Yun and run /mnt/sda1/python-packages/testi.py on the command line, and does it run or give an error? If it runs, does accessing the data/get URL above now show the proper data?

I think I got your error.
Use

p.runShellCommand("python /mnt/whatever.. .py");

Instead of

p.runShellCommand("/mnt/whatever.. .py");

At first thank you for your replies! :slight_smile:

ShapeShiffter: if i try to connect through web i get the following error message:
"Could not connect to YunServer 146 Connection refused"

  • Rest-API Access ist Open

mart256: The Python script is running well, only the passing of data back to the sketch doesn't work!

Hi All,

i resolved my issue!!

It was not a coding error - I'm glad about that :slight_smile:

Referring to post :

i have updated the cpu-mcu-bridge!!

opkg update
opkg upgrade cpu-mcu-bridge

Now all the code is working perfectly!!!

Good detective work, thanks for updating us.

I was going to suggest corrupt bridge software on the Linux side. That /data/get URL does not use the REST API, and does not interact with the sketch -- it is implemented strictly on the Linux side. If that wasn't working, it tells me that there is a problem with the Linux side of the Bridge. I'm glad you found it.