Software Archive
Read-only legacy content
17061 Discussions

Edison+Arduino+MRAA+Python works only first time

Mircea_D_
Beginner
1,366 Views

Hi,

 

very strange problem

i have an Edison Arduino board,

i installed ubilinbux on it

also installed lib mraa (python)

i tried both samples GPIO in and out

https://github.com/intel-iot-devkit/mraa/tree/master/examples/python

blink-io8.py and hello_isr.py

if in unplub both usb cables from the arduino, reconect back login and run the sample everything works perfect

if i start killing the sample (ctrl+Z) or kill python process or close python interpreter, and try again to run the sample, nothing works 

 

let me explain nothing works:

the isr sampel si not working at all

but the gpio out sample, if i use pin 10 instead of turning on the led i added on pin ten (like it was doing immediately after power on) now some green led closer to the 6 pin header (3x2) is turning on and off, and if i mess with this led, i lose the wifi/network connectivity (cannot ping in or out to the edison linux) but the putty over the com port works fine 

 

anyone any ideas or explanation into how this edison works and what gets messed up and eventually how it can be made again to work. (i tried to press all the 5 buttons present on the board and 1 to 4 they are not making the problem go away, anyway read teh docs about them and those buttons have all kind of functionality, and 5 resets the linux but still does not make io work, i need to power down completely the board and power it back on to get io back working)

 

​hope this problem with the IO getting all messed up after first sample run makes sense to anyone.

0 Kudos
4 Replies
Mircea_D_
Beginner
1,366 Views

wifi issue after first mraa python script gets run (till that moment all works perfect)

wifi-after libmraa.jpg

0 Kudos
samontab
Valued Contributor II
1,366 Views

Hi Mircea,

If you do CTRL+Z, you are not killing the process. You are suspending it and sending it to the background. This probably explains why it does not work the second time you try to run it.

Try stopping the application with CTRL+C.

0 Kudos
Mircea_D_
Beginner
1,366 Views

so i do "iwconfig wlan0 power off" to turn off the wifi power saving, and that gives me an initial ~20ms delay on ping

and after ctr+z i do ps -u root| grep python and kill the python process, and than i do fg <bg task id> 

0 Kudos
Mircea_D_
Beginner
1,366 Views

and python code

 

 

import mraa
import time
import sys

print(mraa.getPlatformType())
print(mraa.getPlatformName())
#mraa.setLogLevel(7)

class Counter:
  count = 0

c = Counter()

# inside a python interupt you cannot use 'basic' types so you'll need to use
# objects
def test(args):
  print("wooo")
  c.count+=1


for j in range(1,100):
    for pin in range(7,11):
        try:
            x = mraa.Gpio(pin)
            print('working on pin %d' % (pin, ))
            x.dir(mraa.DIR_OUT)
            for i in range(1,2):
                x.write(1)
                time.sleep(0.05)
                x.write(0)
                time.sleep(0.05)
        except:
            print('BAD pin %d' % (pin, ))
            
            
sys.exit()        
#x.isr(mraa.EDGE_BOTH, test, test)

#time.sleep(5

0 Kudos
Reply