|
Post by toomuchfuel on Apr 15, 2014 5:52:19 GMT -8
Was using Netio, then came across RasPi, loved the install tutorial, but cannot get a single GPIO to trigger, I assumed that Local.py would accomodate the preloaded iphone app. Would be nice to know that the default 'panel setup' using B-2 Flash led would simply trigger a GPIO output.
Have I missed the most basic tutorial that shows how to go from install to GPIO triggers??? Or do I need a degree in Python first?
At least Netio got the GPIO's triggering
|
|
|
Post by SDL on Apr 16, 2014 11:54:15 GMT -8
Hello toomuch,
Have you missed the obvious? Perhaps! Post the local.py file you are using and let's look at it and help.
I assume you are talking about triggering a GPIO on a button push? B-2 specifically?
On the app, did you point B-2 to your Raspberry Pi (the system URL?)? Double check that and make sure that you can access that URL (look at the trouble shooting section of the manual). Run the server in Debug mode and see if you are receiving the XML.
I don't know what you are doing in your local.py file, but here is what I might try. Make sure you have an LED connected to the right pin (with a current limiting resistor!).
# B-2 - Blink an LED on the Raspberry Pi, pin 22 (GPIO 25). if (objectServerID == "B-2"):
#check for validate request # validate allows RasPiConnect to verify this object is here if (validate == "YES"): outgoingXMLData += Validate.buildValidateResponse("YES") outgoingXMLData += BuildResponse.buildFooter() return outgoingXMLData
# not validate request, so execute import RPi.GPIO as GPIO # Note: BOARD pin 22 is GPIO15 GPIO.setmode(GPIO.BOARD) GPIO.setup(22, GPIO.OUT) GPIO.output(22, False) GPIO.output(22, True) time.sleep(0.5) GPIO.output(22, False)
responseData = "OK" outgoingXMLData += BuildResponse.buildResponse(responseData) outgoingXMLData += BuildResponse.buildFooter() return outgoingXMLData
Best regards,
BP
|
|
|
Post by toomuchfuel on Apr 17, 2014 6:39:42 GMT -8
I used the default Local.py file assuming it would do some basic triggering and stuff. I ran the 'ip address:9600/version' test and all was ok, do i need to do more with the ip configs? 
|
|
|
Post by SDL on Apr 17, 2014 21:01:23 GMT -8
The basic default Local.py file plays a sound through the speaker port. It was done that way because the Raspberry Pi has nothing built in that will work aside from that.
Look at the above Local.py file, hook up an LED and try this.
Best regards,
BP
|
|
|
Post by toomuchfuel on Apr 19, 2014 17:40:42 GMT -8
Tried you Local.py file, it caused my app to go offline, then when i removed the file from the RasPiConnectServer folder, my app goes back online. And yes, I point B-2 to my server url
|
|
|
Post by SDL on Apr 19, 2014 19:37:10 GMT -8
Toomuchfuel,
Sorry, I wasn't clear. The above wasn't a full local.py file. Just a replacement for B-2 in the local.py file.
In your local.py file, replace B-2 with the above. You should copy the LocalExample.py to local.py and then replace B-2 with the above code.
Best regards,
BP
|
|
|
Post by toomuchfuel on Apr 20, 2014 2:35:51 GMT -8
Toomuchfuel, Sorry, I wasn't clear. The above wasn't a full local.py file. Just a replacement for B-2 in the local.py file. In your local.py file, replace B-2 with the above. You should copy the LocalExample.py to local.py and then replace B-2 with the above code. Best regards, BP These are my files Attachments:2Local.py (2.89 KB)
1Local.py (111.95 KB)
|
|
|
Post by SDL on Apr 20, 2014 9:39:58 GMT -8
toomuchfuel,
I took your 2local.py file, renamed it Local.py and executed a button B-2 from RasPiConnect. Looking at the debug output from the RasPiConnectServer, you have an indent syntax error.
Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/application.py", line 239, in process return self.handle() File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/application.py", line 230, in handle return self._delegate(fn, self.fvars, args) File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/application.py", line 420, in _delegate return handle_class(cls) File "/usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg/web/application.py", line 396, in handle_class return tocall(*args) File "/home/pi/RasPiConnectServer/RasPiConnectServer.py", line 177, in POST import Local File "./local/Local.py", line 78 if (objectServerID == "B-2"): ^ IndentationError: unindent does not match any outer indentation level
192.168.1.6:63901 - - [20/Apr/2014 17:32:13] "HTTP/1.1 POST /raspi" - 500 Internal Server Error I fixed this indentation problem in your file and then added import time to the headers. The file now runs correctly
Here is the resulting Local.py file
#!/usr/bin/python # Filename: Local.py # # # Local Execute Objects for RasPiConnect # to add Execute objects, modify this file # # # # RasPiConnectServer interface constants
REMOTE_WEBVIEW_UITYPE = 1 ACTION_BUTTON_UITYPE = 16 FEEDBACK_ACTION_BUTTON_UITYPE = 17 SINGLE_LED_DISPLAY_UITYPE = 32 SPEEDOMETER_UITYPE = 64 VOLTMETER_UITYPE = 128 BARMETER_UITYPE = 129 SERVER_STATUS_UITYPE = 256 PICTURE_REMOTE_WEBVIEW_UITYPE = 512 LABEL_UITYPE = 1024 FM_BLINK_LED_UITYPE = 2048 TEXT_DISPLAY_UITYPE = 4096 TOGGLE_SWITCH_UITYPE = 33 SEND_TEXT_UITYPE = 34
# system imports import sys import subprocess import time
# RasPiConnectImports
import Config import Validate import BuildResponse
def ExecuteUserObjects(objectType, element):
# Example Objects
# fetch information from XML for use in user elements
#objectServerID is the RasPiConnect ID from the RasPiConnect App
objectServerID = element.find("./OBJECTSERVERID").text objectID = element.find("./OBJECTID").text
if (Config.debug()): print("objectServerID = %s" % objectServerID) # # check to see if this is a Validate request # validate = Validate.checkForValidate(element)
if (Config.debug()): print "VALIDATE=%s" % validate
# Build the header for the response
outgoingXMLData = BuildResponse.buildHeader(element)
# objects are split up by object types by Interface Constants # # # # search for matches to object Type
if (Config.debug()): print "ACTION_BUTTON_UTYPE of %s found" % objectServerID
# B-2 - Blink an LED on the Raspberry Pi, pin 22 (GPIO 25). if (objectServerID == "B-2"):
#check for validate request # validate allows RasPiConnect to verify this object is here if (validate == "YES"): outgoingXMLData += Validate.buildValidateResponse("YES") outgoingXMLData += BuildResponse.buildFooter() return outgoingXMLData
# not validate request, so execute import RPi.GPIO as GPIO # Note: BOARD pin 22 is GPIO15 GPIO.setmode(GPIO.BOARD) GPIO.setup(22, GPIO.OUT) GPIO.output(22, False) GPIO.output(22, True) time.sleep(0.5) GPIO.output(22, False)
responseData = "OK" outgoingXMLData += BuildResponse.buildResponse(responseData) outgoingXMLData += BuildResponse.buildFooter() return outgoingXMLData
else: return "" # returning a zero length string tells the server that you have not matched # the object and server return ""
Hope this helps.
Best regards,
BP
|
|
|
Post by toomuchfuel on Apr 23, 2014 3:55:45 GMT -8
Took my app offline again
|
|
|
Post by SDL on Apr 23, 2014 7:38:46 GMT -8
Toomuchfuel,
What do you mean "Took my App offline"? Are you talking about the iPad App? Your own program?
We need some more information to help you here. Post your errors.
Best regards,
BP
|
|
|
Post by toomuchfuel on Apr 24, 2014 10:51:56 GMT -8
The green dot in 'server report' on the app goes red
|
|
|
Post by SDL on Apr 24, 2014 12:44:15 GMT -8
Hi toomuchfuel,
On your raspberry Pi, start the RasPiConnectServer in debug mode (in the configuration file - see the wiki manual), start it in a terminal window and copy and paste the error messages you are getting.
The green dot going red does indicate the server is down, but it doesn't tell us why. The above will tell us why.
Best regards,
BP
|
|
|
Post by SDL on Apr 24, 2014 12:44:38 GMT -8
Hi toomuchfuel,
On your raspberry Pi, start the RasPiConnectServer in debug mode (in the configuration file - see the wiki manual), start it in a terminal window and copy and paste the error messages you are getting.
The green dot going red does indicate the server is down, but it doesn't tell us why. The above will tell us why.
Best regards,
BP
|
|
|
Post by toomuchfuel on Apr 25, 2014 21:35:39 GMT -8
If your referring to this line: # set to True if you wish to see debugging output from the server otherwise False DEBUG = True I have it set to 'True' but i do not see any errors coming up on screen?  ? Does it save to a file somewhere?
|
|
|
Post by SDL on Apr 27, 2014 12:58:46 GMT -8
ToomuchFuel,
I posted a response to this a few days ago and it disappeared! Sorry about that.
You need to start the server in a terminal window to see the debug data.
1) type "ps xaf | grep python" to see if RasPiConnect is running. if it is, kill it with "sudo kill -9 'process id from ps oaf command' "
2) start the server in the terminal window. cd to the RasPiConnectServer directory and type "sudo sh startserver.sh"
copy and past the resulting errors into a posting so we can look at them.
Best regards,
BP
|
|