Commit 9bace7cb authored by claes's avatar claes

IO PiFace Digital for Raspberry Pi added

parent b507ffc0
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include ../../special.mk
-include ../special.mk
-include special.mk
/*
Dummy for piface
*/
#include <stdint.h>
int pfio_init(void) { return 1;}
int pfio_deinit(void) {return 1;}
uint8_t pfio_digital_read(uint8_t pin_number) {return 0;}
void pfio_digital_write(uint8_t pin_number, uint8_t value) {}
uint8_t pfio_read_input(void) {return 0;}
uint8_t pfio_read_output(void) {return 0;}
void pfio_write_output(uint8_t value) {}
uint8_t pfio_get_pin_bit_mask(uint8_t pin_number) {return 0;}
uint8_t pfio_get_pin_number(uint8_t bit_mask) {return 0;}
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2014 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/* rt_io_m_piface_digital.c -- I/O methods for class PiFace_Digital. */
#include "pwr.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_otherioclasses.h"
#include "co_time.h"
#include "rt_io_base.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_read.h"
#include "rt_io_card_write.h"
#include "rt_io_msg.h"
#if defined PWRE_CONF_LIBPIFACE && PWRE_CONF_PIFACE
#include <libpiface-1.0/pfio.h>
typedef struct {
pwr_tStatus sts;
} io_sLocal_PiFace;
static pwr_tStatus IoCardInit( io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp)
{
io_sLocal_PiFace *local;
pwr_sClass_PiFace_Digital *op = (pwr_sClass_PiFace_Digital *)cp->op;
local = (io_sLocal_PiFace *) calloc( 1, sizeof(io_sLocal_PiFace));
cp->Local = local;
local->sts = pfio_init();
if ( local->sts != 0) {
op->Status = IO__INITFAIL;
return op->Status;
}
errh_Info( "Init of PiFace Digital '%s'", cp->Name);
op->Status = IO__SUCCESS;
return IO__SUCCESS;
}
static pwr_tStatus IoCardClose( io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp)
{
io_sLocal_PiFace *local = (io_sLocal_PiFace *)cp->Local;
if ( local->sts == 0)
pfio_deinit();
if ( cp->Local)
free( cp->Local);
return IO__SUCCESS;
}
static pwr_tStatus IoCardRead( io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp)
{
io_sLocal_PiFace *local = (io_sLocal_PiFace *)cp->Local;
uint8_t value;
uint8_t m;
int i;
if ( local->sts != 0)
return 0;
// Handle Di
value = pfio_read_input();
m = 1;
for ( i = 0; i < 8; i++) {
if ( cp->chanlist[i].sop)
*(pwr_tBoolean *)cp->chanlist[i].vbp = ((value & m) != 0);
m = m << 1;
}
return IO__SUCCESS;
}
static pwr_tStatus IoCardWrite( io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp)
{
io_sLocal_PiFace *local = (io_sLocal_PiFace *)cp->Local;
uint8_t value;
uint8_t m;
int i;
if ( local->sts != 0)
return 0;
// Handle Do
m = 1;
for ( i = 0; i < 8; i++) {
if ( cp->chanlist[i+8].sop) {
if ( *(pwr_tBoolean *)cp->chanlist[i+8].vbp)
value |= m;
}
m = m << 1;
}
pfio_write_output(value);
return IO__SUCCESS;
}
#else
static pwr_tStatus IoCardInit( io_tCtx ctx,io_sAgent *ap,io_sRack *rp,io_sCard *cp) {return IO__RELEASEBUILD;}
static pwr_tStatus IoCardClose( io_tCtx ctx,io_sAgent *ap,io_sRack *rp,io_sCard *cp) {return IO__RELEASEBUILD;}
static pwr_tStatus IoCardRead( io_tCtx ctx,io_sAgent *ap,io_sRack *rp,io_sCard *cp) {return IO__RELEASEBUILD;}
static pwr_tStatus IoCardWrite( io_tCtx ctx,io_sAgent *ap,io_sRack *rp,io_sCard *cp) {return IO__RELEASEBUILD;}
#endif
/* Every method should be registred here. */
pwr_dExport pwr_BindIoMethods(PiFace_Digital) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardWrite),
pwr_NullMethod
};
......@@ -32,4 +32,5 @@ Epl_MN
Epl_Module
Epl_CNServer
Epl_CNServerModule
PiFace_Digital
#endif
\ No newline at end of file
Volume OtherIO $ClassVolume 0.0.250.10
Body SysBody 01-JAN-1970 01:00:00.00
Attr NextOix = "_X609"
Attr NextCix = "_X45"
Attr NextOix = "_X620"
Attr NextCix = "_X46"
Attr NextTix[0] = "_X17"
EndBody
Object Type $TypeHier 1 15-NOV-2007 14:35:37.90
......@@ -8562,23 +8562,23 @@ Volume OtherIO $ClassVolume 0.0.250.10
! @Author je
! @Creator Jack E, Sixten I
! @Summary Ethernet Powerlink Module
!
!
! The Powerlink module object configures a module in Controlled Node (CN).
!
!
! The Epl_Module object is placed as a child to a Epl_CN object. It can have
! channel objects as children, defining the input and output area for the module,
! but the channels can also be internal attributes in the module object. In this
! case a subclass to the Epl_Module class is created containing the channels.
!
!
! @b Example Epl_Module settings
!
!
! @image orm_otherio_epl_example5.png
!
!
! @b Example Module with channels
!
!
! @image orm_otherio_epl_example4.png
!
!
!
!
! @b See also
! @classlink Epl_MN otherio_epl_mn.html
! @classlink Epl_CN otherio_epl_cn.html
......@@ -8704,26 +8704,26 @@ Volume OtherIO $ClassVolume 0.0.250.10
! the Epl_CN.
!
! See class Epl_MN fore more information about the Powerlink configuration.
!
!
! You will also find a case study in the documentation for object ABB_ACS880_Epl
! and B&R I/O X20 system object BR_PowerSupply_EplModule.
!
!
! @b Example CN settings
!
!
! @image orm_otherio_epl_example7.png
!
!
!
! @b Example Configuration of ABB_ACS880_Epl
!
!
! The figure below shows an example with an ABB ACS880 frequency converter.
! Below the Epl_CN object a special EPL module object is used containing
! the channels in the Io attribute of class ABB_ACS880_Epl_IoModule.
!
!
! @image orm_abb_acs880_epl_example1.gif
!
!
! The Epl_CN object is used when Proview act as a managing node. In circuits where
! Proview acts as a controlled node the Epl_CNServer object is used instead.
!
!
! @b See also
! @classlink EplHandler otherio_eplhandler.html
! @classlink Epl_MN otherio_epl_mn.html
......@@ -8903,7 +8903,7 @@ Volume OtherIO $ClassVolume 0.0.250.10
! in the openCONFIGURATOR. The openCONFIGURATOR imports xdd and xdc files provided
! by the CN vendors, and will generate a cdc-file that is used by the Powerlink
! stack to initiate the communication.
!
!
! @h1 Configuration
! Before the use of a Powerlink agent object a configuration
! file must be created (cdc-file).
......@@ -8932,14 +8932,14 @@ Volume OtherIO $ClassVolume 0.0.250.10
! The NodeId is always 240 for a Powerlink MN. The address range
! 1-239 is used for CN. The address of a CN is specified in the
! openCONFIGURATOR.
!
!
! Epl_MN object also requires configuration of an EplHandler object, see
! figure below.
!
!
! @b Example Epl_MN settings
!
!
! @image orm_otherio_epl_example3.png
!
!
! @b Example 1
!
! A basic configuration with the Proview managing node configured with an
......@@ -8962,16 +8962,16 @@ Volume OtherIO $ClassVolume 0.0.250.10
! ChanAo
!
! @b Example 2
!
!
! This is an example with an ABB ACS880 frequency converter.
! Note that the channels are contained in the Io attribute
! of the module object M1.
!
! @b The result will be like this three class object
!
!
! @image orm_otherio_epl_example2.png
!
!
!
!
! @h1 Case study Powerlink tool openCONFIGURATOR
! openCONFIGURATOR is an open source tool contributed by www.Kalycito.com.
! openCONFIGURATION is used for easy setup, configuration and maintenance
......@@ -8981,13 +8981,13 @@ Volume OtherIO $ClassVolume 0.0.250.10
! Every node in a Powerlink network must be configure through this tool.
! In a Proview project all Powerlink CN nodes is a reflection of this memory
! mapping.
!
!
! @image orm_otherio_epl_example1.png
!
!
! @bThe Case
! The case study is found in class help for object ABB_ACS880_Epl, see this
! class for more information.
!
!
! @b See also
! @classlink EplHandler otherio_eplhandler.html
! @classlink Epl_CN otherio_epl_cn.html
......@@ -9310,31 +9310,31 @@ Volume OtherIO $ClassVolume 0.0.250.10
!
! The Epl_CNServer object configures Powerlink when the Proview system acts
! as a controlled node (CN).
!
!
! @h1 Configuration
! The Epl_CNServer object is placed in the node hierarchy under the node object.
!
!
! The CNServer object requires that the powerlink process is configured with an
! EplHandler object, see example 1.
!
!
! @b Example 1, Epl_CNServer settings
! Shows network device and CN node NodeId number (14) etc.
!
!
!
!
! @image orm_otherio_epl_example8.png
!
!
!
!
! The Server object needs also a Epl_ServerModule object as a child, and
! under Epl_ServerModule object, channel objects are configured. The channel
! objects reflect the IO mapping between the CN and MN nodes, see example 2.
!
!
! @b Example 2, CN and Module with channels
! Shows IO channels i.e. the IO interface. The meaning of name bit8, int32 etc.
! are the setting for attribute "Representation" and nb0, nb1 etc. is the attribute
! "Number" setting.
!
!
! @image orm_otherio_epl_example6.png
!
!
! @h1 Powerlink Configuration in openCONFIGURATOR
! When the configuration is finished, it is possible to create an xdd-file from
! "GenerateXttFile" in the popup menu for the Epl_CNServer object. The name and
......@@ -9342,57 +9342,57 @@ Volume OtherIO $ClassVolume 0.0.250.10
! used when configuring the Powerlink circuit for the MN. See also class Epl_MN
! for more information about openCONFIGURATOR xdd/xdc files and how to create a
! cdc-file for a Powerlink configuration.
!
!
!
!
! @image orm_otherio_epl_example10.png
! @b Fig Generate an xdd file
!
!
!
!
! @b openCONFIGURATOR
! Example 3 to 5 below shows screenshots from openConfigurator tool and the influence
! the imported xdd file from Proview have on the IO mapping.
!
!
! The xdd file is generated with the same settings as in example 2 i.e. nine digital
! inputs divided in two bytes, two analog inputs, two digital outputs and three analog
! outputs.
!
!
! Note the digital bit settings in ChanDi and ChanDo attribute "Number" is important
! for a correctly generated xdd file. In the example 2 the number is named nb0, nb1
! nb3 etc. Attribute "Representation" reflect the byte/word length of the channel.
!
!
! In the example below the CN node (Epl_CNServer) has id number 14.
!
! @b Example 3
! RPDO memory mapping in openCONFIGURATOR based on the xdd file generated from Proview.
! The MN receives data from CN that are outputs in Proview CNServer (Do00, Do01, Ao00,
! Ao01 and Ao04 in that order, see example 2)
!
!
! @image orm_otherio_epl_example11.png
!
!
!
!
! @b Example 4, TPDO memory mapping in openCONFIGURATOR
! @b based on xdd file generated from Proview.
! MN node transmit data to CN node, inputs in Proview CNServer
! (Di00 to Di09, Ai04 and Ai00 in that order, see example 2)
!
!
! @image orm_otherio_epl_example12.png
!
!
!
!
! @b Example 5, Structfile xap.h autogenerated by openCONFIGURATOR tool
! If you compare your node hierarchy (example 2) with the xap.h file, they
! should match.
!
!
! openCONFIGURATOR will align 16 bit words on 16 bit bounary, and 32 bit words
! on 32 bit boundary. The Proview channels will automatically be aligned in
! this way and there is no need for padding.
!
!
! The example 2 over is an example of a node hierarchy that matches the
! xap.h file below. Note that no padding variables are inserted in the
! node hierarchy in example 2. Note also that input is output and output
! is input in CN slave node.
!
!
! @image orm_otherio_epl_example13.png
!
!
! @b See also
! @classlink EplHandler otherio_eplhandler.html
! @classlink Epl_CNServerModule otherio_epl_cnservermodule.html
......@@ -9692,19 +9692,19 @@ Volume OtherIO $ClassVolume 0.0.250.10
! @Summary Ethernet Powerlink Server Module
!
! The server module configures a CN module where Proview acts as a CN.
!
!
! The Epl_CnServerModule object is placed as a child to an Epl_CNServer
! object and is the father of channel objects that defines the input and
! output areas for the module.
!
!
! @b Example Epl_CNServerModule settings
!
!
! @image orm_otherio_epl_example9.png
!
!
! @b Example CN Server and Module with channels
!
!
! @image orm_otherio_epl_example6.png
!
!
! @b See also
! @classlink EplHandler otherio_eplhandler.html
! @classlink Epl_CNServer otherio_epl_cnserver.html
......@@ -9827,18 +9827,18 @@ Volume OtherIO $ClassVolume 0.0.250.10
!
! The Ethernet Powerlink handler object configures the process rt_powerlink
! running the Powerlink stack and handling the Powerlink IO.
!
!
! Any Powerlink configuration, with Proview as managing node or controlled node,
! requires that the EplHandler object is created and configured.
!
! @b Example Powerlink handler with Proview as managing node
!
!
! @image orm_otherio_epl_example3.png
!
!
! @b Example Powerlink handler with Proview as controlled node
!
!
! @image orm_otherio_epl_example8.png
!
!
! @b See also
! @classlink Epl_CNServer otherio_epl_cnserver.html
! @classlink Epl_CnServerModule otherio_epl_cnservermodule.html
......@@ -9874,5 +9874,126 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndBody
EndObject
EndObject
Object PiFace_Digital $ClassDef 45 22-FEB-2014 13:36:57.56
Body SysBody 22-FEB-2014 12:13:41.82
Attr Editor = 0
Attr Method = 0
Attr Flags = 18512
EndBody
Object RtBody $ObjBodyDef 1 22-FEB-2014 12:13:13.58
Body SysBody 22-FEB-2014 13:37:10.90
Attr StructName = "PiFace_Digital"
Attr NextAix = "_X22"
EndBody
Object Description $Attribute 15 22-FEB-2014 12:13:13.58
Body SysBody 22-FEB-2014 12:13:13.58
Attr PgmName = "Description"
Attr Size = 80
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object Process $Attribute 16 22-FEB-2014 12:13:13.58
Body SysBody 22-FEB-2014 12:13:13.58
Attr PgmName = "Process"
Attr Size = 4
Attr TypeRef = "pwrb:Type-IoProcessMask"
EndBody
EndObject
Object ThreadObject $Attribute 17 22-FEB-2014 12:13:13.58
Body SysBody 22-FEB-2014 12:13:13.58
Attr PgmName = "ThreadObject"
Attr Size = 8
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
Object Status $Attribute 18 22-FEB-2014 12:13:13.58
Body SysBody 22-FEB-2014 12:13:13.58
Attr PgmName = "Status"
Attr Size = 4
Attr TypeRef = "pwrs:Type-$Status"
EndBody
EndObject
Object ScanInterval $Attribute 19 22-FEB-2014 12:13:13.58
Body SysBody 22-FEB-2014 12:13:13.58
Attr PgmName = "ScanInterval"
Attr Size = 4
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
Object ChDi $Attribute 20 22-FEB-2014 12:17:16.33
Body SysBody 22-FEB-2014 12:17:47.35
Attr PgmName = "ChDi"
Attr Size = 1280
Attr Flags = 131074
Attr Elements = 8
Attr TypeRef = "pwrb:Class-ChanDi"
EndBody
EndObject
Object ChDo $Attribute 21 22-FEB-2014 12:18:02.37
Body SysBody 22-FEB-2014 12:18:10.93
Attr PgmName = "ChDo"
Attr Size = 1344
Attr Flags = 131074
Attr Elements = 8
Attr TypeRef = "pwrb:Class-ChanDo"
EndBody
EndObject
EndObject
Object ConfiguratorPoson $Menu 617 22-FEB-2014 16:16:47.72
Object Pointed $Menu 618 22-FEB-2014 16:16:47.72
Object Connect $MenuButton 619 22-FEB-2014 16:16:47.72
Body SysBody 22-FEB-2014 16:16:47.72
Attr ButtonName = "Connect PlcThread"
Attr MethodName = "$Objid-Connect"
Attr MethodArguments[0] = "ThreadObject"
Attr MethodArguments[1] = "PlcThread"
Attr FilterName = "$Objid-IsOkConnect"
Attr FilterArguments[0] = "ThreadObject"
Attr FilterArguments[1] = "PlcThread"
EndBody
EndObject
EndObject
EndObject
Object PostCreate $DbCallBack 620 22-FEB-2014 17:37:35.19
Body SysBody 22-FEB-2014 17:37:35.19
Attr MethodName = "BaseIOCard-PostCreate"
EndBody
EndObject
Object IoMethods $RtMethod 610 22-FEB-2014 12:13:13.58
Object IoCardInit $Method 611 22-FEB-2014 12:13:13.58
Body SysBody 22-FEB-2014 13:37:20.15
Attr MethodName = "PiFace_Digital-IoCardInit"
EndBody
EndObject
Object IoCardClose $Method 612 22-FEB-2014 12:13:13.58
Body SysBody 22-FEB-2014 13:37:27.40
Attr MethodName = "PiFace_Digital-IoCardClose"
EndBody
EndObject
Object IoCardRead $Method 613 22-FEB-2014 12:13:13.58
Body SysBody 22-FEB-2014 13:37:33.94
Attr MethodName = "PiFace_Digital-IoCardRead"
EndBody
EndObject
Object IoCardWrite $Method 614 22-FEB-2014 12:13:13.58
Body SysBody 22-FEB-2014 13:37:41.49
Attr MethodName = "PiFace_Digital-IoCardWrite"
EndBody
EndObject
EndObject
Object Template PiFace_Digital 2159509504 01-JAN-1970 00:00:00.00
Body RtBody 22-FEB-2014 12:19:11.93
Attr Process = 2
Attr ChDi[0].ConversionOn = 1
Attr ChDi[1].ConversionOn = 1
Attr ChDi[2].ConversionOn = 1
Attr ChDi[3].ConversionOn = 1
Attr ChDi[4].ConversionOn = 1
Attr ChDi[5].ConversionOn = 1
Attr ChDi[6].ConversionOn = 1
Attr ChDi[7].ConversionOn = 1
EndBody
EndObject
EndObject
EndObject
EndVolume
......@@ -167,6 +167,8 @@ pwre_config_check_lib()
conf_libpnak=$conf_libpnak" -l${lib%.*}"
elif test $4 == "libusb"; then
conf_lib=$conf_lib" -lusb-1.0"
elif test $4 == "libpiface"; then
conf_lib=$conf_lib" -lpiface-1.0"
elif test $4 == "powerlink"; then
conf_libpowerlink=$conf_libpowerlink" -L$lib_path -l${lib%.*}"
elif test $4 == "powerlinkcn"; then
......@@ -456,8 +458,12 @@ else
pwre_config_check_lib libusb LIBUSB lib libusb 1 "/usr/lib/libusb-1.0.so:/usr/lib/$hwpl-linux-$gnu/libusb-1.0.so"
pwre_config_check_lib powerlink POWERLINK lib powerlink 1 "$epl/build/Examples/X86/Generic/powerlink_user_lib/libpowerlink.a"
pwre_config_check_lib powerlinkcn POWERLINKCN lib powerlinkcn 1 "$epl/buildcn/Examples/X86/Generic/powerlink_user_lib/libpowerlink.a"
pwre_config_check_lib libpcap LIBPCAP lib libpcap 1 "/usr/lib/libpcap.so:/usr/lib/$hwpl-linux-$gnu/libpcap.so"
pwre_config_check_lib libpcap LIBPCAP lib libpcap 1 "/usr/lib/libpcap.so:/usr/lib/$hwpl-linux-$gnu/libpcap.so"
pwre_config_check_lib librsvg LIBRSVG lib librsvg 1 "/usr/lib/librsvg-2.so:/usr/lib/$hwpl-linux-$gnu/librsvg-2.so"
if [ $pwre_hw == "hw_arm" ]; then
pwre_config_check_lib libpiface LIBPIFACE lib libpiface 1 "/usr/local/lib/libpiface-1.0.a"
pwre_config_check_include piface PIFACE 1 "/usr/local/include/libpiface-1.0/pfio.h"
fi
pwre_config_check_include mq MQ 0 "/usr/local/dmq/include/p_entry.h"
pwre_config_check_include wmq WMQ 1 "/opt/mqm/inc/cmqc.h"
......
......@@ -184,7 +184,7 @@ CompileRtNode()
ld_opt_tmp="`cat $pwrp_exe/$FileName.opt`"
ld_opt="`eval echo $ld_opt_tmp`"
else
ld_opt="`eval echo $pwrobj/rt_io_user.o -lpwr_rt -lpwr_usbio_dummy -lpwr_usb_dummy -lpwr_pnak_dummy -lpwr_cifx_dummy`"
ld_opt="`eval echo $pwrobj/rt_io_user.o -lpwr_rt -lpwr_usbio_dummy -lpwr_usb_dummy -lpwr_pnak_dummy -lpwr_cifx_dummy -lpwr_piface_dummy`"
fi
if $ldxx $link_debug -L/lib/thread -L$pwrp_lib -L$pwrp_cmn/arm_linux/lib -L$pwrlib \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment