jdf / Processing.py-Bugs

A home for all bugs and feature requests about Python Mode for the Processing Development Environment.
41 stars 8 forks source link

GPIO Library does not load at raspberry pi 3 #189

Closed Schnurber closed 6 years ago

Schnurber commented 7 years ago
add_library('io')
def setup():
    GPIO.pinMode(22, GPIO.OUTPUT)

does not work! Error Message is

processing.app.SketchException: java.lang.NoClassDefFoundError: Could not initialize class processing.io.GPIO

But in Java mode it works!

jdf commented 7 years ago

Hmm. I see that the io library is only built on certain platforms. @benfry, is there any way for me unconditionally build and make available whatever's required to make the io library available on relevant platforms for Python mode?

benfry commented 7 years ago

Hmm, this is a question for @gohai

gohai commented 7 years ago

@jdf The IO library is indeed only shipped on ARM. Additionally, it can also be installed through the Library Manager: on all platforms besides Linux this will only be simulating the actual functionality, but this is still useful e.g. in combination with the UploadToPi tool. And it should also allow you to probe the NoClassDefFoundError.

Hth. Let me know if I can fill in any blanks.

Schnurber commented 7 years ago

I was coding on a raspberry pi with processing ide installed. In python mode, the exception was thrown. There are no problems in java mode.

Am 13.07.2017 um 17:12 schrieb Gottfried Haider notifications@github.com:

@jdf The IO library is indeed only shipped on ARM. Additionally, it can also be installed through the Library Manager: on all platforms besides Linux this will only be simulating the actual functionality, but this is still useful e.g. in combination with the UploadToPi tool. And it should also allow you to probe the NoClassDefFoundError.

Hth. Let me know if I can fill in any blanks.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

HorusMaster commented 6 years ago

I also cant use this library in python mode, any updates??

jdf commented 6 years ago

I can't figure out how to find or install this library when running the PDE on my mac. I see no reference to "io" or "GPIO" in the contributions manager. Can someone walk me through installing it on OS X?

jdf commented 6 years ago

While I'm waiting to figure out the NoClassDefFound error, I also need to change my code to allow for the existence of architectures I was unfamiliar with.

screen shot 2017-11-04 at 2 36 33 pm

My code for searching for native code resources is wrong. How do I detect those arm architectures? @benfry, is there any PDE code I can hijack to figure out the right folder(s) to search for dynamic libraries?

gohai commented 6 years ago

@jdf You should be able to find a "Hardware I/O" library from "The Processing Foundation" under Libraries in the Contribution Manager. Here's the direct download to the ZIP.

For detection of those architectures: perhaps these commits to the PDE code that implement the armv6hf support are instructive? The arm64 ones are probably fairly analogous (but this is currently not yet at play on the Pi anyhow): https://github.com/processing/processing/commit/8d7c5370aad5c825d64c49c26965ccf5b7382eed https://github.com/processing/processing/commit/f098cd6f4b626ce8dbaa3f2e9d2d43d20a410b13 https://github.com/processing/processing/commit/fab830cee1fcef0f2501211c185bced8db23169b

Thanks for looking into this!

jdf commented 6 years ago

Build 3031 contains these fixes, but I'm not able to test them on the platform in question. I'd be happy to try, though. What will I need to test on real hardware?

jdf commented 6 years ago

Also, I forgot to say: Thanks very much, @gohai, for your precise and on-point assistance!

gohai commented 6 years ago

@jdf You're very welcome - thank you.

The easiest way would be to download the prepared image file and put it onto a SD card to be used on a Pi. After boot-up you should find Processing in the menu on the top left.

I am also planning to test this myself in the next week or so!

jdf commented 6 years ago

Hi @gohai. Have you had a chance to test the new release?

gohai commented 6 years ago

@jdf Yes, it works. Here's some example code (equivalent to the SimpleOutput one in Java):

add_library('io')
ledOn = True

# GPIO numbers refer to different phyiscal pins on various boards
# On the Raspberry Pi GPIO 4 is physical pin 7 on the header
# see setup.png in the sketch folder for wiring details

def setup():
  GPIO.pinMode(4, GPIO.OUTPUT)
  frameRate(0.5)

def draw():
  global ledOn
  # make the LED blink
  ledOn = not ledOn
  if ledOn:
    GPIO.digitalWrite(4, GPIO.LOW)
    fill(204)
  else:
    GPIO.digitalWrite(4, GPIO.HIGH)
    fill(255)
  stroke(255)
  ellipse(width/2, height/2, width*0.75, height*0.75)
jdf commented 6 years ago

Thanks for the good news!

Schnurber commented 6 years ago

Thanks!

Am 23.11.2017 um 17:28 schrieb Gottfried Haider notifications@github.com:

@jdf https://github.com/jdf Yes, it works. Here's some example code (equivalent to the SimpleOutput one in Java):

add_library('io') ledOn = True

GPIO numbers refer to different phyiscal pins on various boards

On the Raspberry Pi GPIO 4 is physical pin 7 on the header

see setup.png in the sketch folder for wiring details

def setup(): GPIO.pinMode(4, GPIO.OUTPUT) frameRate(0.5)

def draw(): global ledOn

make the LED blink

ledOn = not ledOn if ledOn: GPIO.digitalWrite(4, GPIO.LOW) fill(204) else: GPIO.digitalWrite(4, GPIO.HIGH) fill(255) stroke(255) ellipse(width/2, height/2, width0.75, height0.75) — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jdf/Processing.py-Bugs/issues/189#issuecomment-346660172, or mute the thread https://github.com/notifications/unsubscribe-auth/AAt6oRuhh7164ARJylEscbKiNgq9FhGLks5s5Z0hgaJpZM4OV3Jg.