Arduino Yun and Bridge Python

Hello,

I'm working on a project that purpose is to catch data from the Yun by WiFi. Atm I'm trying a Python script made by Leland Sindt (http://forum.arduino.cc/index.php?topic=188998.msg1398228#msg1398228). Problem is when I start my scrypt I've got this error: [Errno 10061] No connection could be made because the target machine actively refused it. My computer is connected to the Yun but it seems I can't acces with Python. Someone know what's the matter? Or get some tips to how to take data from a sensor by WiFi with Python?

Btw: I'm using Window 7

Thanks for your help :)! Sam'

SamPrime: [Errno 10061] No connection could be made because the target machine actively refused it.

It seems to speak for itself. Do you have firewalls/antivirus/sort of thing that could make this happen?

I'd shut down firewall and antivirus, that's why this error is disturbing me.

Did you begin the Bridge in the arduino setup code ? If you don't begin it, it just doesn't work.

Check right here http://forum.arduino.cc/index.php?topic=233723.msg1691814#msg1691814

I'm not an advanced user, neither an advanced coder, still it definitely works to send the data thru bridge from arduino up to linino, then the Python script makes the wifi connection available. (take care to change the IP adress inside of the Python code, of course).

Still it is quite slow as I explain in this topic, I tried to have it working by shutting off the console as suggested, but the wifi didn't work anymore...

Hope it does help.

Thanks I find the problem I guess. I did all (Bridge.begin()…) excepting to change the IP adress inside of the Python code :cold_sweat:. So I checked the sockets.py and changed it:

def test_client():
from time import sleep
i = server.connect(‘192.168.1.100’, 5555)
while server.is_connecting(i):
server.run()
if not server.is_connected(i):
print “error”
return
print “connected”
server.send(i, “test”)
server.run()
server.close(i)
server.run()

With my Yun’s IP, but that print “error”, should I conclude I can’t connect to the Yun? Or did I failed to change the IP adress inside of the Python code? Which part of code you changed?

Well, something strikes me immediately within you code. I cannot see import socket (which i think is the library to use TCP or UDP protocol and a lot of other stuff)

Which library the "server" command is taken out of ? I'm definitely not experienced in python coding but is it part of the basical python environment ? don't you need to import a library ?

In my code I personally use the Pyosc library in order to send the data through OSC (which is a formatted UDP-style protocol widely used with pure data, max/msp, processing, etc...), so i don't use the "server" method

Actually that was a part of the sockets.py from Bridge, I though I had to change this part of code to made it work. My run code is like:

import sys sys.path.insert(0, 'D:\user...) from bridgeclient import BridgeClient as bridgeclient ...

I just noticed from the tcp.py files on the 188th line " bus = TCPJSONReceiver('0.0.0.0', 12345) " I've an error: "undifined name "TCPJSONReceiver"". I'd also put my Arduino's IP on the tcp.py and socket.py instead of the "0.0.0.0", still Errno 10061.

It's old test code https://github.com/arduino/YunBridge/blob/master/bridge/tcp.py#L186 It's not executed when using Bridge

Ok thank, then I'll just ignore it. Maybe the connexion is refused because it require a pass or something like this? I tried every IPs combination into the Bridge .py files.

I'll start to think it's a computer problem and not a code problem... but there is no apparent reasons.

Ok thank for all your answers I “solved” my problem but a strange thing just appear! I included a new port (for Arduino) into the .py files and it work ;).
( btw: When I run with the Internal Console my Python Code I’ve still have Errno 10061, can’t explain this…)

But now I’ve something new :relaxed:.
On the Arduino Side I’ve this code:
#include <Bridge.h>
int Pin = 1;
String key = “Test”;
int Value;
void setup() {

  • Bridge.begin();*
    }
    void loop() {
  • Value = analogRead(Pin);*
  • Bridge.put(key, String(Value));*
  • delay(1000);*
    }

I want to store my analogic data into the Linux processor, so I’ve to get them back on Windows with my Python code with a get():

import sys
sys.path.insert(0, ‘D:\Delmas.xy\startups\Bridge’)
from bridgeclient import BridgeClient as bridgeclient
value = bridgeclient()
value.get(‘key’)
print value.get(‘key’)

Instead of print a value of my sensor I’ve got a “None”. Did I do a misunderstood of the put() and get() function?

There is any typical ports for Yun? I can only make a pseudo-connection by using port 22 (like ssh), still have issues with port 8080 or port 5555.

SamPrime: There is any typical ports for Yun? I can only make a [u]pseudo-connection[/u] by using port 22 (like ssh), still have issues with port 8080 or port 5555.

Did you turn off firewall for testing?

/etc/init.d/firewall stop

If it works at firewall off, then setup iptables rule for port 8080 or port 5555 then turn back on the firewall.

About your problem in Wondows.

It looks like you are trying to use the "get" method in windows. But if i got it, the bridge is intended to provide a link between the arduino part and the linux part, so you have to use the "get" method in the linux within then use a script to send the data to your windows.

Sorry if i'm wrong but it's the way i understood it in the main manual.

Yea indeed it's that way I tried, I though I could get directly my data on Windows :drooling_face:. I've to check how programming my Yun with my Python code and check some option to get back my data (Autobhan for eg). Thanks!