3

I am using Jasper.

The voice control part works, however the function I call when a certain word is said, does not.

I'm trying to control a robot, sending high signals to certain pins on an L293D chip. I've made a simple function to easily set multiple pins high:

import wiringpi2 as wiringPi
wiringPi.wiringPiSetupSys()

def goHigh(*arg): #for multiple pins
    for pin in arg: 
        wiringPi.digitalWrite(pin, 1)

But when I call that function with a certain word, I get the error NameError: global name 'wiringPi' is not defined:

ERROR:client.brain:Failed to execute module
Traceback (most recent call last):
  File "/home/pi/jasper/boot/../client/brain.py", line 73, in query
    module.handle(text, self.mic, self.profile)
  File "/home/pi/jasper/client/modules/robot.py", line 64, in handle
    goForward(mic, message)
  File "/home/pi/jasper/client/modules/robot.py", line 29, in goForward
    goHigh(A1,B2)
  File "/home/pi/jasper/client/modules/robot.py", line 12, in goHigh
    wiringPi.digitalWrite(pin, 1)
NameError: global name 'wiringPi' is not defined

It seems that Jasper cannot see WiringPi as being installed. What I've tried:

  • Building WiringPi in the Jasper directory
  • Normally building it in my home

But this still doesn't work; I presume because WiringPi builds in its own folder, and Jasper looks for a single file.

How can I fix this? So I can use WiringPi with Jasper?

  • I don't think it is installed properly. – dhruvvyas90 Oct 13 '15 at 5:44
  • How am I supposed to install it? I cloned it from github and built it currently...It's worth saying that running this myself, in python, does work, it's just jasper – ᔕᖺᘎᕊ Oct 13 '15 at 6:11
  • Here : follow this : raspi.tv/… – dhruvvyas90 Oct 13 '15 at 6:13
  • OK, I installed it following wiringpi.com/download-and-install; I'll try using pip tonight and see if that works, however id does already work if I type in some commands manually! It's just with Jasper that causes the problem :( – ᔕᖺᘎᕊ Oct 13 '15 at 6:18
  • 1
    I've heard a lot about jasper project but haven't really tried using it. Feel free to ask a question, if not me, there're chances that someone who has already worked on it would answer the question. Also, added the work around as the answer. Hope it helps. – dhruvvyas90 Oct 13 '15 at 17:21
2

As a workaround, since the OP's having difficulty using jasper modules with sudo, I suggest to use the os module in python and call the system gpio utility by os.system.

For example,

import os
# import other modules

#do other works.

os.system("gpio write 0 0")

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.