Skip to content

Commit

Permalink
Bump to 4.0.1 + doc piface digital
Browse files Browse the repository at this point in the history
  • Loading branch information
xaqq committed Dec 22, 2014
1 parent 0305738 commit fa929b5
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 101 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ endif()

add_definitions(-DLEOSAC_VERSION_MAJOR=0)
add_definitions(-DLEOSAC_VERSION_MINOR=4)
add_definitions(-DLEOSAC_VERSION_PATCH=0)
add_definitions(-DLEOSAC_VERSION_PATCH=1)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LEOSAC_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LEOSAC_BINARY_DIR})
Expand Down Expand Up @@ -73,4 +73,4 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/build_ipconfig.sh
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/load_ipconfig.sh
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
DESTINATION scripts
)
)
6 changes: 4 additions & 2 deletions deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function clone()
{
git clone https://github.com/islog/leosac.git
pushd leosac
git checkout master;
git submodule init;
git submodule update;
popd
Expand All @@ -45,6 +46,7 @@ cd $name
#copy existing pkg/debian directory (maintained in repos, with patches)
cp -R pkg/debian .

export DEB_BUILD_OPTIONS="parallel=3"
if [ -z ${DEB_BUILD_OPTIONS} ] ; then
export DEB_BUILD_OPTIONS="parallel=3"
fi
debuild -us -uc

6 changes: 6 additions & 0 deletions pkg/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
leosac (0.4.1-1) UNRELEASED; urgency=medium

* Fix package dependecies

-- <xaqq@atlantis.islog.private> Mon, 22 Dec 2014 15:11:41 +0100

leosac (0.4.0-1) UNRELEASED; urgency=medium

* More stable.
Expand Down
2 changes: 1 addition & 1 deletion pkg/debian/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: leosac
Maintainer: Thibault Schueller <ryp.sqrt@gmail.com>
Maintainer: Arnaud Kapp <kapp.arno@gmail.com>
Section: misc
Priority: optional
Standards-Version: 3.9.2
Expand Down
17 changes: 3 additions & 14 deletions src/modules/pifacedigital/PFDigitalModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
#include "exception/gpioexception.hpp"
#include "tools/log.hpp"

using namespace Leosac::Module::Piface;

PFDigitalModule::PFDigitalModule(const boost::property_tree::ptree &config,
zmqpp::socket *module_manager_pipe,
zmqpp::context &ctx) :
pipe_(*module_manager_pipe),
config_(config),
is_running_(true),
ctx_(ctx),
BaseModule(ctx, module_manager_pipe, config),
bus_push_(ctx_, zmqpp::socket_type::push)
{
if (pifacedigital_open(0) == -1)
Expand All @@ -28,7 +27,6 @@ PFDigitalModule::PFDigitalModule(const boost::property_tree::ptree &config,
{
reactor_.add(gpio.sock_, std::bind(&PFDigitalPin::handle_message, &gpio));
}
reactor_.add(pipe_, std::bind(&PFDigitalModule::handle_pipe, this));

std::string path_to_gpio = "/sys/class/gpio/gpio" + std::to_string(GPIO_INTERRUPT_PIN) + "/value";
interrupt_fd_ = open(path_to_gpio.c_str(), O_RDONLY | O_NONBLOCK);
Expand Down Expand Up @@ -67,15 +65,6 @@ void PFDigitalModule::run()
}
}

void PFDigitalModule::handle_pipe()
{
zmqpp::signal s;

pipe_.receive(s, true);
if (s == zmqpp::signal::stop)
is_running_ = false;
}

void PFDigitalModule::handle_interrupt()
{
// get interrupt state.
Expand Down
142 changes: 61 additions & 81 deletions src/modules/pifacedigital/PFDigitalModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,97 +3,77 @@
#include <zmqpp/socket.hpp>
#include <boost/property_tree/ptree.hpp>
#include <zmqpp/reactor.hpp>
#include <modules/BaseModule.hpp>
#include "PFDigitalPin.hpp"

/**
* Application-level controller for the PiFaceDigital I/O extender cards: it provides support of
* GPIO object.
*
* It implements the *GPIO command set* described in the specifications of the facade object (FGPIO).
*
* Specifications of configuration informations:
* 1. A `<gpios>` entities defines all the GPIO you wish to export.
* 2. Each `<gpio>` entities define one GPIO pin.
* 3. `<name>` defines the application-name of the GPIO. The object shall be available through this name
* and it shall use this name to publish message on the message bus.
* 4. `<no>` defines the number of the GPIO pin. It must be between 0 and 7.
* 5. `<direction>` defines whether this an INPUT or OUTPUT pin. It must be either `in` or `out`.
* 6. `<value>` defines the initial value. This is applicable only for OUTPUT pin.
*
* @note `<name>`, `<no>` and `<direction>` are mandatory configuration information.
* `<value>` is optional and default to `0`.
*
* @note Pin number if shared by input and outputs pin. Both use 0-7. This is important when writing configuration file.
* @see FGPIO for the GPIO command set specifications.
* @see PFDigitalPin for the helper class that is used by this module.
*/
class PFDigitalModule
namespace Leosac
{
public:
PFDigitalModule(const boost::property_tree::ptree &config,
zmqpp::socket *module_manager_pipe,
zmqpp::context &ctx);
namespace Module
{
/**
* Provide support for the piface digital device.
*
* @see @ref mod_piface_main for documentation
*/
namespace Piface
{
/**
* Main class for the piface digital module.
*/
class PFDigitalModule : public BaseModule
{
public:
PFDigitalModule(const boost::property_tree::ptree &config,
zmqpp::socket *module_manager_pipe,
zmqpp::context &ctx);

/**
* Module's main loop.
*/
void run();
/**
* Module's main loop.
*/
virtual void run() override;

private:
zmqpp::socket &pipe_;
boost::property_tree::ptree config_;
private:

zmqpp::reactor reactor_;
/**
* An interrupt was triggered. Lets handle it.
*/
void handle_interrupt();

bool is_running_;
/**
* Process the configuration, preparing configured GPIO pin.
*/
void process_config(const boost::property_tree::ptree &cfg);

/**
* Handle message coming from the pipe.
* This is basically handle the stop signal from the module manager.
*/
void handle_pipe();
/**
* Compute the poll timeout (in milliseconds) and returns it.
* This timeout is calculated by calling `next_update()` on the available GPIO.
*/
int compute_timeout();

/**
* An interrupt was triggered. Lets handle it.
*/
void handle_interrupt();
/**
* Socket to push event to the bus.
*/
zmqpp::socket bus_push_;

/**
* Process the configuration, preparing configured GPIO pin.
*/
void process_config(const boost::property_tree::ptree &cfg);
/**
* GPIO vector
*/
std::vector<PFDigitalPin> gpios_;

/**
* Compute the poll timeout (in milliseconds) and returns it.
* This timeout is calculated by calling `next_update()` on the available GPIO.
*/
int compute_timeout();
/**
* Should be removed someday...
* store the name of the input pin with id = idx in dest.
*
* returns true if it was succesful (pin exists), false otherwise.
*/
bool get_input_pin_name(std::string &dest, int idx);

/**
* A reference to our ZeroMQ context.
*/
zmqpp::context &ctx_;
/**
* File descriptor of the PIN that triggers interrupts. This is card and will not change.
*/
int interrupt_fd_;
};

/**
* Socket to push event to the bus.
*/
zmqpp::socket bus_push_;

/**
* GPIO vector
*/
std::vector <PFDigitalPin> gpios_;

/**
* Should be removed someday...
* store the name of the input pin with id = idx in dest.
*
* returns true if it was succesful (pin exists), false otherwise.
*/
bool get_input_pin_name(std::string &dest, int idx);

/**
* File descriptor of the PIN that triggers interrupts. This is card and will not change.
*/
int interrupt_fd_;
};
}
}
}
2 changes: 1 addition & 1 deletion src/modules/pifacedigital/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern "C" __attribute__((visibility("default"))) bool start_module(zmqpp::socke
boost::property_tree::ptree cfg,
zmqpp::context &zmq_ctx)
{
PFDigitalModule module(cfg, pipe, zmq_ctx);
Leosac::Module::Piface::PFDigitalModule module(cfg, pipe, zmq_ctx);

INFO("Module PFDigital initiliazed.");
pipe->send(zmqpp::signal::ok);
Expand Down
68 changes: 68 additions & 0 deletions src/modules/pifacedigital/piface.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
PifaceDigital Module Documentation {#mod_piface_main}
============================================

[TOC]

Introduction {#mod_piface_intro}
=================================

Documentation for the PifaceDigital module.
This provide support for using the PifaceDigital device with Leosac, as a GPIO controller.
This can be very handy because it eases wiring.

Configuration Options {#mod_piface_user_config}
================================================

See below for various configuration options.


Options | Options | Options | Description | Mandatory
-----------|-----------|------------------------|--------------------------------------------------------|-----------
gpios | | | GPIOS definitions | YES
----> | name | | A name for the GPIO device | YES
----> | no | | The GPIO number of the piface. Range from 0 to 7 | YES
----> | direction | | Direction of the PIN. in or out | YES
----> | value | | Only for out PIN. The default value of the PIN | YES

Notes:
+ `value` is a boolean. It's only for output GPIO and represents the default value.


Example {#mod_piface_example}
------------------------------


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.xml
<module>
<name>PIFACE-GPIO</name>
<file>libpifacedigital.so</file>
<level>2</level>
<module_config>
<gpios>
<gpio>
<name>wiegand_green</name>
<no>3</no>
<direction>out</direction>
<value>false</value>
</gpio>
<gpio>
<name>wiegand_buzzer</name>
<no>2</no>
<direction>out</direction>
<value>false</value>
</gpio>
<!-- Prepare GPIO for our Wiegand reader -->
<gpio>
<name>wiegand_data_high</name>
<no>1</no>
<direction>in</direction>
</gpio>
<gpio>
<name>wiegand_data_low</name>
<no>0</no>
<direction>in</direction>
</gpio>
</gpios>
</module_config>
</module>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 comments on commit fa929b5

Please sign in to comment.