Segmentation Fault


6 posts
by tedthetoaster » Thu May 18, 2017 1:30 pm
Hello Everyone! I was coding my Raspberry Pi in Python, and I am trying to use Pyo to accomplish this. When I run the code, I get a segmentation fault. Please help.
Code: Select all
# Servo Control
import time
import RPi.GPIO as GPIO
import wiringpi
# use 'GPIO naming'
GPIO.setmode(GPIO.BCM)
# set #18 to be a PWM output
GPIO.setup(18, GPIO.OUT)
# set the PWM mode to milliseconds stype
wiringpi.pwmSetMode(wiringpi.GPIO.PWM_MODE_MS)
# divide down clock
wiringpi.pwmSetClock(192)
wiringpi.pwmSetRange(2000)
delay_period = 0.01
# DO THE PWM SETUP
# pwm = GPIO.PWM(18, 1000)
# pwm.start(50)
#while True:
p = GPIO.PWM(18, 50)

def onPoseEdge(pose, edge):
   if (pose == "fist") and (edge == "on"):
      GPIO.output(18, GPIO.HIGH)
   pwm = GPIO.PWM(18, 1000)
   p.start(7.5)

   if (pose == "fingersSpread") and (edge == "on"):
      GPIO.output(18, GPIO.LOW)
   pwm = GPIO.PWM(18, 1000)
   p.start(2.5)
   

#def onPoseEdge(pose, edge):
#   if myo.title_contains("YouTube"):
#      if (pose == "waveOut") and (edge == "on"):
#         myo.keyboard("right_arrow","press","")
#      if (pose == "waveIn") and (edge == "on"):
#         myo.keyboard("left_arrow","press","")
#      if (pose == "fist") and (edge == "on"):
#         myo.keyboard("space","press","")


Thank You,

Ted
Posts: 2
Joined: Wed May 17, 2017 4:20 pm
by B.Goode » Thu May 18, 2017 6:30 pm
Welcome to the forums.

In the absence of any more skilled response to your question -

It isn't my area of expertise (some unkind people might suggest I don't have one... ) but my counter-question would be to ask whether you have any documentation that indicates that hybrid use of the RPi.GPIO and wiringpi libraries is supported as you are attempting?

I wonder if using either one or the other might give you clearer diagnostics?
Posts: 3474
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK
by davef21370 » Fri May 19, 2017 4:27 pm
I'll go with B.Goode's suggestion that mixing the libraries could be the problem. Could you post the error in full?

Dave.
Please feel free to tap into my abundant lack of knowledge.
When you're dead you don't know you're dead. It's the same as being stupid.
Apple say. Monkey do.
User avatar
Posts: 821
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded
by DougieLawson » Sun May 21, 2017 1:49 pm
Who's code gets the segfault? Where did you get the python library for WiringPi? What version of WiringPi is installed?

That's aside from the problem of mixing library functions.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.
User avatar
Posts: 27875
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by tedthetoaster » Sun May 21, 2017 7:33 pm
davef21370 wrote:I'll go with B.Goode's suggestion that mixing the libraries could be the problem. Could you post the error in full?

Dave.


B.Goode wrote:Welcome to the forums.

In the absence of any more skilled response to your question -

It isn't my area of expertise (some unkind people might suggest I don't have one... ) but my counter-question would be to ask whether you have any documentation that indicates that hybrid use of the RPi.GPIO and wiringpi libraries is supported as you are attempting?

I wonder if using either one or the other might give you clearer diagnostics?


The only thing that it says when I try to run the code is Segmentation fault.

I attached an image of when the error occurs - I highlighted in red something that may be causing the problem, but I am unsure. The black boxes are for privacy concerns
Attachments
IMG_3734_opt.jpg
IMG_3734_opt.jpg (14.15 KiB) Viewed 57 times
Posts: 2
Joined: Wed May 17, 2017 4:20 pm
by AshPowers » Mon May 22, 2017 7:55 pm
I just recently went through this. In Python, go to Build, Set Build Components. In the Execute entry at the bottom, add "sudo" at the front of the other text in the window to it's right.

Seems that you need superuser privileges to run most programs..
Posts: 60
Joined: Thu Apr 20, 2017 12:10 am
Location: Ormond Beach, FL