thomasmacpherson / piface Goto Github PK
View Code? Open in Web Editor NEWEverything piface
Everything piface
I cannot get the example code running on a brand new Piface digital 2 board.
Is it intended to be compatible??
When sending the SPI module (Python C extension) three bytes of data to write to the board, the variable is modified.
A new player on the RPi forums complained that his CPP program was not linking against the piface functions. It would be easier for most if CPP wrappers were placed within piface.h:
extern "C" {
<existing piface.h body>
}
The Pi Face emulator and the Python shell both crash when trying to initialise the emulator interactively.
$ python
>>> import piface.emulator as emulator
>>> emulator.init()
>>>
The emulator pops up but it doesn't respond to user input, same with the shell.
This works though:
$ python -c "import piface.emulator as emulator;
from time import sleep
emulator.init();
led1 = emulator.LED(1);
led1.turn_on();
sleep(2);
led1.turn_off()"
I think this has something to do with the threaded nature of emulator and the Python shell not liking it.
It should be explicitly stated in the README that Python 2 is required and not Python 3.
For example, on Arch Linux (where python
means Python 3 python2
means Python 2), it is
sudo python2 setup.py install
and not
sudo python setup.py install
I received my piface today and used this README to get it going. Thanks. FYI, I only run my RPi as a server (no screen or keyboard attached) via ssh and only had to do the following to get the python interface working:
sudo apt-get install python-dev git
git clone https://github.com/thomasmacpherson/piface.git
cd piface/python
sudo python setup.py install
sudo ../scripts/spidev-setup (so I could use spidev as user pi, not root).
All good, except that I also need to disable the "blacklist spi-bc2708" line in /etc/modprobe.d/raspi-blacklist.conf by commenting it out. This should be added to the README.md (and why would the Raspbian people disable the spi module from loading? - Perhaps query them to change it?)
Another minor comment is that a new user needs a schematic for input/output numbering, jumpers, etc. It seems the pifacedigitaldatasheet.pdf document referenced from here is intended for this but it is for the old piface board. I found an updated document at http://www.farnell.com/datasheets/1684425.pdf which should perhaps be referenced?
I could not use the python test script because it assumes a gtk environment.
I've just setup my PiFace and it works on Python. I'm trying to get it to work on C too however once I follow your instructions I get an error:
./piface_program: error while loading shared libraries: libpiface-1.0.so.0: cannot open shared object file: No such file or directory
Any ideas why?
I am trying to use Piface C libraries with Ruby FFI + piface ruby gems, and SiriProxy.
I had the add the following symbolic link to the /usr/local/lib
folder to get them all to play nice together.
ln -s libpiface-1.0.so.0.0.0 libpiface-1.0
/usr/local/rvm/gems/ruby-2.0.0-p0/gems/ffi-1.7.0.dev/lib/ffi/library.rb:123:in block in ffi_lib': Could not open library 'libpiface': libpiface: cannot open shared object file: No such file or directory. (LoadError) Could not open library 'libpiface.so': libpiface.so: cannot open shared object file: No such file or directory. Could not open library 'libpiface-1.0': libpiface-1.0: cannot open shared object file: No such file or directory. Could not open library 'libpiface-1.0.so': libpiface-1.0.so: cannot open shared object file: No such file or directory. Could not open library 'libpiface-1.0.so.1': libpiface-1.0.so.1: cannot open shared object file: No such file or directory. Could not open library '/usr/local/lib/libpiface-1.0': /usr/local/lib/libpiface-1.0: cannot open shared object file: No such file or directory from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/ffi-1.7.0.dev/lib/ffi/library.rb:90:in
map'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/ffi-1.7.0.dev/lib/ffi/library.rb:90:in ffi_lib' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/piface-0.3.0/lib/piface/native.rb:6:in
module:Native'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/piface-0.3.0/lib/piface/native.rb:4:in <module:Piface>' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/piface-0.3.0/lib/piface/native.rb:3:in
<top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/piface-0.3.0/lib/piface.rb:2:in require' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/piface-0.3.0/lib/piface.rb:2:in
<top (required)>'
from /root/plugins/siriproxy-piface/lib/siriproxy-piface.rb:1:in require' from /root/plugins/siriproxy-piface/lib/siriproxy-piface.rb:1:in
<top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/lib/siriproxy/plugin_manager.rb:23:in require' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/lib/siriproxy/plugin_manager.rb:23:in
block in load_plugins'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/lib/siriproxy/plugin_manager.rb:14:in each' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/lib/siriproxy/plugin_manager.rb:14:in
load_plugins'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/lib/siriproxy/plugin_manager.rb:8:in initialize' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/lib/siriproxy/command_line.rb:230:in
new'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/lib/siriproxy/command_line.rb:230:in init_plugins' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/lib/siriproxy/command_line.rb:89:in
run_server'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/lib/siriproxy/command_line.rb:39:in initialize' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/bin/siriproxy:6:in
new'
from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/bin/siriproxy:6:in <top (required)>' from /usr/local/rvm/gems/ruby-2.0.0-p0/bin/siriproxy:23:in
load'
from /usr/local/rvm/gems/ruby-2.0.0-p0/bin/siriproxy:23:in `
I have one of the relays on the piface running a fan. The script that controls the fan checks a temperature sensor and turns on the fan when the temperature is high. This script runs every fifteen seconds using cron. The fan is interrupted (turned off for a brief second) every time the script is run. I am thinking that the init() is the culprit but am not sure. I suppose I could have the script run at startup instead of using cron. Can anyone shed any light on this?
Compiling the current C implementation gives:
phil@philbox ~/piface/c/src/piface $ make
gcc -Wall -c -o pfio.o pfio.c
pfio.c: In function ‘pfio_init’:
pfio.c:65:5: warning: pointer targets in passing argument 1 of ‘snprintf’ differ in signedness [-Wpointer-sign]
/usr/include/stdio.h:387:12: note: expected ‘char * __restrict__’ but argument is of type ‘uint8_t *’
pfio.c:72:5: warning: pointer targets in passing argument 1 of ‘open’ differ in signedness [-Wpointer-sign]
/usr/include/fcntl.h:119:12: note: expected ‘const char *’ but argument is of type ‘uint8_t *’
Possible solution: Changing line 64 from
uint8_t path[MAXPATH];
into
char path[MAXPATH];
Or is there a special reason for making the string elements of type uint8_t?
Thank's for your help!
Philipp
Pi Face detection currently works on checking if the SPI bus exists in /dev/. If it doesn't then the Pi Face doesn't exist, if it does then the Pi Face exists. Even if it isn't plugged in.
What should happen is that emulator should make a request to the Pi Face over the SPI bus requesting a version string from the microchip (MCP17S23). I can't find a data sheet on this though so I don't know what command to send.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.