Problème de lancement de script sous RaspBianOSJessie
Posté : mar. 6 sept. 2016 19:54
Bonjour, j'aimerai executer un script copier de fred-j.org pour reproduire son robot mais lors de l'éxecution du script, j'ai : RuntimeError: rpio-pwm: Page 0 not present (pfn 0xa10000000005e5) ...
J'ai toute les permissions, je suis en "root" et voilà le script :
#!/usr/bin/python
# -*- coding:Utf-8 -*-
from RPIO import PWM
import RPIO
import socket
import RPi.GPIO as GPIO
import time
import sys
HOST = "0.0.0.0"
PORT = 12345
#-------------[ CABLAGE ]--------------------
My_LED = 22
Moteur_1_Forward = 25
Moteur_1_Reverse = 24
Moteur_2_Forward = 23
Moteur_2_Reverse = 18
LED_R = 22
LED_V = 27
LED_B = 17
BUZZER_PIN = 04
#-------------[ Initialisation ]--------------
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(Moteur_1_Forward, GPIO.OUT)
GPIO.setup(Moteur_1_Reverse, GPIO.OUT)
GPIO.setup(Moteur_2_Forward, GPIO.OUT)
GPIO.setup(Moteur_2_Reverse, GPIO.OUT)
GPIO.setup(LED_R, GPIO.OUT)
GPIO.setup(LED_V, GPIO.OUT)
GPIO.setup(LED_B, GPIO.OUT)
BUZZER = RPIO.PWM.Servo()
#--------------------------------------------
def BIP() :
BUZZER.set_servo(BUZZER_PIN,15000)
time.sleep(.1)
BUZZER.stop_servo(BUZZER_PIN)
time.sleep(.01)
BUZZER.set_servo(BUZZER_PIN,15000)
time.sleep(.1)
BUZZER.stop_servo(BUZZER_PIN)
def AVANT() :
print "Marche Avant"
GPIO.output(Moteur_1_Forward, GPIO.HIGH)
GPIO.output(Moteur_2_Forward, GPIO.HIGH)
def ARRIERE() :
print "Marche Arriere"
GPIO.output(Moteur_1_Reverse, GPIO.HIGH)
GPIO.output(Moteur_2_Reverse, GPIO.HIGH)
time.sleep(0.5)
STOP()
def DROITE() :
print "tourne a droite"
GPIO.output(Moteur_1_Forward, GPIO.HIGH)
GPIO.output(Moteur_2_Reverse, GPIO.HIGH)
time.sleep(0.5)
STOP()
def DROITE_Toute() :
print "tourne a droite"
GPIO.output(Moteur_1_Forward, GPIO.HIGH)
GPIO.output(Moteur_2_Reverse, GPIO.HIGH)
def GAUCHE() :
print "tourne a gauche"
GPIO.output(Moteur_1_Reverse, GPIO.HIGH)
GPIO.output(Moteur_2_Forward, GPIO.HIGH)
time.sleep(0.5)
STOP()
def GAUCHE_Toute() :
print "tourne a gauche"
GPIO.output(Moteur_1_Reverse, GPIO.HIGH)
GPIO.output(Moteur_2_Forward, GPIO.HIGH)
def STOP () :
print "stop"
GPIO.output(Moteur_1_Forward, GPIO.LOW)
GPIO.output(Moteur_2_Forward, GPIO.LOW)
GPIO.output(Moteur_1_Reverse, GPIO.LOW)
GPIO.output(Moteur_2_Reverse, GPIO.LOW)
def LED_R_UP() :
print "LED Rouge Marche"
GPIO.output(LED_R, GPIO.HIGH)
def LED_V_UP() :
print "LED Vert Marche"
GPIO.output(LED_V, GPIO.HIGH)
def LED_B_UP() :
print "LED Bleu Marche"
GPIO.output(LED_B, GPIO.HIGH)
def LED_DOWN() :
print "LED Stop"
GPIO.output(LED_R, GPIO.LOW)
GPIO.output(LED_V, GPIO.LOW)
GPIO.output(LED_B, GPIO.LOW)
def MENU() :
connexion.send( "\n\r" )
connexion.send( " A --> en Avant\n" )
connexion.send( " R --> en Arriere\n" )
connexion.send( " D --> a Droite\n" )
connexion.send( " DD --> a Droite (sans stop)\n" )
connexion.send( " G --> a Gauche\n" )
connexion.send( " GG --> a Gauche (sans stop)\n" )
connexion.send( " S --> STOP\n" )
connexion.send( " 1 --> LED Rouge ON\n" )
connexion.send( " 2 --> LED Vert ON\n" )
connexion.send( " 3 --> LED Bleu ON\n" )
connexion.send( " 0 --> LED OFF\n" )
connexion.send( " B --> BIP\n" )
connexion.send( " M --> MENU\n" )
connexion.send( "\n" )
print "GO"
print "Start\n"
# Creation du socket
mySocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Liaison du socket avec l'interface
try:
mySocket.bind((HOST, PORT))
except socket.error:
print "La liaison du socket à l'adresse choisie a échoué."
sys.exit()
BIP()
# --------------------------------------
while 1:
print "Serveur en attente ..."
mySocket.listen(5)
# Etablissement de la connexion :
connexion, adresse = mySocket.accept()
print "Client connecté, adresse IP %s, port %s" % (adresse[0], adresse[1])
# Envoi d'un message qu client :
connexion.send("\nWelcome to Fred's Robot Server\n\n")
MENU()
# Reception des message client
while 1:
msgClient = connexion.recv(10).rstrip()
print "C>"+msgClient+"<"
if msgClient.lower() == "fin" or msgClient =="" or msgClient.lower() == "stop":
print "Break !!!"
break
elif msgClient.upper() == "M" :
MENU()
# Commandes Robot
elif msgClient.upper() == "A" :
AVANT()
elif msgClient.upper() == "R" :
ARRIERE()
elif msgClient.upper() == "D" :
DROITE()
elif msgClient.upper() == "DD" :
DROITE_Toute()
elif msgClient.upper() == "G" :
GAUCHE()
elif msgClient.upper() == "GG" :
GAUCHE_Toute()
elif msgClient.upper() == "S" :
STOP()
elif msgClient.upper() == "1" :
LED_R_UP()
elif msgClient.upper() == "2" :
LED_V_UP()
elif msgClient.upper() == "3" :
LED_B_UP()
elif msgClient.upper() == "0" :
LED_DOWN()
elif msgClient.upper() == "B" :
BIP()
# Fin de la session
connexion.send("By By !")
print "Connexion interrompue."
connexion.close()
# fin du programme
if msgClient.lower() == "stop":
break
Merci d'avance, WolsterKing
J'ai toute les permissions, je suis en "root" et voilà le script :
#!/usr/bin/python
# -*- coding:Utf-8 -*-
from RPIO import PWM
import RPIO
import socket
import RPi.GPIO as GPIO
import time
import sys
HOST = "0.0.0.0"
PORT = 12345
#-------------[ CABLAGE ]--------------------
My_LED = 22
Moteur_1_Forward = 25
Moteur_1_Reverse = 24
Moteur_2_Forward = 23
Moteur_2_Reverse = 18
LED_R = 22
LED_V = 27
LED_B = 17
BUZZER_PIN = 04
#-------------[ Initialisation ]--------------
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(Moteur_1_Forward, GPIO.OUT)
GPIO.setup(Moteur_1_Reverse, GPIO.OUT)
GPIO.setup(Moteur_2_Forward, GPIO.OUT)
GPIO.setup(Moteur_2_Reverse, GPIO.OUT)
GPIO.setup(LED_R, GPIO.OUT)
GPIO.setup(LED_V, GPIO.OUT)
GPIO.setup(LED_B, GPIO.OUT)
BUZZER = RPIO.PWM.Servo()
#--------------------------------------------
def BIP() :
BUZZER.set_servo(BUZZER_PIN,15000)
time.sleep(.1)
BUZZER.stop_servo(BUZZER_PIN)
time.sleep(.01)
BUZZER.set_servo(BUZZER_PIN,15000)
time.sleep(.1)
BUZZER.stop_servo(BUZZER_PIN)
def AVANT() :
print "Marche Avant"
GPIO.output(Moteur_1_Forward, GPIO.HIGH)
GPIO.output(Moteur_2_Forward, GPIO.HIGH)
def ARRIERE() :
print "Marche Arriere"
GPIO.output(Moteur_1_Reverse, GPIO.HIGH)
GPIO.output(Moteur_2_Reverse, GPIO.HIGH)
time.sleep(0.5)
STOP()
def DROITE() :
print "tourne a droite"
GPIO.output(Moteur_1_Forward, GPIO.HIGH)
GPIO.output(Moteur_2_Reverse, GPIO.HIGH)
time.sleep(0.5)
STOP()
def DROITE_Toute() :
print "tourne a droite"
GPIO.output(Moteur_1_Forward, GPIO.HIGH)
GPIO.output(Moteur_2_Reverse, GPIO.HIGH)
def GAUCHE() :
print "tourne a gauche"
GPIO.output(Moteur_1_Reverse, GPIO.HIGH)
GPIO.output(Moteur_2_Forward, GPIO.HIGH)
time.sleep(0.5)
STOP()
def GAUCHE_Toute() :
print "tourne a gauche"
GPIO.output(Moteur_1_Reverse, GPIO.HIGH)
GPIO.output(Moteur_2_Forward, GPIO.HIGH)
def STOP () :
print "stop"
GPIO.output(Moteur_1_Forward, GPIO.LOW)
GPIO.output(Moteur_2_Forward, GPIO.LOW)
GPIO.output(Moteur_1_Reverse, GPIO.LOW)
GPIO.output(Moteur_2_Reverse, GPIO.LOW)
def LED_R_UP() :
print "LED Rouge Marche"
GPIO.output(LED_R, GPIO.HIGH)
def LED_V_UP() :
print "LED Vert Marche"
GPIO.output(LED_V, GPIO.HIGH)
def LED_B_UP() :
print "LED Bleu Marche"
GPIO.output(LED_B, GPIO.HIGH)
def LED_DOWN() :
print "LED Stop"
GPIO.output(LED_R, GPIO.LOW)
GPIO.output(LED_V, GPIO.LOW)
GPIO.output(LED_B, GPIO.LOW)
def MENU() :
connexion.send( "\n\r" )
connexion.send( " A --> en Avant\n" )
connexion.send( " R --> en Arriere\n" )
connexion.send( " D --> a Droite\n" )
connexion.send( " DD --> a Droite (sans stop)\n" )
connexion.send( " G --> a Gauche\n" )
connexion.send( " GG --> a Gauche (sans stop)\n" )
connexion.send( " S --> STOP\n" )
connexion.send( " 1 --> LED Rouge ON\n" )
connexion.send( " 2 --> LED Vert ON\n" )
connexion.send( " 3 --> LED Bleu ON\n" )
connexion.send( " 0 --> LED OFF\n" )
connexion.send( " B --> BIP\n" )
connexion.send( " M --> MENU\n" )
connexion.send( "\n" )
print "GO"
print "Start\n"
# Creation du socket
mySocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Liaison du socket avec l'interface
try:
mySocket.bind((HOST, PORT))
except socket.error:
print "La liaison du socket à l'adresse choisie a échoué."
sys.exit()
BIP()
# --------------------------------------
while 1:
print "Serveur en attente ..."
mySocket.listen(5)
# Etablissement de la connexion :
connexion, adresse = mySocket.accept()
print "Client connecté, adresse IP %s, port %s" % (adresse[0], adresse[1])
# Envoi d'un message qu client :
connexion.send("\nWelcome to Fred's Robot Server\n\n")
MENU()
# Reception des message client
while 1:
msgClient = connexion.recv(10).rstrip()
print "C>"+msgClient+"<"
if msgClient.lower() == "fin" or msgClient =="" or msgClient.lower() == "stop":
print "Break !!!"
break
elif msgClient.upper() == "M" :
MENU()
# Commandes Robot
elif msgClient.upper() == "A" :
AVANT()
elif msgClient.upper() == "R" :
ARRIERE()
elif msgClient.upper() == "D" :
DROITE()
elif msgClient.upper() == "DD" :
DROITE_Toute()
elif msgClient.upper() == "G" :
GAUCHE()
elif msgClient.upper() == "GG" :
GAUCHE_Toute()
elif msgClient.upper() == "S" :
STOP()
elif msgClient.upper() == "1" :
LED_R_UP()
elif msgClient.upper() == "2" :
LED_V_UP()
elif msgClient.upper() == "3" :
LED_B_UP()
elif msgClient.upper() == "0" :
LED_DOWN()
elif msgClient.upper() == "B" :
BIP()
# Fin de la session
connexion.send("By By !")
print "Connexion interrompue."
connexion.close()
# fin du programme
if msgClient.lower() == "stop":
break
Merci d'avance, WolsterKing