I believe that this should not be a problem of the hardwareInterface but rather a problem in python. You will most likely find solutions for this problem in the PI/python communities.
For the hardwareInterface you basically want to extend the new hardwareInterface in to the python environment.
In python one should den be able to:
Add new IO points within a setup and go function.
Have some sort of listener or callback for when data from the IO points is coming in
I have some materials , and is researching on ways to interrface nodejs and python,while the new API is getting ready @KevinOrtman
The gpio using python is not ready yet , there are nodejs GPIO methods available as Carsten mentioned
but you can add the objects to hybrid object server and connect to the reality editor
if you are intrrested you can play around with making AR elements like line graph,bar graph etc for the reality editor
Steps for running hybridobject server on Raspberry pi
NOTE : It will be better to update your raspberry pi before beginning the process
# sudo apt-get update
# sudo apt-get upgrade
Requirements :
1. Raspberrry pi ( server should work on any model , please report if any issues)
2. internet connection on the pi ( to use the vuforia portal ) , you can use a wifi adapter or directly connecct via LAN cable
3 iOS 7 or above device for reality editor
@KevinOrtman Thats a good Idea, I will add it to the open hybrid install guide on the webpage. @V_Mohammed_Ibrahim is the guide above finished or should we add some more things before its added to the page?
I will also generate a drop down menu on the install page. By now we have a lot of guides.
Do you have some good sources for wiki systems that would allow use to rebuild the open hybrid webpage as a wiki? That would allow us to have more people involved in taking care of the webpage content.
@KevinOrtman did you have any difficulty during npm install ?
if there were no problems then the guide is is perfect , i had some doubts on weather npm would work ,
should we add any pics or will this be clear enough? @valentin
it should , ZERO has processing power and almost same features , the server should work , ZERO is not available here yet @valentin the guide is finished
Sorry for the delay in getting back with you. I wanted to make 100% sure that the steps were accurate.
So, I re-imaged my sd card to try from scratch (base OS only) and tried multiple variations on the install steps. The install/restore process takes quite a long time, thus the delay.
@V_Mohammed_Ibrahim I found that following the exact steps outlined above failed to install serialport. In my case, the default nodejs instance need to be uninstalled first, and the install via node-arm was a bit flakey. I had a better install experience simply uninstalling the default nodejs then installing v0.12 via nodesource (GitHub - nodesource/distributions: NodeSource Node.js Binary Distributions).
It will become the master branch next week once we debugged it. A lot has changed.
It might be possible that the default nodejs version is working with this branch.
@Carsten worked on a new hardwareInterfaces that allows you to easily communicate with your hardware with nodejs.
@KevinOrtman@valentin
my node version is 4.0.0 , old nodejs versions might cause problems,
you can update to node 4.0.0 using this
i have updated the instructions above with getting node 4.0.0, but that is too many instructions for a new user ,
we should update the guide in the site with @KevinOrtman instructions
The method works in that npm install completes successfully.
Server execution fails, however, with the following output. Iām in the process of debugging.
pi@raspberrypi:~/object $ nodejs server.js
got it started
Loading template: base
Starting System:
Enter loadHybridObjects
TempFolderName: null
object Light1 has no marker yet
TempFolderName: null
object Light2 has no marker yet
TempFolderName: null
object test has no marker yet
socket.io started
Createing folder: /home/pi/object/objects/Light1/
AddIO objectID: null philipsHue
Createing folder: /home/pi/object/objects/Light1/
AddIO objectID: null philipsHue
it's all cleared
Createing folder: /home/pi/object/objects/Light2/
AddIO objectID: null philipsHue
Createing folder: /home/pi/object/objects/Light2/
AddIO objectID: null philipsHue
it's all cleared
found 1 internal server
starting internal Server.
webserver + socket.io is listening on port: 8080
UDP listening on port: 52316
base loaded !
Loading template: documentation
documentation loaded !
Loading template: header
header loaded !
Loading template: home-object
home-object loaded !
Loading template: home-object-add
home-object-add loaded !
Loading template: interface
interface loaded !
Loading template: interface-rowitem
interface-rowitem loaded !
Loading template: monitor
monitor loaded !
Loading template: sidebar
sidebar loaded !
Loading template: target
target loaded !
events.js:85
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED
at exports._errnoException (util.js:746:11)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1012:19)
@V_Mohammed_Ibrahim do you get the same output when running the code in the beta branch on your Pi?
I was seeing that error because the philipsHue interface was enabled and trying to send an http request to a pH device. Should we set the exports.enabled flag to false by default?
I also ran across a few other minor items that could be improved while working through the code. Iāll submit a PR for your review.
Yes we should set the flag to false by default. The hue interface is very beta. It doesnāt have any error handling at all so far. At the moment itās main purpose is to illustrate the use of the new API. I should have mentioned that in the comments.
I decided to focus on Pi <-> Hue comms before debugging my RE <-> Pi comms. I can load objects into my phone and see overlays, so I know Iām not too far away on the RE side.
It took me some time to get the Hue interface working, mostly because Iām barely competent, but it more or less works!
I learned enough curl to build Hue REST messages by hand. This was all new to me. Turns out the trickiest part is getting a valid username, and once I did that manually I just added that to the URL template so itās still ugly, but functional. Getting IP address was pretty easyā¦lots of ways to do that, but from my phone app was easiest.
Took me awhile to figure out little things like the right ports. Itās 80 on mine, not 8000.
I added a level set to go with the state on/off. I re-learned vi a bit after a 20 year hiatus. Slow but steady progressā¦
Since I donāt have host comms working yet, I hacked in a level staircase that reads the level, adds a bit, writes the level, waits a while, and repeats. Sorta llike the generator loop I see in there to send to RE, only facing the lights instead.
Itās still a polling loop, reading the light state and trying to send it up to RE. I didnāt add change filtering yet.
It was cool for about 30 seconds. A light that ramps continually gets old pretty fast!