[OSADL-svn-commits] r113 - in branches: . fddi-mapping fddi-mapping/busconfig fddi-mapping/busconfig/3S fddi-mapping/busconfig/Pengutronix fddi-mapping/busconfig/misc fddi-mapping/config fddi-mapping/config/m4 fddi-mapping/doc fddi-mapping/include fddi-mapping/include/osadl fddi-mapping/include/osadl/attic fddi-mapping/src fddi-mapping/tests
OSADL repository commits
osadl-svn-commits at lists.osadl.org
Tue Oct 2 16:30:06 CEST 2007
Author: robert
Date: Tue Oct 2 16:30:06 2007
New Revision: 113
Log:
* mapping branch: re-added
Added:
branches/
branches/fddi-mapping/
branches/fddi-mapping/AUTHORS
branches/fddi-mapping/COPYING
branches/fddi-mapping/ChangeLog
branches/fddi-mapping/GNUmakefile.am
branches/fddi-mapping/README
branches/fddi-mapping/TODO
branches/fddi-mapping/autogen.sh (contents, props changed)
branches/fddi-mapping/busconfig/
branches/fddi-mapping/busconfig/3S/
branches/fddi-mapping/busconfig/3S/ModBusConfigExample.xml
branches/fddi-mapping/busconfig/3S/fddiconfig.xsd
branches/fddi-mapping/busconfig/Pengutronix/
branches/fddi-mapping/busconfig/Pengutronix/can-example.xml
branches/fddi-mapping/busconfig/Pengutronix/modbus-example.xml
branches/fddi-mapping/busconfig/misc/
branches/fddi-mapping/busconfig/misc/pretty.xsl
branches/fddi-mapping/config/
branches/fddi-mapping/config/GNUmakefile.am
branches/fddi-mapping/config/libfddi.pc.in
branches/fddi-mapping/config/m4/
branches/fddi-mapping/config/m4/.secret-world-domination-project
branches/fddi-mapping/config/m4/acx_pthread.m4
branches/fddi-mapping/configure.ac
branches/fddi-mapping/doc/
branches/fddi-mapping/doc/GNUmakefile.am
branches/fddi-mapping/doc/OSADL-FieldbusFramework-20070809-1.docbook
branches/fddi-mapping/doc/fddi_modbus_config_3s-20070710-7.odt (contents, props changed)
branches/fddi-mapping/doc/fddi_proposal_3s-20070618-1.odt (contents, props changed)
branches/fddi-mapping/doc/header.txt
branches/fddi-mapping/include/
branches/fddi-mapping/include/GNUmakefile.am
branches/fddi-mapping/include/fddistuff.h
branches/fddi-mapping/include/osadl/
branches/fddi-mapping/include/osadl/attic/
branches/fddi-mapping/include/osadl/attic/fddi_hess.h
branches/fddi-mapping/include/osadl/fddi.h
branches/fddi-mapping/include/osadl/fddi_device.h
branches/fddi-mapping/include/osadl/fddi_id.h
branches/fddi-mapping/include/osadl/fddi_iface.h
branches/fddi-mapping/include/osadl/fddi_param.h
branches/fddi-mapping/include/osadl/fddi_pv.h
branches/fddi-mapping/include/osadl/fddi_pv_attr.h
branches/fddi-mapping/include/osadl/fddi_pv_engine.h
branches/fddi-mapping/include/osadl/fddi_pv_group.h
branches/fddi-mapping/include/osadl/fddi_pv_group_attr.h
branches/fddi-mapping/include/osadl/fddi_tpu.h
branches/fddi-mapping/include/osadl/fddi_types.h
branches/fddi-mapping/src/
branches/fddi-mapping/src/GNUmakefile.am
branches/fddi-mapping/src/fddi_pv.c
branches/fddi-mapping/src/fddi_pv_engine.c
branches/fddi-mapping/src/fddi_pv_group.c
branches/fddi-mapping/src/fddi_pv_group_attr.c
branches/fddi-mapping/src/libfddi.c
branches/fddi-mapping/src/libfddi_can.c
branches/fddi-mapping/src/libfddi_hess.c
branches/fddi-mapping/src/libfddi_libmodbus.c
branches/fddi-mapping/tests/
branches/fddi-mapping/tests/GNUmakefile.am
branches/fddi-mapping/tests/example.xml
branches/fddi-mapping/tests/examplebus.h
branches/fddi-mapping/tests/fddi_examplebus.h
branches/fddi-mapping/tests/libexamplebus.c
branches/fddi-mapping/tests/libfddi_examplebus.c
branches/fddi-mapping/tests/test_examplebus1.c
branches/fddi-mapping/tests/test_fddi_can1.c
branches/fddi-mapping/tests/test_fddi_can1.xml
branches/fddi-mapping/tests/test_fddi_examplebus1.c
branches/fddi-mapping/tests/test_fddi_examplebus_attach_backend.c
branches/fddi-mapping/tests/test_fddi_examplebus_cmd_identify.c
branches/fddi-mapping/tests/test_fddi_examplebus_cmd_quiterr.c
branches/fddi-mapping/tests/test_fddi_examplebus_cmd_reset.c
branches/fddi-mapping/tests/test_fddi_examplebus_cmd_start.c
branches/fddi-mapping/tests/test_fddi_examplebus_cmd_stop.c
branches/fddi-mapping/tests/test_fddi_examplebus_configure.c
branches/fddi-mapping/tests/test_fddi_examplebus_setstate_configerror.c
branches/fddi-mapping/tests/test_fddi_examplebus_setstate_missing.c
branches/fddi-mapping/tests/test_fddi_examplebus_setstate_operation_error.c
branches/fddi-mapping/tests/test_fddi_examplebus_setstate_operational.c
branches/fddi-mapping/tests/test_fddi_examplebus_setstate_preoperational.c
branches/fddi-mapping/tests/test_fddi_examplebus_setstate_unconfigured.c
branches/fddi-mapping/tests/test_fddi_examplebus_tpu_usecase.c
branches/fddi-mapping/tests/test_fddi_libmodbus1.c
branches/fddi-mapping/tests/test_fddi_versionstr.c
branches/fddi-mapping/tests/usecase_controller.c
branches/fddi-mapping/tests/usecase_streaming.c
Added: branches/fddi-mapping/AUTHORS
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/AUTHORS Tue Oct 2 16:30:06 2007
@@ -0,0 +1,18 @@
+N: Dieter Hess
+E: d.hess AT 3s-software.com
+W: http://www.3s-software.com
+D: Maintainer
+S: 3S-Smart Software Solutions GmbH
+S: Memminger Str.151
+S: 87439 Kempten
+S: Germany
+
+N: Robert Schwebel
+E: r.schwebel AT pengutronix.de
+W: http://www.pengutronix.de
+D: Maintainer
+S: Pengutronix e.K.
+S: Hannoversche Strasse 2
+S: 31134 Hildesheim
+S: Germany
+
Added: branches/fddi-mapping/COPYING
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/COPYING Tue Oct 2 16:30:06 2007
@@ -0,0 +1,31 @@
+LICENCING INFORMATION
+---------------------
+
+libfddi is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License version 2 as published by
+the Free Software Foundation
+
+libfddi 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 libfddi; if not, write to the Free Software Foundation, Inc., 59
+Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+
+LINK EXCEPTION
+--------------
+
+For all source files required to build the libfddi library, which are
+referenced by the term 'these files' in the following section. As a
+special exception, if other files instantiate templates or use macros or
+inline functions from these files, or you compile these files and link
+them with other works to produce a work based on these files, these
+files do not by themselves cause the resulting work to be covered by the
+GNU General Public License. However the source code for these files must
+still be made available in accordance with section (3) of the GNU
+General Public License. This exception DOES NOT invalidate any other
+reasons why a work based on these files might be covered by the GNU
+General Public License.
+
Added: branches/fddi-mapping/ChangeLog
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/ChangeLog Tue Oct 2 16:30:06 2007
@@ -0,0 +1,27 @@
+2007-07-04 Robert Schwebel <r.schwebel at pengutronix.de>
+
+ * libftdl: added
+ * makefiles: fixed distcheck (works now if all tests would work,
+ which is not the case because of unimplemented functionality)
+ * release: released 20070618-1-ptx3 (svn only)
+
+2007-06-30 Robert Schwebel <r.schwebel at pengutronix.de>
+
+ * libfddi: return -1 for functions which are currently unimplemented
+ * tests: added test for fddi_getversionstr
+ * tests: added tests for setstate
+ * tests: added first bunch of unit tests
+ * libexamplebus: added example fieldbus library
+ * libfddi_examplebus: added fddi wrapper library
+ * libfddi: implement lt_dlopen loader for backends
+ * release: released 20070618-1-ptx2 (svn only)
+
+2007-06-18 Robert Schwebel <r.schwebel at pengutronix.de>
+
+ * design: model fddi components as POSIX like objects
+ * release: released 20070618-1-ptx1 (svn only)
+
+2007-06-18 Dieter Hess <d.hess at 3s-software.com>
+
+ * design: initial proposal for an API
+
Added: branches/fddi-mapping/GNUmakefile.am
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/GNUmakefile.am Tue Oct 2 16:30:06 2007
@@ -0,0 +1,52 @@
+
+DIST_SUBDIRS = include config src tests
+SUBDIRS = $(LIBLTDL_DIR) $(DIST_SUBDIRS)
+
+EXTRA_DIST = \
+ autogen.sh \
+ busconfig \
+ config/m4/.secret-world-domination-project \
+ libltdl/COPYING.LIB \
+ libltdl/Makefile.am \
+ libltdl/Makefile.in \
+ libltdl/README \
+ libltdl/acinclude.m4 \
+ libltdl/aclocal.m4 \
+ libltdl/config-h.in \
+ libltdl/config.guess \
+ libltdl/config.sub \
+ libltdl/configure \
+ libltdl/configure.ac \
+ libltdl/install-sh \
+ libltdl/ltdl.c \
+ libltdl/ltdl.h \
+ libltdl/ltmain.sh \
+ libltdl/missing
+
+MAINTAINERCLEANFILES = \
+ configure \
+ GNUmakefile.in \
+ aclocal.m4 \
+ config/autoconf/compile \
+ config/autoconf/config.guess \
+ config/autoconf/config.sub \
+ config/autoconf/depcomp \
+ config/autoconf/install-sh \
+ config/autoconf/ltmain.sh \
+ config/autoconf/mdate-sh \
+ config/autoconf/missing \
+ config/autoconf/texinfo.tex \
+ config/m4/libtool.m4 \
+ config/m4/ltoptions.m4 \
+ config/m4/ltsugar.m4 \
+ config/m4/ltversion.m4
+
+maintainer-clean-local:
+ -rm -fr $(srcdir)/libltdl
+
+distclean-local:
+ -cd $(builddir)/libltdl && make distclean
+
+uninstall-local:
+ -rm -rf $(DESTDIR)$(pkgdatadir)/libltdl
+
Added: branches/fddi-mapping/README
==============================================================================
Added: branches/fddi-mapping/TODO
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/TODO Tue Oct 2 16:30:06 2007
@@ -0,0 +1,29 @@
+TODO
+----
+
+[ ] Usecases
+
+ [ ] packet streaming with jvisu observation
+ [ ] PLC (SPS)
+ [ ] controller (e.g. PID)
+
+[ ] Questions:
+
+ [ ] workflow / timing for use cases?
+ [ ] where does the data come from?
+ [ ] where does it go?
+ [ ] when is it being processed?
+ [ ] take input+output into account
+ [ ] what happens if two processes want to manipulate variables
+ in the same TPU? Example: error counters; jvisu.
+ [ ] Put permission model into mapping layer? This could also
+ handle safety issues (e.g. who is allowed to write?
+ [ ] command api (e.g. having a "pv->increment" command which is
+ distributed over the network)
+
+[ ] Wakeup: D. Hess suggests that TPUs can have a sync flag, which means that
+ upper layers can subscribe to that flags and are being woken up when they come
+ in.
+
+[ ] invent performant data transport model with persistence; rcu?
+
Added: branches/fddi-mapping/autogen.sh
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/autogen.sh Tue Oct 2 16:30:06 2007
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+#
+# usage:
+#
+# banner <target name>
+#
+banner() {
+ echo
+ TG=`echo $1 | sed -e "s,/.*/,,g"`
+ LINE=`echo $TG |sed -e "s/./-/g"`
+ echo $LINE
+ echo $TG
+ echo $LINE
+ echo
+}
+
+
+ACLOCAL=${ACLOCAL:=aclocal}
+AUTOHEADER=${AUTOHEADER:=autoheader}
+AUTOMAKE=${AUTOMAKE:=automake}
+AUTOCONF=${AUTOCONF:=autoconf}
+
+#$ACLOCAL --version | \
+# awk -vPROG="aclocal" -vVERS=1.7\
+# '{if ($1 == PROG) {gsub ("-.*","",$4); if ($4 < VERS) print PROG" < version "VERS"\nThis may result in errors\n"}}'
+
+#$AUTOMAKE --version | \
+# awk -vPROG="automake" -vVERS=1.7\
+# '{if ($1 == PROG) {gsub ("-.*","",$4); if ($4 < VERS) print PROG" < version "VERS"\nThis may result in errors\n"}}'
+
+
+banner "running aclocal"
+$ACLOCAL -I config/m4 || exit
+
+banner "running libtoolize"
+libtoolize --force --ltdl --copy || exit
+
+banner "running autoheader"
+$AUTOHEADER || exit
+
+banner "running automake"
+$AUTOMAKE --gnu --add-missing -Wall || exit
+
+banner "running autoconf"
+$AUTOCONF -Wall || exit
+
+banner "Finished"
Added: branches/fddi-mapping/busconfig/3S/ModBusConfigExample.xml
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/busconfig/3S/ModBusConfigExample.xml Tue Oct 2 16:30:06 2007
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--Sample XML file generated by XMLSPY v2004 rel. 4 U (http://www.xmlspy.com)-->
+
+<FddiDevice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="C:\Dokumente und Einstellungen\d.hess\Desktop\fddi\fddiconfig.xsd">
+
+ <Id>0</Id>
+ <Name>ModbusMaster</Name>
+
+ <FddiDevice>
+ <Id>1</Id>
+ <Name>ModbusSlave1</Name>
+ <FddiParam Id="1" Name="ParamAddress" Type="int">14</FddiParam>
+ <FddiParam Id="2" Name="ParamValue" Type="int">0</FddiParam>
+ <FddiParam Id="11" Name="ParamAddress" Type="int">22</FddiParam>
+ <FddiParam Id="12" Name="ParamValue" Type="int">17</FddiParam>
+ <FddiParam Id="1001" Name="TpuAdress" Type="int">64</FddiParam>
+ <FddiParam Id="1002" Name="TpuSize" Type="int">8</FddiParam>
+ <FddiParam Id="1003" Name="TpuGranularity" Type="int">1</FddiParam>
+ <FddiParam Id="1004" Name="TpuUpdateRate" Type="int">100</FddiParam>
+ <FddiParam Id="1004" Name="TpuDirectionWrite" Type="bool">false</FddiParam>
+ <FddiParam Id="1011" Name="TpuAdress" Type="int">72</FddiParam>
+ <FddiParam Id="1012" Name="TpuSize" Type="int">12</FddiParam>
+ <FddiParam Id="1013" Name="TpuGranularity" Type="int">2</FddiParam>
+ <FddiParam Id="1014" Name="TpuUpdateRate" Type="int">100</FddiParam>
+ <FddiParam Id="1014" Name="TpuDirectionWrite" Type="bool">true</FddiParam>
+ </FddiDevice>
+
+ <FddiDevice>
+ <Id>2</Id>
+ <Name>ModbusSlave2</Name>
+ <FddiParam Id="1" Name="ParamAddress" Type="int">4</FddiParam>
+ <FddiParam Id="2" Name="ParamValue" Type="int">11</FddiParam>
+ <FddiParam Id="1011" Name="TpuAdress" Type="int">20</FddiParam>
+ <FddiParam Id="1012" Name="TpuSize" Type="int">4</FddiParam>
+ <FddiParam Id="1013" Name="TpuGranularity" Type="int">1</FddiParam>
+ <FddiParam Id="1014" Name="TpuUpdateRate" Type="int">50</FddiParam>
+ <FddiParam Id="1014" Name="TpuDirectionWrite" Type="bool">true</FddiParam>
+ </FddiDevice>
+
+ <FddiParam Id="1" Name="TCPIP-Port" Type="int">1010</FddiParam>
+
+</FddiDevice>
Added: branches/fddi-mapping/busconfig/3S/fddiconfig.xsd
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/busconfig/3S/fddiconfig.xsd Tue Oct 2 16:30:06 2007
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- edited with XMLSPY v2004 rel. 4 U (http://www.xmlspy.com) by Dieter Hess (3S-Smart Software Solutions GmbH) -->
+<xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="FddiDevice" type="FddiDeviceType">
+ <xs:annotation>
+ <xs:documentation>Root device of a fddi configuration</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:complexType name="FddiDeviceType">
+ <xs:sequence>
+ <xs:element name="Id" type="xs:unsignedLong"/>
+ <xs:element name="Name" type="xs:string" minOccurs="0"/>
+ <xs:element name="FddiDevice" type="FddiDeviceType" minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element name="FddiParam" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:simpleContent>
+ <xs:extension base="xs:anySimpleType">
+ <xs:attribute name="Id" type="xs:hexBinary" use="required"/>
+ <xs:attribute name="Name" type="xs:string" use="optional"/>
+ <xs:attribute name="Type" type="xs:string" use="required"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
Added: branches/fddi-mapping/busconfig/Pengutronix/can-example.xml
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/busconfig/Pengutronix/can-example.xml Tue Oct 2 16:30:06 2007
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="iso8859-1"?>
+
+<!--
+ TODO:
+
+ - let jfr fix the schema for CAN entries
+ - version bump
+ - clarify: who is the owner of a transportation unit?
+ always the data source -> ioInterface...?
+ - discuss with mkl if the filter mechanics makes sense
+-->
+
+<openIO>
+
+ <system prefix="demosystem" index="0">
+
+ <name>OSADL CAN Demo System</name>
+
+ <system prefix="boardcomputer" index="0">
+
+ <name>Board Computer</name>
+
+ <portCan>
+ <id prefix="can" index="0"/>
+ <device prefix="can" index="0" direction="inout"/>
+ <name>CAN</name>
+ <baudrate>500000</baudrate>
+ </portCan>
+
+ <ioInterfaceCan>
+ <id prefix="can" index="0"/>
+ <device prefix="can" index="0" direction="inout"/>
+ </ioInterfaceCan>
+
+ </system>
+
+ <system prefix="car" index="0">
+
+ <name>The Car</name>
+
+ <portCan>
+ <id prefix="can" index="0"/>
+ <device prefix="can" index="0" direction="inout"/>
+ <name>CAN</name>
+ <baudrate>500000</baudrate>
+ </portCan>
+
+ <ioInterfaceCan>
+ <id prefix="can" index="0"/>
+ <device prefix="can" index="0" direction="inout"/>
+
+ <transportationUnit direction="out" cycletime="0">
+ <size>8</size>
+ <property name="canid-type" value="extended"/>
+ <property name="canid" value="0x18E0F108"/>
+ <property name="canid-andmask" value="0xffffffff"/>
+ <property name="canid-ormask" value="0x00000000"/>
+ <pv id="can_speed" val="0">
+ <name>Car Speed (from CAN)</name>
+ <type>uint16_t</type>
+ <offset>0</offset>
+ <bit></bit>
+ </pv>
+ <pv id="can_rpm" val="0">
+ <name>RPM (from CAN)</name>
+ <type>uint16_t</type>
+ <offset>2</offset>
+ <bit></bit>
+ </pv>
+ <pv id="can_voltage" val="0">
+ <name>Voltage (from CAN)</name>
+ <type>uint16_t</type>
+ <offset>4</offset>
+ <bit></bit>
+ </pv>
+ <pv id="can_current" val="0">
+ <name>Current (from CAN)</name>
+ <type>uint16_t</type>
+ <offset>6</offset>
+ <bit></bit>
+ </pv>
+ </transportationUnit>
+
+ <transportationUnit direction="out" cycletime="0">
+ <size>4</size>
+ <property name="canid-type" value="extended"/>
+ <property name="canid" value="0x18E0F108"/>
+ <property name="canid-andmask" value="0xffffffff"/>
+ <property name="canid-ormask" value="0x00000000"/>
+ <pv id="can_arate" val="0">
+ <name>A Rate (from CAN)</name>
+ <type>uint16_t</type>
+ <offset>0</offset>
+ <bit></bit>
+ </pv>
+ <pv id="can_srate" val="0">
+ <name>S Rate (from CAN)</name>
+ <type>uint16_t</type>
+ <offset>2</offset>
+ <bit></bit>
+ </pv>
+ </transportationUnit>
+
+ </ioInterfaceCan>
+
+ </system>
+
+ <connection>
+ <node system_id="boardcomputer0" port_id="can0"/>
+ <node system_id="car0" port_id="can0"/>
+ </connection>
+
+ <ioConnection>
+ <node system_id="boardcomputer0" ioInterface_id="can0"/>
+ <node system_id="car0" ioInterface_id="can0"/>
+ </ioConnection>
+
+ </system>
+
+</openIO>
+
Added: branches/fddi-mapping/busconfig/Pengutronix/modbus-example.xml
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/busconfig/Pengutronix/modbus-example.xml Tue Oct 2 16:30:06 2007
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="iso8859-1"?>
+
+<openIO type="topology">
+
+ <system>
+ <id prefix="model" index="0"/>
+
+ <description>OSADL Modbus Demo System</description>
+
+ <system>
+ <id prefix="controller" index="0"/>
+
+ <description>Controller PC</description>
+
+ <portEthernet>
+ <id prefix="eth" index="0"/>
+ <device prefix="eth" index="0" direction="inout"/>
+ <description>Ethernet</description>
+ <ip/>
+ <broadcast/>
+ <mac/>
+ </portEthernet>
+
+ <ioInterfaceModbus>
+ <id prefix="modbus" index="0"/>
+ <device prefix="eth" index="0" direction="inout"/>
+ <role>master</role>
+ </ioInterfaceModbus>
+
+ </system>
+
+ <system>
+ <id prefix="iobox" index="0">
+
+ <description>Wago IO Box</description>
+
+ <portEthernet>
+ <id prefix="eth" index="0"/>
+ <device prefix="eth" index="0" direction="inout"/>
+ <description>Ethernet</description>
+ <ip/>
+ <broadcast/>
+ <mac/>
+ </portEthernet>
+
+ <ioInterfaceModbus>
+ <id prefix="modbus" index="0"/>
+ <device prefix="eth" index="0" direction="inout"/>
+ <role>slave</role>
+
+ <transportationUnit direction="out" cycletime="0">
+ <size>1</size>
+ <pv id="signal_red" val="0">
+ <property description="modbusregister" value="30001"/> <!-- FIXME -->
+ <description>Signal Noun Red Light</description>
+ <type>bool_t</type>
+ <offset>0</offset>
+ <bit>0</bit>
+ </pv>
+ <pv id="signal_yellow" val="0">
+ <property description="modbusregister" value="30002"/> <!-- FIXME -->
+ <description>Signal Noun Yellow Light</description>
+ <type>bool_t</type>
+ <offset>0</offset>
+ <bit>1</bit>
+ </pv>
+ <pv id="signal_green" val="0">
+ <property description="modbusregister" value="30003"/> <!-- FIXME -->
+ <description>Signal Noun Green Light</description>
+ <type>bool_t</type>
+ <offset>0</offset>
+ <bit>2</bit>
+ </pv>
+ </transportationUnit>
+
+ </ioInterfaceModbus>
+
+ </system>
+
+ <connection>
+ <node system_id="controller0" port_id="eth0"/>
+ <node system_id="iobox0" port_id="eth0"/>
+ </connection>
+
+ <ioConnection>
+ <node system_id="controller0" ioInterface_id="modbus0"/>
+ <node system_id="iobox0" ioInterface_id="modbus0"/>
+ </ioConnection>
+
+ </system>
+
+</openIO>
+
+<openIO type="mapping">
+ <map> <pv_src id="iobox.klemme1"/><pv_dst id="controller.input"/></map>
+</openIO>
+
Added: branches/fddi-mapping/busconfig/misc/pretty.xsl
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/busconfig/misc/pretty.xsl Tue Oct 2 16:30:06 2007
@@ -0,0 +1,47 @@
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:output method="xml" encoding="ISO-8859-1"/>
+ <xsl:param name="indent-increment" select="' '"/>
+
+ <xsl:template name="newline">
+ <xsl:text disable-output-escaping="yes">
+</xsl:text>
+ </xsl:template>
+
+ <xsl:template match="comment() | processing-instruction()">
+ <xsl:param name="indent" select="''"/>
+ <xsl:call-template name="newline"/>
+ <xsl:value-of select="$indent"/>
+ <xsl:copy />
+ </xsl:template>
+
+ <xsl:template match="text()">
+ <xsl:param name="indent" select="''"/>
+ <xsl:call-template name="newline"/>
+ <xsl:value-of select="$indent"/>
+ <xsl:value-of select="normalize-space(.)"/>
+ </xsl:template>
+
+ <xsl:template match="text()[normalize-space(.)='']"/>
+
+ <xsl:template match="*">
+ <xsl:param name="indent" select="''"/>
+ <xsl:call-template name="newline"/>
+ <xsl:value-of select="$indent"/>
+ <xsl:choose>
+ <xsl:when test="count(child::*) > 0">
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates select="*|text()">
+ <xsl:with-param name="indent" select="concat ($indent, $indent-increment)"/>
+ </xsl:apply-templates>
+ <xsl:call-template name="newline"/>
+ <xsl:value-of select="$indent"/>
+ </xsl:copy>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+</xsl:stylesheet>
Added: branches/fddi-mapping/config/GNUmakefile.am
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/config/GNUmakefile.am Tue Oct 2 16:30:06 2007
@@ -0,0 +1,7 @@
+EXTRA_DIST = libfddi.pc.in
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libfddi.pc
+
+MAINTAINERCLEANFILES = \
+ GNUmakefile.in
Added: branches/fddi-mapping/config/libfddi.pc.in
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/config/libfddi.pc.in Tue Oct 2 16:30:06 2007
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libfddi
+Description: OSADL Fieldbus Device Driver Interface
+Requires:
+Version: @VERSION@
+Libs: -L${libdir} -lfddi
+#Libs.private: -lm -lpthread ...etc...
+Cflags: -I${includedir}
Added: branches/fddi-mapping/config/m4/.secret-world-domination-project
==============================================================================
Added: branches/fddi-mapping/config/m4/acx_pthread.m4
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/config/m4/acx_pthread.m4 Tue Oct 2 16:30:06 2007
@@ -0,0 +1,238 @@
+dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+dnl
+dnl @summary figure out how to build C programs using POSIX threads
+dnl
+dnl This macro figures out how to build C programs using POSIX threads.
+dnl It sets the PTHREAD_LIBS output variable to the threads library and
+dnl linker flags, and the PTHREAD_CFLAGS output variable to any special
+dnl C compiler flags that are needed. (The user can also force certain
+dnl compiler flags/libs to be tested by setting these environment
+dnl variables.)
+dnl
+dnl Also sets PTHREAD_CC to any special C compiler that is needed for
+dnl multi-threaded programs (defaults to the value of CC otherwise).
+dnl (This is necessary on AIX to use the special cc_r compiler alias.)
+dnl
+dnl NOTE: You are assumed to not only compile your program with these
+dnl flags, but also link it with them as well. e.g. you should link
+dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
+dnl $LIBS
+dnl
+dnl If you are only building threads programs, you may wish to use
+dnl these variables in your default LIBS, CFLAGS, and CC:
+dnl
+dnl LIBS="$PTHREAD_LIBS $LIBS"
+dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+dnl CC="$PTHREAD_CC"
+dnl
+dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
+dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
+dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
+dnl
+dnl ACTION-IF-FOUND is a list of shell commands to run if a threads
+dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
+dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
+dnl default action will define HAVE_PTHREAD.
+dnl
+dnl Please let the authors know if this macro fails on any platform, or
+dnl if you have any other suggestions or comments. This macro was based
+dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with
+dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros
+dnl posted by Alejandro Forero Cuervo to the autoconf macro repository.
+dnl We are also grateful for the helpful feedback of numerous users.
+dnl
+dnl @category InstalledPackages
+dnl @author Steven G. Johnson <stevenj at alum.mit.edu>
+dnl @version 2005-06-15
+dnl @license GPLWithACException
+
+AC_DEFUN([ACX_PTHREAD], [
+AC_REQUIRE([AC_CANONICAL_HOST])
+AC_LANG_SAVE
+AC_LANG_C
+acx_pthread_ok=no
+
+# We used to check for pthread.h first, but this fails if pthread.h
+# requires special compiler flags (e.g. on True64 or Sequent).
+# It gets checked for in the link test anyway.
+
+# First of all, check if the user has set any of the PTHREAD_LIBS,
+# etcetera environment variables, and if threads linking works using
+# them:
+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+ save_LIBS="$LIBS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
+ AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
+ AC_MSG_RESULT($acx_pthread_ok)
+ if test x"$acx_pthread_ok" = xno; then
+ PTHREAD_LIBS=""
+ PTHREAD_CFLAGS=""
+ fi
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+fi
+
+# We must check for the threads library under a number of different
+# names; the ordering is very important because some systems
+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
+# libraries is broken (non-POSIX).
+
+# Create a list of thread flags to try. Items starting with a "-" are
+# C compiler flags, and other items are library names, except for "none"
+# which indicates that we try without any flags at all, and "pthread-config"
+# which is a program returning the flags for the Pth emulation library.
+
+acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
+
+# The ordering *is* (sometimes) important. Some notes on the
+# individual items follow:
+
+# pthreads: AIX (must check this before -lpthread)
+# none: in case threads are in libc; should be tried before -Kthread and
+# other compiler flags to prevent continual compiler warnings
+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
+# -pthreads: Solaris/gcc
+# -mthreads: Mingw32/gcc, Lynx/gcc
+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+# doesn't hurt to check since this sometimes defines pthreads too;
+# also defines -D_REENTRANT)
+# ... -mt is also the pthreads flag for HP/aCC
+# pthread: Linux, etcetera
+# --thread-safe: KAI C++
+# pthread-config: use pthread-config program (for GNU Pth library)
+
+case "${host_cpu}-${host_os}" in
+ *solaris*)
+
+ # On Solaris (at least, for some versions), libc contains stubbed
+ # (non-functional) versions of the pthreads routines, so link-based
+ # tests will erroneously succeed. (We need to link with -pthreads/-mt/
+ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
+ # a function called by this macro, so we could check for that, but
+ # who knows whether they'll stub that too in a future libc.) So,
+ # we'll just look for -pthreads and -lpthread first:
+
+ acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
+ ;;
+esac
+
+if test x"$acx_pthread_ok" = xno; then
+for flag in $acx_pthread_flags; do
+
+ case $flag in
+ none)
+ AC_MSG_CHECKING([whether pthreads work without any flags])
+ ;;
+
+ -*)
+ AC_MSG_CHECKING([whether pthreads work with $flag])
+ PTHREAD_CFLAGS="$flag"
+ ;;
+
+ pthread-config)
+ AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
+ if test x"$acx_pthread_config" = xno; then continue; fi
+ PTHREAD_CFLAGS="`pthread-config --cflags`"
+ PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
+ ;;
+
+ *)
+ AC_MSG_CHECKING([for the pthreads library -l$flag])
+ PTHREAD_LIBS="-l$flag"
+ ;;
+ esac
+
+ save_LIBS="$LIBS"
+ save_CFLAGS="$CFLAGS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+ # Check for various functions. We must include pthread.h,
+ # since some functions may be macros. (On the Sequent, we
+ # need a special flag -Kthread to make this header compile.)
+ # We check for pthread_join because it is in -lpthread on IRIX
+ # while pthread_create is in libc. We check for pthread_attr_init
+ # due to DEC craziness with -lpthreads. We check for
+ # pthread_cleanup_push because it is one of the few pthread
+ # functions on Solaris that doesn't have a non-functional libc stub.
+ # We try pthread_create on general principles.
+ AC_TRY_LINK([#include <pthread.h>],
+ [pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
+ [acx_pthread_ok=yes])
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ AC_MSG_RESULT($acx_pthread_ok)
+ if test "x$acx_pthread_ok" = xyes; then
+ break;
+ fi
+
+ PTHREAD_LIBS=""
+ PTHREAD_CFLAGS=""
+done
+fi
+
+# Various other checks:
+if test "x$acx_pthread_ok" = xyes; then
+ save_LIBS="$LIBS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+ # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
+ AC_MSG_CHECKING([for joinable pthread attribute])
+ attr_name=unknown
+ for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+ AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
+ [attr_name=$attr; break])
+ done
+ AC_MSG_RESULT($attr_name)
+ if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
+ AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
+ [Define to necessary symbol if this constant
+ uses a non-standard name on your system.])
+ fi
+
+ AC_MSG_CHECKING([if more special flags are required for pthreads])
+ flag=no
+ case "${host_cpu}-${host_os}" in
+ *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
+ *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
+ esac
+ AC_MSG_RESULT(${flag})
+ if test "x$flag" != xno; then
+ PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
+ fi
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ # More AIX lossage: must compile with cc_r
+ AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC})
+else
+ PTHREAD_CC="$CC"
+fi
+
+AC_SUBST(PTHREAD_LIBS)
+AC_SUBST(PTHREAD_CFLAGS)
+AC_SUBST(PTHREAD_CC)
+
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+if test x"$acx_pthread_ok" = xyes; then
+ ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
+ :
+else
+ acx_pthread_ok=no
+ $2
+fi
+AC_LANG_RESTORE
+])dnl ACX_PTHREAD
Added: branches/fddi-mapping/configure.ac
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/configure.ac Tue Oct 2 16:30:06 2007
@@ -0,0 +1,280 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+AC_PREREQ(2.59)
+
+AC_INIT([fddi], [0.0.1], [bugs at pengutronix.de])
+AC_CONFIG_HEADERS([include/fddi_config.h])
+AC_CONFIG_SRCDIR([src/libfddi.c])
+AC_CONFIG_MACRO_DIR([config/m4])
+AC_CONFIG_AUX_DIR([config/autoconf])
+AC_CANONICAL_BUILD
+AC_CANONICAL_HOST
+
+AM_MAINTAINER_MODE
+
+CFLAGS="${CFLAGS} -Wall"
+
+#
+# libtool library versioning stuff
+#
+
+# Library code modified: REVISION++
+# Interfaces changed/added/removed: CURRENT++ REVISION=0
+# Interfaces added: AGE++
+# Interfaces removed: AGE=0
+LT_CURRENT=0
+LT_REVISION=0
+LT_AGE=0
+AC_SUBST(LT_CURRENT)
+AC_SUBST(LT_REVISION)
+AC_SUBST(LT_AGE)
+
+#
+# libtool and lt_dl
+#
+
+AC_LIBLTDL_INSTALLABLE
+AC_LIBTOOL_DLOPEN
+AC_LIBTOOL_WIN32_DLL
+AC_PROG_LIBTOOL
+AC_CONFIG_SUBDIRS(libltdl)
+AC_SUBST(INCLTDL)
+AC_SUBST(LIBLTDL)
+if test "${enable_ltdl_install}" = "yes"; then
+ LIBLTDL_DIR=libltdl
+else
+ LIBLTDL_DIR=""
+fi
+AC_SUBST(LIBLTDL_DIR)
+
+#
+# Checks for programs.
+#
+
+AC_PROG_CC
+
+AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2])
+
+
+#
+# Checks for libraries
+#
+
+##
+# librn
+##
+# REQUIRES_LIBRN="librn >= 0.4.2"
+# AC_SUBST(REQUIRES_LIBRN)
+# PKG_CHECK_MODULES([librn],
+# [${REQUIRES_LIBRN}],
+# [],
+# [AC_MSG_ERROR([*** ${REQUIRES_LIBRN} not found by pkg-config on your system])]
+# )
+# AC_SUBST(librn_CFLAGS)
+# AC_SUBST(librn_LIBS)
+
+#
+# Checks for header files.
+#
+
+AC_HEADER_DIRENT
+AC_HEADER_STDC
+AC_HEADER_SYS_WAIT
+AC_CHECK_HEADERS([ \
+ arpa/inet.h \
+ limits.h \
+ netdb.h \
+ netinet/in.h \
+ stddef.h \
+ stdlib.h \
+ string.h \
+ sys/param.h \
+ sys/socket.h \
+ sys/time.h \
+ sys/un.h \
+ unistd.h \
+ utime.h \
+ ])
+
+
+#
+# Checks for typedefs, structures, and compiler characteristics.
+#
+
+AC_C_CONST
+AC_C_INLINE
+AC_TYPE_SIZE_T
+AC_HEADER_TIME
+
+
+#
+# Checks for library functions.
+#
+
+AC_FUNC_MEMCMP
+AC_TYPE_SIGNAL
+AC_FUNC_STAT
+AC_FUNC_UTIME_NULL
+AC_CHECK_FUNCS([gethostbyaddr gethostbyname gethostname gettimeofday memset mkdir socket utime])
+
+
+#
+# Debugging
+#
+
+AC_MSG_CHECKING([whether to enable debugging])
+AC_ARG_ENABLE(debug,
+ AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=yes@:>@]),
+ [case "$enableval" in
+ y | yes) CONFIG_DEBUG=yes ;;
+ *) CONFIG_DEBUG=no ;;
+ esac],
+ [CONFIG_DEBUG=yes]
+)
+AC_MSG_RESULT([${CONFIG_DEBUG}])
+if test "${CONFIG_DEBUG}" = "yes"; then
+ CFLAGS="${CFLAGS} -Wsign-compare -Wfloat-equal -Wformat-security -g -O1"
+ AC_DEFINE(DEBUG, 1, [debugging])
+else
+ CFLAGS="${CFLAGS} -Werror -O2"
+fi
+
+
+#
+# XML parsers
+#
+
+AC_MSG_CHECKING([for xml parser])
+AC_ARG_WITH(xmlparser,
+ AS_HELP_STRING([--with-xmlparser], [select used xml parser; you can chose from expat,
+ libxml2 or auto. @<:@default=libxml2@:>@]),
+ [case "$withval" in
+ expat) CONFIG_XMLPARSER=expat ;;
+ libxml2) CONFIG_XMLPARSER=libxml2 ;;
+ n | no) CONFIG_XMLPARSER=no ;;
+ auto | *) CONFIG_XMLPARSER=auto ;;
+ esac],
+ [CONFIG_XMLPARSER=auto]
+)
+if test "${CONFIG_XMLPARSER}" = "auto"; then
+ AC_MSG_WARN([echo "FIXME - auto test for xml parser not written yet"])
+fi
+AM_CONDITIONAL(XMLPARSER_EXPAT, test "${CONFIG_XMLPARSER}" = "expat")
+AM_CONDITIONAL(XMLPARSER_LIBXML2, test "${CONFIG_XMLPARSER}" = "libxml2")
+AC_MSG_RESULT([${CONFIG_XMLPARSER}])
+
+
+#
+# Backends
+#
+
+AC_MSG_CHECKING([whether to enable libmodbus backend])
+AC_ARG_ENABLE(backend-libmodbus,
+ AS_HELP_STRING([--enable-backend-libmodbus], [enable libmodbus backend @<:@default=no@:>@]),
+ [case "$enableval" in
+ y | yes) CONFIG_BACKEND_LIBMODBUS=yes ;;
+ *) CONFIG_BACKEND_LIBMODBUS=no ;;
+ esac],
+ [CONFIG_BACKEND_LIBMODBUS=no]
+)
+AM_CONDITIONAL(BACKEND_LIBMODBUS, test "${CONFIG_BACKEND_LIBMODBUS}" = "yes")
+AC_MSG_RESULT([${CONFIG_BACKEND_LIBMODBUS}])
+
+if test "${CONFIG_BACKEND_LIBMODBUS}" = "yes"; then
+
+ REQUIRES_LIBMODBUS="libmodbus >= 1.0.3"
+ AC_SUBST(REQUIRES_LIBMODBUS)
+ PKG_CHECK_MODULES([libmodbus],
+ [${REQUIRES_LIBMODBUS}],
+ [],
+ [AC_MSG_ERROR([${REQUIRES_LIBMODBUS} not found by pkg-config on your system])]
+ )
+ AC_SUBST(libmodbus_CFLAGS)
+ AC_SUBST(libmodbus_LIBS)
+
+ AC_MSG_CHECKING([whether libmodbus backend finds an xml parser])
+ if test "${CONFIG_XMLPARSER}" != "libxml2"; then
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([libmodbus backend needs libxml2, specify with --with-xmlparser])
+ else
+ AC_MSG_RESULT([yes])
+ fi
+
+fi
+
+
+AC_MSG_CHECKING([whether to enable can backend])
+AC_ARG_ENABLE(backend-can,
+ AS_HELP_STRING([--enable-backend-can], [enable can backend @<:@default=no@:>@]),
+ [case "$enableval" in
+ y | yes) CONFIG_BACKEND_CAN=yes ;;
+ *) CONFIG_BACKEND_CAN=no ;;
+ esac],
+ [CONFIG_BACKEND_CAN=no]
+)
+AM_CONDITIONAL(BACKEND_CAN, test "${CONFIG_BACKEND_CAN}" = "yes")
+AC_MSG_RESULT([${CONFIG_BACKEND_CAN}])
+
+if test "${CONFIG_BACKEND_CAN}" = "yes"; then
+
+ AC_CHECK_HEADER([linux/can.h], have_can_h=yes,, [[
+ #include <sys/socket.h>
+ ]])
+ if test "$have_can_h" != "yes"; then
+ AC_MSG_ERROR([linux/can.h must be available when building with --enable-backend-can])
+ fi
+
+fi
+
+
+#
+# Documentation
+#
+
+AC_MSG_CHECKING(whether to build doxygen documentation)
+AC_ARG_ENABLE(doc,
+ AS_HELP_STRING([--enable-doc], [enable documentation @<:@default=no@:>@]),
+ [case "$enableval" in
+ y | yes) CONFIG_DOCUMENTATION=yes ;;
+ *) CONFIG_DOCUMENTATION=no ;;
+ esac],
+ [CONFIG_DOCUMENTATION=no]
+)
+
+#if test \! -d $srcdir/doc ; then
+# if test x$CONFIG_XENO_DOC_DOX = xy ;
+# then
+# AC_MSG_ERROR([documentation tree is missing.])
+# fi
+# AC_MSG_RESULT([not present])
+#else
+# AC_MSG_RESULT(${CONFIG_XENO_DOC_DOX:-no})
+#fi
+
+AC_CHECK_PROG(DOXYGEN, doxygen, doxygen)
+if test "$CONFIG_DOCUMENTATION" = "y" -a -z "$DOXYGEN"; then
+ AC_MSG_ERROR([you need doxygen to generate the documentation, or use --disable-doc])
+fi
+
+AC_CHECK_PROG(DOXYGEN_HAVE_DOT, dot, YES, NO)
+if test "$DOXYGEN_HAVE_DOT" = "YES" ; then
+ DOXYGEN_SHOW_INCLUDE_FILES=NO
+else
+ DOXYGEN_SHOW_INCLUDE_FILES=YES
+fi
+
+
+#
+# Finished
+#
+
+AC_CONFIG_FILES([
+ GNUmakefile
+ config/libfddi.pc
+ config/GNUmakefile
+ include/GNUmakefile
+ src/GNUmakefile
+ tests/GNUmakefile
+ ])
+AC_OUTPUT
+
Added: branches/fddi-mapping/doc/GNUmakefile.am
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/doc/GNUmakefile.am Tue Oct 2 16:30:06 2007
@@ -0,0 +1,29 @@
+DOCBOOKFILES = $(wildcard *.docbook)
+HTMLFILES = $(patsubst %.docbook,%.html,$(DOCBOOKFILES))
+TXTFILES = $(patsubst %.docbook,%.txt,$(DOCBOOKFILES))
+HTMLXSL = /usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl
+XMLTO = xmlto
+
+all: $(HTMLFILES) $(TXTFILES)
+
+%.html: %.docbook
+ # $(XMLTO) -x $(HTMLXSL) html $<
+ # mv $(subst .docbook,.proc,$<) $(subst .docbook,.html,$<)
+ xsltproc --output $(subst .docbook,.html,$<) --stringparam section.autolabel 1 $(HTMLXSL) $<
+ touch *.wml
+
+%.txt: %.html
+ lynx -dump $< > $@
+ #recode utf8..latin1 $@
+
+clean:
+ rm -f $(HTMLFILES) $(TXTFILES) osadl-*.html
+
+osadl-fieldbus-framework.html: OSADL-Fieldbus-Framework-20070809-1.html
+
+EXTRA_DIST = \
+ OSADL-Fieldbus-Framework-20070809-1.docbook
+
+MAINTAINERCLEANFILES = \
+ GNUmakefile.in
+
Added: branches/fddi-mapping/doc/OSADL-FieldbusFramework-20070809-1.docbook
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/doc/OSADL-FieldbusFramework-20070809-1.docbook Tue Oct 2 16:30:06 2007
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://docbook.org/xml/4.1.2/docbookx.dtd" []>
+
+<article lang="en">
+
+ <articleinfo>
+
+ <authorgroup>
+ <author>
+ <firstname>Robert</firstname>
+ <surname>Schwebel</surname>
+ </author>
+ <!-- <collab><collabname>Fridolin Tux</collabname></collab> -->
+ </authorgroup>
+
+ <title>
+ OSADL Fieldbus Framework
+ </title>
+
+ <revhistory>
+ <revision>
+ <revnumber>0.1</revnumber>
+ <date>2007-08-09</date>
+ <revremark>Draft</revremark>
+ </revision>
+ </revhistory>
+
+ </articleinfo>
+
+
+
+<!-- ==================================================================== -->
+<sect1 id="rationale"><title>Rationale</title>
+<!-- ==================================================================== -->
+
+ <para> Industrial I/O components are the central interface between today's
+ automation systems and our physical environment. As Linux is becoming
+ more and more the first-class choice for embedded controllers, measurement
+ devices, soft PLCs and other control equipment throughout the industry,
+ there is still no commonly accepted way to connect I/O devices to a POSIX
+ operating system. </para>
+
+ <para> Although modern embedded controllers use more and more
+ decentralized infrastructure and although there is a huge variety of
+ fieldbus topologies available today, we are still far away from the
+ situation we have in the IT business: today's server infrastructure
+ is completely based on open standards. It simply does not matter if
+ you buy a network card from vendor A or vendor B: nobody would ever
+ try to start changing lowlevel hardware access code inside of the
+ apache web server just in case of a hardware change. But that's exactly
+ how industral I/O works today. There is no generally accepted interface
+ for accessing fieldbusses and local I/O on the market. </para>
+
+ <para> OSADL, being an organization who's members are machine building
+ companies, software specialists and embedded Linux experts, has the
+ declared aim to join market forces in order to make such a unified
+ framework possible. This document outlines the ideas and concepts behind
+ the OSADL Fieldbus Framework. </para>
+
+</sect1>
+
+
+
+
+
+
+<!-- ==================================================================== -->
+<sect1 id="bsp-definition"><title>BSP Definition</title>
+<!-- ==================================================================== -->
+
+ <para> bla bla </para>
+
+ <itemizedlist>
+
+ <listitem><para> foo </para></listitem>
+
+ <listitem><para> bar </para></listitem>
+
+ </itemizedlist>
+
+ <literallayout>
+ - kernel.org ---> BSP Provider ---> Board Vendor ---> End Customer
+ BSP BSP
+ </literallayout>
+
+ <sect2><title>Sub Chapter</title>
+
+ <para> gargelpu </para>
+
+ </sect2>
+
+</sect1>
+
+<!-- ==================================================================== -->
+<appendix label="A"><title>Glossary and Abbreviations</title>
+<!-- ==================================================================== -->
+
+<glosslist>
+
+ <glossentry>
+ <glossterm>Vanilla Kernel</glossterm>
+ <glossdef>
+
+ <para> The generally accepted main version of the Linux kernel is
+ being maintained by Linus Torvalds. It is the base for all
+ distributions, is the most whidespread version and the base for
+ all kernel development activities. The vanilla kernel can be
+ downloaded from <ulink
+ url="http://www.kernel.org/">http://www.kernel.org/</ulink>.
+ </para>
+
+ </glossdef>
+ </glossentry>
+
+</glosslist>
+
+</appendix>
+
+<!-- ==================================================================== -->
+
+<appendix label="B"><title>Authors</title>
+
+<para>
+ <literallayout>
+Robert Schwebel
+Pengutronix
+Hannoversche Straße 2
+31134 Hildesheim
+Tel. +49-5121-206917-0
+Fax: +49-5121-206917-9
+e-Mail: r.schwebel at pengutronix.de
+URI: http://www.pengutronix.de
+ </literallayout>
+</para>
+
+</appendix>
+
+</article>
Added: branches/fddi-mapping/doc/fddi_modbus_config_3s-20070710-7.odt
==============================================================================
Binary file. No diff available.
Added: branches/fddi-mapping/doc/fddi_proposal_3s-20070618-1.odt
==============================================================================
Binary file. No diff available.
Added: branches/fddi-mapping/doc/header.txt
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/doc/header.txt Tue Oct 2 16:30:06 2007
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2007 Robert Schwebel <r.schwebel at pengutronix.de>
+ *
+ * This file is part of the OSADL Fieldbus Framework.
+ *
+ * The OSADL Fieldbus Framework is free software; you can redistribute it
+ * and/or modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation. Note that there
+ * is a special link exception; see COPYING for details.
+ *
+ * The OSADL Fieldbus Framework 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 Lesser General Public
+ * License along with the OSADL Fieldbus Framework; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
Added: branches/fddi-mapping/include/GNUmakefile.am
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/include/GNUmakefile.am Tue Oct 2 16:30:06 2007
@@ -0,0 +1,17 @@
+noinst_HEADERS = \
+ fddistuff.h
+
+nobase_include_HEADERS = \
+ osadl/fddi.h \
+ osadl/fddi_device.h \
+ osadl/fddi_id.h \
+ osadl/fddi_iface.h \
+ osadl/fddi_param.h \
+ osadl/fddi_pv.h \
+ osadl/fddi_tpu.h \
+ osadl/fddi_types.h
+
+MAINTAINERCLEANFILES = \
+ fddi_config.h.in \
+ GNUmakefile.in
+
Added: branches/fddi-mapping/include/fddistuff.h
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/include/fddistuff.h Tue Oct 2 16:30:06 2007
@@ -0,0 +1,5 @@
+#ifndef FDDI_H
+#define FDDI_H
+
+
+#endif
Added: branches/fddi-mapping/include/osadl/attic/fddi_hess.h
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/include/osadl/attic/fddi_hess.h Tue Oct 2 16:30:06 2007
@@ -0,0 +1,434 @@
+#ifndef _OSADL_FDDI_H
+#define _OSADL_FDDI_H
+
+/* fieldbus device driver interface */
+
+
+/* #include "lldi.h" */
+typedef void *LL_INTERFACE;
+struct _io_interface_inst;
+struct _io_device;
+enum _io_device_command;
+
+/* result codes */
+#define RESOK 0
+#define RESERR_INTERFACE_ALREADY_REGISTERD 1
+#define RESERR_LLINTERFACE_ALREADY_IN_USE 2
+#define RESERR_LLINTERFACE_HAS_WRONG_TYPE 3
+#define RESERR_OUT_OF_MEM 4
+#define RESERR_TIMEOUT 5
+#define RESERR_NO_ACCESS 6
+#define RESERR_BUFFER_TO_SMALL 7
+#define RESERR_WRONGTPUTYPE 8
+#define RESERR_UNKOWNADDRESS 9
+
+/* io-interface */
+
+#if 0
+
+bind()
+configure()
+scan()
+read_device_async()
+write_device_async()
+cmd_device()
+
+#endif
+
+struct _io_interface
+{
+ char* name; /* name of the interface */
+ unsigned long version; /* version of the interface */
+
+ int (*_fptr_bind_io_interface)(char* name, LL_INTERFACE llitf, struct _io_interface_inst **result);
+ /* function pointer of the bind_io_interface method (see bind_io_interface for further information) */
+ int (*_fptr_configure_io_interface_inst)(struct _io_interface_inst *itfinst, struct _io_device *root);
+ /* function pointer of the configure_io_interface_inst method (see configure_io_interface for further information) */
+ int (*_fptr_scan_io_interface_inst)(struct _io_interface_inst *itfinst, struct _io_device **root);
+ /* function pointer of the scan_io_interface_inst method (see scan_io_interface_inst for further information) */
+ int (*_fptr_read_device_async)(struct _io_device *dev, unsigned long address, unsigned char* buf, unsigned long buf_size, unsigned long* read_size);
+ /* function pointer of the read_iodevice_async method (see scan_io_interface_inst for further information) */
+ int (*_fptr_write_device_async)(struct _io_device *dev, unsigned long address, unsigned char* buf, unsigned long size);
+ /* function pointer of the write_iodevice_async method (see scan_io_interface_inst for further information) */
+ int (*_fptr_cmd_device)(struct _io_device *dev, enum _io_device_command cmd);
+ /* function pointer of the cmd_iodevice method (see scan_io_interface_inst for further information) */
+};
+
+typedef struct _io_interface *IO_INTERFACE;
+
+
+/* instance of io-interface */
+struct _io_interface_inst
+{
+ char* name; /* name of the io-interface-instance */
+ IO_INTERFACE ioitf; /* the type of the io-interface */
+ LL_INTERFACE llitf; /* the low level interface, to which the io-interface is bound to */
+
+ struct _io_device *root; /* root device, set during configuration */
+
+ int num_tpus; /* number of io-transport units (set after configuration) */
+ struct _io_transport_unit **tpus; /* list of io-transport units (set after configuration by fddi-driver) */
+
+ int num_dev; /* number of devices */
+ struct _io_device **devlist; /* linear list of all devices (set automatically after configuration by fddi) */
+
+ int num_var; /* number of variables */
+ struct _io_variable **varlist; /* linear list of all variables (set after configuration by fddi-driver) */
+
+ void* inst_data; /* type specific management data */
+};
+
+typedef struct _io_interface_inst *IO_INTERFACE_INST;
+
+
+/* io-device */
+enum _io_device_state
+{
+ DEVSTATE_VOID, /* the device is not configured */
+ DEVSTATE_MISSING, /* the configuration of the device failed, because it is missing */
+ DEVSTATE_CONFIG_ERROR, /* the configuration of the device failed, because of wrong config data */
+ DEVSTATE_PREOPERATIONAL, /* the device is configured, but not working */
+ DEVSTATE_OPERATIONAL, /* the device is working */
+ DEVSTATE_OPERATION_ERROR /* the device encountered an error, while it is working */
+};
+
+typedef enum _io_device_state IO_DEVICE_STATE;
+
+enum _io_device_command
+{
+ DEVCMD_START, /* start the device */
+ DEVCMD_STOP, /* stop the device */
+ DEVCMD_RESET, /* reset the device */
+ DEVCMD_IDENTIFY, /* let the device do something to identify itself (like blinking with a LED) */
+ DEVCMD_QUITERR /* quit an error of the device, to return to normal operation */
+};
+
+typedef enum _io_device_command IO_DEVICE_COMMAND;
+/* use this datatype with the function cmd_iodevice */
+
+struct _io_device_param
+{
+ unsigned long key;
+ unsigned long value;
+ unsigned short flags;
+};
+
+#define PARAMFLAG_PTR 0 /* value contains a pointer to a struct (frist word of the struct is size) */
+#define PARAMFLAG_BYTE 1 /* value contais a byte */
+#define PARAMFLAG_WORD 2 /* value contains a word */
+#define PARAMFLAG_LONG 3 /* value contains a double word */
+#define PARAMFLAG_TYPEMASK 3 /* value contains a double word */
+#define PARAMFLAG_DEFAULT 4 /* value contains a device default parameter. the parameter is used to set up the configuration,
+ * but need not to be sent to the device
+ */
+
+typedef struct _io_device_param IO_DEVICE_PARAM;
+
+struct _io_device
+{
+ IO_INTERFACE_INST itfinst; /* reference to owning io-interface instance (set by fddi) */
+
+ unsigned long physical_id; /* physical id of the device */
+ unsigned long logical_id; /* logical id of the device */
+ unsigned long type_id; /* type id of the device */
+ char* name; /* optional name of the device (from configuration) */
+
+ int num_params; /* number of parameters */
+ IO_DEVICE_PARAM* params; /* pointer to list of parameters */
+
+ struct _io_device* parent; /* parent device */
+ struct _io_device* first_child; /* first child device of this device */
+ struct _io_device* next_child;/* next child of the same parent */
+
+ IO_DEVICE_STATE state; /* state of the device */
+};
+
+typedef struct _io_device *IO_DEVICE;
+
+#define MAXCALLBACKS 3
+
+/* io-transport unit */
+struct _io_transport_unit
+{
+ IO_INTERFACE_INST itfinst; /* reference to owning io-interface instance (set by fddi) */
+
+ unsigned long id;
+ unsigned long time_stamp;
+ unsigned long flags;
+ unsigned long size;
+ unsigned char* buf_read;
+ unsigned char* buf_write;
+
+ int num_callbacks;
+ void (*callback[MAXCALLBACKS])(struct _io_transport_unit *iotpu);
+
+ int read_count;
+ int write_count;
+
+ int num_var; /* number of variables */
+ struct _io_variable **varlist; /* linear list of all variables (set after configuration by fddi-driver) */
+};
+
+#define TPUFLAG_IN 1 /* application reads from this transport unit */
+#define TPUFLAG_OUT 2 /* application writes to this transport unit */
+#define TPUFLAG_SYNC 4 /* this transport unit synchronizes a group of io-devices */
+#define TPUFLAG_EXTMEM 8 /* the memory of this transport unit is not maintained by the fddi */
+#define TPUFLAG_CONSIST 16 /* the memory of this transport unit is kept consistent by the fddi (cannot be used with TPUFLAG_EXTMEM) */
+
+typedef struct _io_transport_unit *IO_TRANSPORT_UNIT;
+
+
+/* io-variable */
+struct _io_variable
+{
+ char* name; /* optional name of the variable */
+ unsigned long size; /* size of the variable */
+ unsigned long offset; /* offset of the variable in io-transport unit */
+
+ IO_TRANSPORT_UNIT iotpu;/* reference to io-transport unit */
+ IO_DEVICE iodev; /* reference to io-device */
+};
+
+typedef struct _io_variable *IO_VARIABLE;
+
+
+
+/* functions of the fddi */
+int register_io_interface(IO_INTERFACE ioitf);
+ /* registers a new io-interface to the fddi layer (for example a CANopen stack)
+ *
+ * ioitf: [in] the definition of the new interface
+ *
+ * result: RESOK, RESERR_INTERFACE_ALREADY_REGISTERD, RESERR_OUT_OF_MEM
+ *
+ * remarks: this function is only called by the module which implements his own driver
+ * it need not to be called by users of an existiong driver
+ */
+
+int bind_io_interface(IO_INTERFACE ioitf, char* name, LL_INTERFACE llitf, IO_INTERFACE_INST* res);
+ /* binds a io-interface to a hardware interface (for example a CANopen stack to CAN interface 1)
+ *
+ * name: [in] name of the interface instance (for example "CANopen on can1")
+ * The name can be used to open the instance
+ * llitf: [in] handle of the low level interface, to which the io_interface should be bound to
+ * res: [out] pointer to resulting interface instace
+ *
+ * result: RESOK, RESERR_LLINTERFACE_ALREADY_IN_USE, RESERR_LLINTERFACE_HAS_WRONG_TYPE, RESERR_OUT_OF_MEM
+ */
+
+int enum_io_interfaces(IO_INTERFACE** ioitfs);
+ /* enumerates all registered io-interfaces
+ *
+ * ioitfs: [out] pointer to pointer to an array of io_interfaces
+ *
+ * result: Because this function can never fail, the number of io_interfaces is returned
+ */
+
+int enum_io_interface_instances(IO_INTERFACE_INST** ioitfinsts);
+ /* enumerates all io-interface instances
+ *
+ * ioitfinsts: [out] pointer to pointer to an array of io-interfaces-instances
+ *
+ * result: Because this function can never fail, the number of io interfaces instances is returned
+ */
+
+IO_INTERFACE get_io_interface(char* name);
+ /* retrieves a io-interface by its name
+ *
+ * name: [in] name of the io-interface to retrieved
+ *
+ * result: the io-interface with the given name or null if the name was not found
+ */
+
+IO_INTERFACE_INST get_io_interface_inst(char* name);
+ /* retrieves a io-interface instance by its name
+ *
+ * name: [in] name of the io-interface instance to retrieved
+ *
+ * result: the io-interface instance with the given name or null if the name was not found
+ */
+
+int enum_io_transport_units(IO_INTERFACE_INST ioitfinst, IO_TRANSPORT_UNIT** iotpus);
+ /* enumerates all configured io-transport-units of an io-interface instances
+ *
+ * ioitfinst: [in] interface instance, which content should be enumerated
+ * iotpus: [out] pointer to pointer to an array of io-transport-units
+ *
+ * result: Because this function can never fail, the number of io-transport-units is returned
+ */
+
+int enum_io_devices(IO_INTERFACE_INST ioitfinst, IO_DEVICE** iodevices);
+ /* enumerates all configured io-devices of an io-interface instances as a flat list
+ *
+ * ioitfinst: [in] interface instance, which content should be enumerated
+ * iodevices: [out] pointer to pointer to an array of io-devices
+ *
+ * result: Because this function can never fail, the number of io-devices is returned
+ */
+
+int enum_io_variables(IO_INTERFACE_INST ioitfinst, IO_VARIABLE** iovars);
+ /* enumerates all configured io-variables of an io-interface instances
+ *
+ * ioitfinst: [in] interface instance, which content should be enumerated
+ * iovars: [out] pointer to pointer to an array of io-variables
+ *
+ * result: Because this function can never fail, the number of io-variables is returned
+ */
+
+int configure_io_interface_inst(IO_INTERFACE_INST ioitfinst, IO_DEVICE root);
+ /* configures a io-interface instance
+ *
+ * ioitfinst: [in] the interface to be configured
+ * root: [in] root node, which contains the configured child nodes.
+ * Typically the root node contains the interface hardware and the childs are the fieldbus slaves.
+ * The following members of IO_DEVICE are expected to be set correctly in each node:
+ *
+ * logical_id;
+ * type_id;
+ * name; (optional)
+ *
+ * num_params;
+ * params;
+ *
+ * parent;
+ * first_child;
+ * next_child;
+ *
+ * result: RESOK, RESERR_OUT_OF_MEM
+ * remarks: all previous configurations are disgarded.
+ * configuration can take some time. it can be useful to do process it in a extra thread with a timeout.
+ */
+
+int scan_io_interface_inst(IO_INTERFACE_INST itfinst, IO_DEVICE *root);
+ /* scans a io-interface instance for all connected devices
+ *
+ * ioitfinst: [in] the interface to be scanned
+ * root: [out] root node, which contains the connected child nodes. The following members of IO_DEVICE
+ * are set:
+ *
+ * pysical_id
+ * logical_id;
+ * type_id;
+ * name; (optional)
+ *
+ * parent;
+ * first_child;
+ * next_child;
+ *
+ * result: RESOK, RESERR_OUT_OF_MEM
+ * remarks: a previous configurations is not disgarded.
+ * scan can take some time. it can be useful to do process it in a extra thread with a timeout.
+ */
+
+int read_iodevice_async(IO_DEVICE iodev, unsigned long address, unsigned char* buf, unsigned long buf_size, unsigned long* read_size);
+ /* performs an asynchronous read (for example CANopen SDO, Profibus DPV1 etc.) on an io-device
+ *
+ * iodev: [in] device on which the read operation is done
+ * address: [in] address in the device
+ * buf: [out] buffer to receive the result
+ * buf_size:[in] size of the buffer / size of the data to read
+ * read_size:[out] size of the data, which was actually read
+ *
+ * result: RESOK, RESERR_TIMEOUT, RESERR_NO_ACCESS, RESERR_BUFFER_TO_SMALL
+ * remarks: async read can take some time. it can be useful to do process it in a extra thread with a timeout.
+ */
+
+int write_iodevice_async(IO_DEVICE iodev, unsigned long address, unsigned char* buf, unsigned long size);
+ /* performs an asynchronous write (for example CANopen SDO, Profibus DPV1 etc.) on an io-device
+ *
+ * iodev: [in] device on which the write operation is done
+ * address: [in] address in the device
+ * buf: [in] buffer with the data to write
+ * buf_size:[in] size of the data to write
+ *
+ * result: RESOK, RESERR_TIMEOUT, RESERR_NO_ACCESS
+ * remarks: async write can take some time. it can be useful to do process it in a extra thread with a timeout.
+ */
+
+int cmd_iodevice(IO_DEVICE iodev, IO_DEVICE_COMMAND cmd);
+ /* performs a command like start, stop, reset on an io-device
+ *
+ * iodev: [in] device on which the command should be done
+ * cmd: [in] the command (see definition of IO_DEVICE_COMMAND)
+ *
+ * result: RESOK, RESERR_TIMEOUT, RESERR_NO_ACCESS
+ * remarks: cmd_iodevice can take some time. it can be useful to do process it in a extra thread with a timeout.
+ * a command done on the root device typically, executes the command for all devices (start, stop)
+ */
+
+int enum_io_variables_of_iodevice(IO_DEVICE iodev, IO_VARIABLE** iovars);
+ /* enumerates all configured io-variables of an io-device
+ *
+ * iodev: [in] device, which content should be enumerated
+ * iovars: [out] pointer to pointer to an array of io-variables
+ *
+ * result: Because this function can never fail, the number of io-variables is returned
+ */
+
+unsigned char* address_to_read(IO_TRANSPORT_UNIT iotpu);
+ /* Get the adress of the process data of a io-transport unit to read on it
+ *
+ * iotpu: [in] transport unit of which the address is retrieved
+ *
+ * result: the address
+ * remarks: only read operations should be done on the memory area.
+ * use release_address after finishing read operations.
+ */
+
+unsigned char* address_to_write(IO_TRANSPORT_UNIT iotpu);
+ /* Get the address of the process data of a io-transport unit to write (modify) it
+ *
+ * iotpu: [in] transport unit of which the address is retrieved
+ *
+ * result: the adress
+ * remarks: if the complete memory of the io-transport unit is written, use address_to_replace, because it may be faster.
+ * use release_adress after finishing write operations.
+ */
+
+unsigned char* address_to_replace(IO_TRANSPORT_UNIT iotpu);
+ /* Get the address of the process data of a io-transport unit to write the complete process data
+ *
+ * iotpu: [in] transport unit of which the address is retrieved
+ *
+ * result: the adress
+ * remarks: this function is faster on consistent transport units than address_to_write
+ * use release_adress after finishing write operations.
+ */
+
+int release_adress(IO_TRANSPORT_UNIT iotpu, unsigned char* address);
+ /* Releases an address, previously retrieved by address_to_read, address_to_write, address_to_replace
+ *
+ * iotpu: [in] transport unit of which the address is released
+ * address: [in] address to release
+ *
+ * result: RESOK, RESERR_UNKOWNADDRESS
+ */
+
+int send_iotransport_unit(IO_TRANSPORT_UNIT iotpu);
+ /* Explcitly send an io-transport unit, to do I/O syncronously, application triggered
+ *
+ * iotpu: [in] transport unit which is to be sent
+ *
+ * result: RESOK, RESERR_WRONGTPUTYPE
+ */
+
+int register_callback_to_iotransport_unit(IO_TRANSPORT_UNIT iotpu, void (*callback)(IO_TRANSPORT_UNIT iotpu));
+ /* Registers a callback function to a io-transport unit, to do I/O synchronously, IO-system triggered
+ *
+ * iotpu: [in] transport unit which should trigger the callback
+ * callback:[in] callback function, which supplies a reference to the io-transport unit as parameter
+ *
+ * result: RESOK, RESERR_WRONGTPUTYPE
+ * remarks: the callback is called after a write operation is finished (release_address) on the given transport unit
+ */
+
+int enum_io_variables_of_iotransport_unit(IO_TRANSPORT_UNIT iotpu, IO_VARIABLE** iovars);
+ /* enumerates all configured io-variables of an io-transport-unit
+ *
+ * iotpu: [in] transport unit, which content should be enumerated
+ * iovars: [out] pointer to pointer to an array of io-variables
+ *
+ * result: Because this function can never fail, the number of io-variables is returned
+ */
+#endif
+
Added: branches/fddi-mapping/include/osadl/fddi.h
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/include/osadl/fddi.h Tue Oct 2 16:30:06 2007
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2007 Robert Schwebel <r.schwebel at pengutronix.de>
+ *
+ * This file is part of the OSADL Fieldbus Framework.
+ *
+ * The OSADL Fieldbus Framework is free software; you can redistribute it
+ * and/or modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation. Note that there
+ * is a special link exception; see COPYING for details.
+ *
+ * The OSADL Fieldbus Framework 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 Lesser General Public
+ * License along with the OSADL Fieldbus Framework; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#ifndef OSADL_FDDI_H
+#define OSADL_FDDI_H
+
+#include <osadl/fddi_types.h>
+#include <osadl/fddi_device.h>
+#include <osadl/fddi_iface.h>
+#include <osadl/fddi_param.h>
+#include <osadl/fddi_pv.h>
+#include <osadl/fddi_pv_attr.h>
+#include <osadl/fddi_pv_engine.h>
+#include <osadl/fddi_pv_group.h>
+#include <osadl/fddi_pv_group_attr.h>
+#include <osadl/fddi_tpu.h>
+
+#endif
Added: branches/fddi-mapping/include/osadl/fddi_device.h
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/include/osadl/fddi_device.h Tue Oct 2 16:30:06 2007
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2007 Robert Schwebel <r.schwebel at pengutronix.de>
+ *
+ * This file is part of the OSADL Fieldbus Framework.
+ *
+ * The OSADL Fieldbus Framework is free software; you can redistribute it
+ * and/or modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation. Note that there
+ * is a special link exception; see COPYING for details.
+ *
+ * The OSADL Fieldbus Framework 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 Lesser General Public
+ * License along with the OSADL Fieldbus Framework; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#ifndef OSADL_FDDI_DEVICE_H
+#define OSADL_FDDI_DEVICE_H
+
+#include <osadl/fddi_types.h>
+#include <osadl/fddi_id.h>
+
+struct fddi_device {
+
+ /* public */
+ fddi_id_t id;
+ fddi_state_enum_t state;
+
+ /* private */
+ struct fddi_device *next;
+ struct fddi_device *previous;
+
+ fddi_param_t *param_list;
+
+ void *priv;
+
+};
+
+/* fddi_device_t */
+extern int fddi_dev_getnext(fddi_device_t **dev);
+extern int fddi_dev_getname(fddi_device_t *dev, char **name);
+extern int fddi_dev_getstate(fddi_device_t *dev, fddi_state_enum_t *state);
+extern int fddi_dev_getstatestr(fddi_device_t *dev, char **state);
+extern int fddi_dev_getphysid(fddi_device_t *dev, int *id);
+extern int fddi_dev_getlogicalid(fddi_device_t *dev, int *id);
+extern int fddi_dev_getparamlist(fddi_device_t *dev, fddi_param_t **param);
+extern int fddi_dev_getnotpus(fddi_device_t *dev);
+extern int fddi_dev_read_async(fddi_device_t *dev /* FIXME */);
+extern int fddi_dev_write_async(fddi_device_t *dev /* FIXME */);
+
+#endif
+
Added: branches/fddi-mapping/include/osadl/fddi_id.h
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/include/osadl/fddi_id.h Tue Oct 2 16:30:06 2007
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2007 Robert Schwebel <r.schwebel at pengutronix.de>
+ *
+ * This file is part of the OSADL Fieldbus Framework.
+ *
+ * The OSADL Fieldbus Framework is free software; you can redistribute it
+ * and/or modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation. Note that there
+ * is a special link exception; see COPYING for details.
+ *
+ * The OSADL Fieldbus Framework 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 Lesser General Public
+ * License along with the OSADL Fieldbus Framework; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#ifndef OSADL_FDDI_ID_H
+#define OSADL_FDDI_ID_H
+
+#include <stdlib.h>
+
+#include <osadl/fddi_types.h>
+
+struct fddi_id {
+
+ /* public */
+
+ /* private */
+ char *prefix;
+ int index;
+ char *suffix;
+
+ char *id_as_string;
+ size_t id_as_str_len;
+
+ void *priv;
+};
+
+extern int fddi_id_init(fddi_id_t *fddi_id, const char *prefix, int index, const char *suffix);
+extern int fddi_id_getid(fddi_id_t *fddi_id, char *id_string, size_t len);
+extern int fddi_id_destroy(fddi_id_t *fddi_id);
+
+#endif
+
Added: branches/fddi-mapping/include/osadl/fddi_iface.h
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/include/osadl/fddi_iface.h Tue Oct 2 16:30:06 2007
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2007 Robert Schwebel <r.schwebel at pengutronix.de>
+ *
+ * This file is part of the OSADL Fieldbus Framework.
+ *
+ * The OSADL Fieldbus Framework is free software; you can redistribute it
+ * and/or modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation. Note that there
+ * is a special link exception; see COPYING for details.
+ *
+ * The OSADL Fieldbus Framework 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 Lesser General Public
+ * License along with the OSADL Fieldbus Framework; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#ifndef OSADL_FDDI_IFACE_H
+#define OSADL_FDDI_IFACE_H
+
+#include <osadl/fddi_types.h>
+
+struct fddi_iface_attr {
+
+ /* public */
+ char *path;
+ fddi_id_t id;
+
+ char *fddi_class_name; /* FIXME */
+
+};
+
+struct fddi_iface_backend_ops {
+
+ int (*init) (fddi_iface_t *iface);
+ int (*destroy) (fddi_iface_t *iface);
+ int (*configure) (fddi_iface_t *iface, const char *configfile, void *data);
+ int (*setstate) (fddi_iface_t *iface, fddi_state_enum_t state);
+ int (*cmd) (fddi_iface_t *iface, fddi_cmd_enum_t cmd);
+
+};
+
+struct fddi_iface {
+
+ /* public */
+ fddi_id_t id;
+ fddi_state_enum_t state;
+
+ /* private */
+ fddi_device_t *devlist_head;
+ unsigned int nodev;
+
+ fddi_tpu_t *tpulist_head;
+ unsigned int notpus;
+
+ unsigned int nopvs;
+
+ void *backend_lib;
+ fddi_iface_backend_ops_t backend;
+
+ void *priv;
+};
+
+/* fddi_iface_attr_t */
+extern int fddi_iface_attr_init(fddi_iface_attr_t *attr);
+extern int fddi_iface_attr_setclass(fddi_iface_attr_t *attr, char *fddi_class_name);
+extern int fddi_iface_attr_setid(fddi_iface_attr_t *attr, const char *path, fddi_id_t device_id);
+
+/* fddi_iface_t */
+extern int fddi_iface_init(fddi_iface_t *iface, fddi_iface_attr_t *attr);
+extern int fddi_iface_destroy(fddi_iface_t *iface);
+extern int fddi_iface_configure(fddi_iface_t *iface, const char *configfile, void *data);
+extern int fddi_iface_setstate(fddi_iface_t *iface, fddi_state_enum_t state);
+extern int fddi_iface_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd);
+extern int fddi_iface_getid(fddi_iface_t *iface, fddi_id_t *id);
+extern int fddi_iface_setid(fddi_iface_t *iface, fddi_id_t id);
+extern int fddi_iface_getnodev(fddi_iface_t *iface);
+extern int fddi_iface_getnotpus(fddi_iface_t *iface);
+extern int fddi_iface_getnopvs(fddi_iface_t *iface);
+extern int fddi_iface_getdevlist(fddi_iface_t *iface, fddi_device_t **dev);
+extern int fddi_iface_gettpulist(fddi_iface_t *iface, fddi_tpu_t **tpu);
+extern int fddi_iface_getversionstr(fddi_iface_t *iface, const char **version);
+extern int fddi_iface_getversion(fddi_iface_t *iface, int *version);
+/*
+ * TODO: split public/private
+ * TODO: add_tpu(), with counts
+ * TODO: add_pv(), with counts
+ */
+
+#endif
+
Added: branches/fddi-mapping/include/osadl/fddi_param.h
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/include/osadl/fddi_param.h Tue Oct 2 16:30:06 2007
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2007 Robert Schwebel <r.schwebel at pengutronix.de>
+ *
+ * This file is part of the OSADL Fieldbus Framework.
+ *
+ * The OSADL Fieldbus Framework is free software; you can redistribute it
+ * and/or modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation. Note that there
+ * is a special link exception; see COPYING for details.
+ *
+ * The OSADL Fieldbus Framework 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 Lesser General Public
+ * License along with the OSADL Fieldbus Framework; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#ifndef OSADL_FDDI_PARAM_H
+#define OSADL_FDDI_PARAM_H
+
+#include <osadl/fddi_types.h>
+
+struct fddi_param {
+
+ /* public */
+ char *key;
+ char *val;
+ unsigned long flags;
+
+ /* private */
+ struct fddi_param *next;
+ struct fddi_param *previous;
+
+ void *priv;
+
+};
+
+/* fddi_param_t */
+extern int fddi_param_getnext(fddi_param_t **param);
+extern int fddi_param_getkey(fddi_param_t *param, char **val);
+extern int fddi_param_getval(fddi_param_t *param, char **val);
+extern int fddi_param_getflags(fddi_param_t *param, unsigned long *flags); /* FIXME */
+extern int fddi_param_getnotpus(fddi_param_t *param, int *notpus);
+
+#endif
+
Added: branches/fddi-mapping/include/osadl/fddi_pv.h
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/include/osadl/fddi_pv.h Tue Oct 2 16:30:06 2007
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2007 Robert Schwebel <r.schwebel at pengutronix.de>
+ *
+ * This file is part of the OSADL Fieldbus Framework.
+ *
+ * The OSADL Fieldbus Framework is free software; you can redistribute it
+ * and/or modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation. Note that there
+ * is a special link exception; see COPYING for details.
+ *
+ * The OSADL Fieldbus Framework 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 Lesser General Public
+ * License along with the OSADL Fieldbus Framework; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#ifndef OSADL_FDDI_PV_H
+#define OSADL_FDDI_PV_H
+
+#include <stdint.h>
+
+#include <osadl/fddi_types.h>
+#include <osadl/fddi_id.h>
+
+struct fddi_pv {
+
+ /* public */
+ fddi_id_t id;
+ fddi_param_t *name;
+ fddi_pv_type_enum_t type;
+
+ /* private */
+ struct fddi_pv *next;
+ struct fddi_pv *previous;
+ fddi_param_t *param_list_head;
+ unsigned int offset;
+ unsigned int bit;
+
+ void *priv;
+};
+
+/* fddi_pv_t */
+extern int fddi_pv_uint32_init(fddi_pv_t *pv, fddi_pv_attr_t *attr);
+extern int fddi_pv_uint32_destroy(fddi_pv_t *pv);
+extern uint32_t fddi_pv_uint32_get(fddi_pv_t *pv);
+extern void fddi_pv_uint32_set(fddi_pv_t *pv, uint32_t val);
+#define fddi_pv_UINT32_init fddi_pv_uint32_init
+#define fddi_pv_UINT32_destroy fddi_pv_uint32_destroy
+#define fddi_pv_UINT32_get fddi_pv_uint32_get
+#define fddi_pv_UINT32_set fddi_pv_uint32_set
+
+/* FIXME: add other data types */
+
+extern int fddi_pv_getnext(fddi_pv_t **pv);
+extern int fddi_pv_getname(fddi_pv_t *pv, char **name);
+
+#endif
+
Added: branches/fddi-mapping/include/osadl/fddi_pv_attr.h
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/include/osadl/fddi_pv_attr.h Tue Oct 2 16:30:06 2007
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2007 Robert Schwebel <r.schwebel at pengutronix.de>
+ *
+ * This file is part of the OSADL Fieldbus Framework.
+ *
+ * The OSADL Fieldbus Framework is free software; you can redistribute it
+ * and/or modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation. Note that there
+ * is a special link exception; see COPYING for details.
+ *
+ * The OSADL Fieldbus Framework 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 Lesser General Public
+ * License along with the OSADL Fieldbus Framework; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#ifndef OSADL_FDDI_PV_ATTR_H
+#define OSADL_FDDI_PV_ATTR_H
+
+#include <osadl/fddi_types.h>
+#include <osadl/fddi_pv.h>
+#include <osadl/fddi_pv_group.h>
+
+struct fddi_pv_attr {
+
+ /* public */
+ fddi_pv_type_enum_t type;
+
+ char *name;
+ fddi_pv_group_t *pv_group;
+
+ /* private */
+
+ void *priv;
+
+};
+
+/* fddi_pv_t */
+extern int fddi_pv_attr_init(fddi_pv_attr_t *pv_attr, fddi_pv_group_t *pv_group, const char *name);
+extern int fddi_pv_attr_destroy(fddi_pv_attr_t *pv_attr);
+
+#endif
+
Added: branches/fddi-mapping/include/osadl/fddi_pv_engine.h
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/include/osadl/fddi_pv_engine.h Tue Oct 2 16:30:06 2007
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2007 Robert Schwebel <r.schwebel at pengutronix.de>
+ *
+ * This file is part of the OSADL Fieldbus Framework.
+ *
+ * The OSADL Fieldbus Framework is free software; you can redistribute it
+ * and/or modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation. Note that there
+ * is a special link exception; see COPYING for details.
+ *
+ * The OSADL Fieldbus Framework 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 Lesser General Public
+ * License along with the OSADL Fieldbus Framework; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#ifndef OSADL_FDDI_PV_ENGINE_H
+#define OSADL_FDDI_PV_ENGINE_H
+
+#include <osadl/fddi_types.h>
+
+struct fddi_pv_engine {
+
+ /* public */
+
+ /* private */
+
+ void *priv;
+};
+
+/* pv_engine_t */
+extern int fddi_pv_engine_init(fddi_pv_engine_t *pv_engine);
+extern int fddi_pv_engine_destroy(fddi_pv_engine_t *pv_engine);
+extern int fddi_pv_engine_configure_from_cmdline(fddi_pv_engine_t *pv_engine, int argc, char *argv[]);
+
+#endif
+
Added: branches/fddi-mapping/include/osadl/fddi_pv_group.h
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/include/osadl/fddi_pv_group.h Tue Oct 2 16:30:06 2007
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2007 Robert Schwebel <r.schwebel at pengutronix.de>
+ *
+ * This file is part of the OSADL Fieldbus Framework.
+ *
+ * The OSADL Fieldbus Framework is free software; you can redistribute it
+ * and/or modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation. Note that there
+ * is a special link exception; see COPYING for details.
+ *
+ * The OSADL Fieldbus Framework 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 Lesser General Public
+ * License along with the OSADL Fieldbus Framework; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#ifndef OSADL_FDDI_PV_GROUP_H
+#define OSADL_FDDI_PV_GROUP_H
+
+#include <osadl/fddi_types.h>
+#include <osadl/fddi_pv_group_attr.h>
+
+struct fddi_pv_group {
+
+ /* public */
+
+ /* private */
+
+ void *priv;
+};
+
+/* fddi_pv_group_t */
+extern int fddi_pv_group_init(fddi_pv_group_t *pv_group, fddi_pv_group_attr_t *attr);
+extern int fddi_pv_group_destroy(fddi_pv_group_t *pv_group);
+extern int fddi_pv_group_wait_and_lock(fddi_pv_group_t *pv_group);
+extern int fddi_pv_group_unlock(fddi_pv_group_t *pv_group);
+
+#endif
+
Added: branches/fddi-mapping/include/osadl/fddi_pv_group_attr.h
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/include/osadl/fddi_pv_group_attr.h Tue Oct 2 16:30:06 2007
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2007 Robert Schwebel <r.schwebel at pengutronix.de>
+ *
+ * This file is part of the OSADL Fieldbus Framework.
+ *
+ * The OSADL Fieldbus Framework is free software; you can redistribute it
+ * and/or modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation. Note that there
+ * is a special link exception; see COPYING for details.
+ *
+ * The OSADL Fieldbus Framework 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 Lesser General Public
+ * License along with the OSADL Fieldbus Framework; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#ifndef OSADL_FDDI_PV_GROUP_ATTR_H
+#define OSADL_FDDI_PV_GROUP_ATTR_H
+
+#include <osadl/fddi_types.h>
+
+struct fddi_pv_group_attr {
+
+ /* public */
+
+ /* private */
+
+ void *priv;
+
+};
+
+/* fddi_pv_group_attr_t */
+extern int fddi_pv_group_attr_init(fddi_pv_group_attr_t *pv_group_attr, fddi_pv_engine_t *pv_engine);
+extern int fddi_pv_group_attr_destroy(fddi_pv_group_attr_t *pv_group_attr);
+extern int fddi_pv_group_attr_setname(fddi_pv_group_attr_t *pv_group_attr, const char *name);
+
+#endif
+
Added: branches/fddi-mapping/include/osadl/fddi_tpu.h
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/include/osadl/fddi_tpu.h Tue Oct 2 16:30:06 2007
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2007 Robert Schwebel <r.schwebel at pengutronix.de>
+ *
+ * This file is part of the OSADL Fieldbus Framework.
+ *
+ * The OSADL Fieldbus Framework is free software; you can redistribute it
+ * and/or modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation. Note that there
+ * is a special link exception; see COPYING for details.
+ *
+ * The OSADL Fieldbus Framework 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 Lesser General Public
+ * License along with the OSADL Fieldbus Framework; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#ifndef OSADL_FDDI_TPU_H
+#define OSADL_FDDI_TPU_H
+
+#include <osadl/fddi_types.h>
+
+typedef enum {
+
+ IN,
+ OUT,
+ INOUT,
+
+} fddi_tpu_direction_enum_t;
+
+struct fddi_tpu {
+
+ /* public */
+ fddi_id_t id;
+ uint64_t cycletime; /* ns */
+ fddi_tpu_direction_enum_t direction;
+
+ /* private */
+ struct fddi_tpu *next; /* TODO: generic list */
+ struct fddi_tpu *previous;
+
+ fddi_pv_t *pv_list_head;
+ char *payload;
+
+ void *callback_arg;
+ int (*callback) (fddi_tpu_t *tpu, void *arg);
+
+ void *priv;
+
+};
+
+/* fddi_tpu_t */
+extern int fddi_tpu_getnext(fddi_tpu_t **tpu);
+extern int fddi_tpu_getid(fddi_tpu_t *tpu, fddi_id_t *id);
+extern int fddi_tpu_gettimestamp(fddi_tpu_t *tpu, int *timestamp); /* FIXME tv */
+extern int fddi_tpu_setcallback(fddi_tpu_t *tpu, int(*tpu_callback)(fddi_tpu_t *tpu, void *arg), void *arg);
+extern int fddi_tpu_getpvlist(fddi_tpu_t *tpu, fddi_pv_t **pv);
+extern int fddi_tpu_getpayload(fddi_tpu_t *tpu, char **payload);
+extern int fddi_tpu_transfer(fddi_tpu_t *tpu);
+
+#endif
Added: branches/fddi-mapping/include/osadl/fddi_types.h
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/include/osadl/fddi_types.h Tue Oct 2 16:30:06 2007
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2007 Robert Schwebel <r.schwebel at pengutronix.de>
+ *
+ * This file is part of the OSADL Fieldbus Framework.
+ *
+ * The OSADL Fieldbus Framework is free software; you can redistribute it
+ * and/or modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation. Note that there
+ * is a special link exception; see COPYING for details.
+ *
+ * The OSADL Fieldbus Framework 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 Lesser General Public
+ * License along with the OSADL Fieldbus Framework; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#ifndef OSADL_FDDI_TYPES_H
+#define OSADL_FDDI_TYPES_H
+
+typedef enum fddi_state_enum fddi_state_enum_t;
+typedef enum fddi_cmd_enum fddi_cmd_enum_t;
+
+enum fddi_state_enum {
+
+ STATE_UNCONFIGURED, /* the device is not configured */
+ STATE_MISSING, /* the configuration of the device failed, because it is missing */
+ STATE_CONFIG_ERROR, /* the configuration of the device failed, because of wrong config data */
+ STATE_PREOPERATIONAL, /* the device is configured, but not working */
+ STATE_OPERATIONAL, /* the device is working */
+ STATE_OPERATION_ERROR /* the device encountered an error, while it is working */
+
+};
+
+enum fddi_cmd_enum {
+
+ CMD_START, /* start the device */
+ CMD_STOP, /* stop the device */
+ CMD_RESET, /* reset the device */
+ CMD_IDENTIFY, /* let the device do something to identify itself (like blinking with a LED) */
+ CMD_QUITERR /* quit an error of the device, to return to normal operation */
+
+};
+
+typedef enum {
+
+ /* little endian */
+ LE_UINT8,
+ LE_UINT16,
+ LE_UINT32,
+ LE_UINT64,
+
+ LE_INT8,
+ LE_INT16,
+ LE_INT32,
+ LE_INT64,
+
+ LE_FLOAT,
+ LE_DOUBLE,
+
+ /* big endian */
+ BE_UINT8,
+ BE_UINT16,
+ BE_UINT32,
+ BE_UINT64,
+
+ BE_INT8,
+ BE_INT16,
+ BE_INT32,
+ BE_INT64,
+
+ BE_FLOAT,
+ BE_DOUBLE,
+
+ /* native endianess */
+ UINT8,
+ UINT16,
+ UINT32,
+ UINT64,
+
+ INT8,
+ INT16,
+ INT32,
+ INT64,
+
+ FLOAT,
+ DOUBLE,
+
+ /* FIXME does endianess matter for bool? */
+
+ BOOL,
+
+} fddi_pv_type_enum_t;
+
+typedef struct fddi_id fddi_id_t;
+typedef struct fddi_param fddi_param_t;
+typedef struct fddi_device fddi_device_t;
+typedef struct fddi_iface_attr fddi_iface_attr_t;
+typedef struct fddi_pv fddi_pv_t;
+typedef struct fddi_pv_attr fddi_pv_attr_t;
+typedef struct fddi_pv_engine fddi_pv_engine_t;
+typedef struct fddi_pv_group fddi_pv_group_t;
+typedef struct fddi_pv_group_attr fddi_pv_group_attr_t;
+typedef struct fddi_tpu fddi_tpu_t;
+typedef struct fddi_iface_backend_ops fddi_iface_backend_ops_t;
+typedef struct fddi_iface fddi_iface_t;
+
+#endif
+
Added: branches/fddi-mapping/src/GNUmakefile.am
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/src/GNUmakefile.am Tue Oct 2 16:30:06 2007
@@ -0,0 +1,65 @@
+BACKEND_LIBS =
+if BACKEND_LIBMODBUS
+BACKEND_LIBS += libfddi_libmodbus.la
+endif
+if BACKEND_CAN
+BACKEND_LIBS += libfddi_can.la
+endif
+
+lib_LTLIBRARIES = \
+ libfddi.la \
+ $(BACKEND_LIBS)
+
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/include \
+ -I$(top_builddir)/include \
+ $(INCLTDL)
+
+#
+# libfddi
+#
+
+libfddi_la_SOURCES = \
+ libfddi.c \
+ fddi_pv_group.c \
+ fddi_pv_engine.c \
+ fddi_pv_group_attr.c \
+ fddi_pv.c
+
+libfddi_la_LDFLAGS = \
+ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
+ -no-undefined \
+ -export-dynamic
+
+libfddi_la_LIBADD = \
+ $(LIBLTDL)
+
+#
+# libfddi_modbusmaster
+#
+
+libfddi_libmodbus_la_SOURCES = \
+ libfddi_libmodbus.c
+
+libfddi_libmodbus_la_CPPFLAGS = \
+ $(libmodbus_CFLAGS)
+
+libfddi_libmodbus_la_LIBADD = \
+ $(top_builddir)/src/libfddi.la \
+ $(libmodbus_LIBS)
+
+#
+# libfddi_can
+#
+
+libfddi_can_la_SOURCES = \
+ libfddi_can.c
+
+libfddi_can_la_CPPFLAGS = \
+ -DPF_CAN=29 -DAF_CAN=PF_CAN
+
+# libfddi_can_la_LIBADD =
+
+MAINTAINERCLEANFILES = \
+ GNUmakefile.in
+
Added: branches/fddi-mapping/src/fddi_pv.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/src/fddi_pv.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2007 Robert Schwebel <r.schwebel at pengutronix.de>
+ *
+ * This file is part of the OSADL Fieldbus Framework.
+ *
+ * The OSADL Fieldbus Framework is free software; you can redistribute it
+ * and/or modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation. Note that there
+ * is a special link exception; see COPYING for details.
+ *
+ * The OSADL Fieldbus Framework 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 Lesser General Public
+ * License along with the OSADL Fieldbus Framework; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#include <errno.h>
+
+#include <osadl/fddi_pv.h>
+
+int fddi_pv_uint32_init(fddi_pv_t *pv, fddi_pv_attr_t *attr)
+{
+ return 0;
+}
+
+int fddi_pv_uint32_destroy(fddi_pv_t *pv)
+{
+ return 0;
+}
+
+uint32_t fddi_pv_uint32_get(fddi_pv_t *pv)
+{
+ return 0;
+}
+
+void fddi_pv_uint32_set(fddi_pv_t *pv, uint32_t val)
+{
+ return;
+}
+
+int fddi_pv_getnext(fddi_pv_t **pv)
+{
+ if (!pv)
+ return EINVAL;
+
+ *pv = (*pv)->next;
+ return 0;
+}
+
+int fddi_pv_getid(fddi_pv_t *pv, fddi_id_t *id)
+{
+ if ((!pv) || (!id))
+ return EINVAL;
+
+ memcpy(id, &pv->id, sizeof(fddi_id_t));
+
+ return 0;
+}
+
+int fddi_pv_getname(fddi_pv_t *pv, char **name)
+{
+ return 0;
+}
Added: branches/fddi-mapping/src/fddi_pv_engine.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/src/fddi_pv_engine.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2007 Robert Schwebel <r.schwebel at pengutronix.de>
+ *
+ * This file is part of the OSADL Fieldbus Framework.
+ *
+ * The OSADL Fieldbus Framework is free software; you can redistribute it
+ * and/or modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation. Note that there
+ * is a special link exception; see COPYING for details.
+ *
+ * The OSADL Fieldbus Framework 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 Lesser General Public
+ * License along with the OSADL Fieldbus Framework; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#include <osadl/fddi_pv_engine.h>
+
+int fddi_pv_engine_init(fddi_pv_engine_t *pv_engine)
+{
+ return 0;
+}
+
+int fddi_pv_engine_destroy(fddi_pv_engine_t *pv_engine)
+{
+ return 0;
+}
+
+int fddi_pv_engine_configure_from_cmdline(fddi_pv_engine_t *pv_engine, int argc, char *argv[])
+{
+ return 0;
+}
+
+
Added: branches/fddi-mapping/src/fddi_pv_group.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/src/fddi_pv_group.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2007 Robert Schwebel <r.schwebel at pengutronix.de>
+ *
+ * This file is part of the OSADL Fieldbus Framework.
+ *
+ * The OSADL Fieldbus Framework is free software; you can redistribute it
+ * and/or modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation. Note that there
+ * is a special link exception; see COPYING for details.
+ *
+ * The OSADL Fieldbus Framework 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 Lesser General Public
+ * License along with the OSADL Fieldbus Framework; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#include <osadl/fddi_pv_group.h>
+
+int fddi_pv_group_init(fddi_pv_group_t *pv_group, fddi_pv_group_attr_t *attr)
+{
+ return 0;
+}
+
+int fddi_pv_group_destroy(fddi_pv_group_t *pv_group)
+{
+ return 0;
+}
+
+int fddi_pv_group_wait_and_lock(fddi_pv_group_t *pv_group)
+{
+ return 0;
+}
+
+int fddi_pv_group_unlock(fddi_pv_group_t *pv_group)
+{
+ return 0;
+}
+
Added: branches/fddi-mapping/src/fddi_pv_group_attr.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/src/fddi_pv_group_attr.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2007 Robert Schwebel <r.schwebel at pengutronix.de>
+ *
+ * This file is part of the OSADL Fieldbus Framework.
+ *
+ * The OSADL Fieldbus Framework is free software; you can redistribute it
+ * and/or modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation. Note that there
+ * is a special link exception; see COPYING for details.
+ *
+ * The OSADL Fieldbus Framework 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 Lesser General Public
+ * License along with the OSADL Fieldbus Framework; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#include <osadl/fddi_pv_group_attr.h>
+
+int fddi_pv_group_attr_init(fddi_pv_group_attr_t *pv_group_attr, fddi_pv_engine_t *pv_engine)
+{
+ return 0;
+}
+
+int fddi_pv_group_attr_destroy(fddi_pv_group_attr_t *pv_group_attr)
+{
+ return 0;
+}
+
+int fddi_pv_group_attr_setname(fddi_pv_group_attr_t *pv_group_attr, const char *name)
+{
+ return 0;
+}
+
+
Added: branches/fddi-mapping/src/libfddi.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/src/libfddi.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,564 @@
+/*
+ * Copyright (C) 2007 Robert Schwebel <r.schwebel at pengutronix.de>
+ *
+ * This file is part of the OSADL Fieldbus Framework.
+ *
+ * The OSADL Fieldbus Framework is free software; you can redistribute it
+ * and/or modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation. Note that there
+ * is a special link exception; see COPYING for details.
+ *
+ * The OSADL Fieldbus Framework 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 Lesser General Public
+ * License along with the OSADL Fieldbus Framework; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA.
+ */
+
+#include <errno.h>
+#include <ltdl.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <osadl/fddi.h>
+#include <fddi_config.h>
+
+static pthread_mutex_t lt_dl_mutex = PTHREAD_MUTEX_INITIALIZER;
+const char fddi_version_str[] = VERSION;
+
+/* fddi_iface_attr_t */
+int fddi_iface_attr_init(fddi_iface_attr_t *attr)
+{
+ if (!attr)
+ return EINVAL;
+
+ memset(attr, 0, sizeof(fddi_iface_attr_t));
+
+ return 0;
+}
+
+int fddi_iface_attr_setclass(fddi_iface_attr_t *attr, char *class)
+{
+ if ((!attr) || (!class))
+ return EINVAL;
+
+ attr->fddi_class_name = strdup(class);
+ /* FIXME: where to free() this memory? */
+
+ return 0;
+}
+
+int fddi_iface_attr_setid(fddi_iface_attr_t *attr, const char *path, fddi_id_t id)
+{
+ if (!attr)
+ return EINVAL;
+
+ if (path)
+ attr->path = strdup(path);
+
+ memcpy(&attr->id, &id, sizeof(fddi_id_t));
+
+ return EINVAL;
+}
+
+/* fddi_iface_t */
+int fddi_iface_init(fddi_iface_t *iface, fddi_iface_attr_t *attr)
+{
+ const char *error_string;
+ int ret = 0;
+
+ if ((!iface) || (!attr))
+ return EINVAL;
+
+ if (attr->fddi_class_name == NULL)
+ return EINVAL;
+
+ /* initialize instance variables */
+ memset(iface, 0, sizeof(fddi_iface_t));
+ memcpy(&iface->id, &attr->id, sizeof(fddi_id_t));
+
+ /* attach to backend library */
+
+ pthread_mutex_lock(<_dl_mutex);
+
+ if (lt_dlinit()) {
+ pthread_mutex_unlock(<_dl_mutex);
+ return ELIBACC;
+ }
+
+ iface->backend_lib = lt_dlopenext(attr->fddi_class_name);
+ if ((iface->backend_lib) == NULL) {
+ pthread_mutex_unlock(<_dl_mutex);
+ return ELIBACC;
+ }
+
+ lt_dlerror();
+
+ /* register backend functions */
+ iface->backend.init = lt_dlsym(iface->backend_lib, "fddi_backend_init");
+ if ((error_string = lt_dlerror())) {
+ pthread_mutex_unlock(<_dl_mutex);
+ goto iface_init_err;
+ }
+
+ iface->backend.destroy = lt_dlsym(iface->backend_lib, "fddi_backend_destroy");
+ if ((error_string = lt_dlerror())) {
+ pthread_mutex_unlock(<_dl_mutex);
+ goto iface_init_err;
+ }
+
+ iface->backend.configure = lt_dlsym(iface->backend_lib, "fddi_backend_configure");
+ if ((error_string = lt_dlerror())) {
+ pthread_mutex_unlock(<_dl_mutex);
+ goto iface_init_err;
+ }
+
+ iface->backend.setstate = lt_dlsym(iface->backend_lib, "fddi_backend_setstate");
+ if ((error_string = lt_dlerror())) {
+ pthread_mutex_unlock(<_dl_mutex);
+ goto iface_init_err;
+ }
+
+ iface->backend.cmd = lt_dlsym(iface->backend_lib, "fddi_backend_cmd");
+ if ((error_string = lt_dlerror())) {
+ pthread_mutex_unlock(<_dl_mutex);
+ goto iface_init_err;
+ }
+
+ pthread_mutex_unlock(<_dl_mutex);
+
+ ret = iface->backend.init(iface);
+ if (ret)
+ fprintf(stderr, "error: backend init returned %i\n", ret);
+
+ return ret;
+
+iface_init_err:
+
+ fprintf(stderr, "%s\n", error_string);
+ pthread_mutex_lock(<_dl_mutex);
+ lt_dlclose(iface->backend_lib);
+ pthread_mutex_unlock(<_dl_mutex);
+ return EINVAL; /* FIXME better retval? */
+}
+
+int fddi_iface_destroy(fddi_iface_t *iface)
+{
+ int ret = 0;
+
+ if (!iface)
+ return EINVAL;
+
+ ret = iface->backend.destroy(iface);
+ if (ret)
+ fprintf(stderr, "error: backend init returned %i\n", ret);
+
+ pthread_mutex_lock(<_dl_mutex);
+ lt_dlclose(iface->backend_lib);
+ pthread_mutex_unlock(<_dl_mutex);
+
+ return ret;
+}
+
+int fddi_iface_configure(fddi_iface_t *iface, const char *configfile, void *data)
+{
+ if ((!iface) || (!configfile))
+ return EINVAL;
+
+ if (!iface->backend.configure)
+ return ENOSYS;
+
+ return iface->backend.configure(iface, configfile, data);
+}
+
+int fddi_iface_setstate(fddi_iface_t *iface, fddi_state_enum_t state)
+{
+ if (!iface)
+ return EINVAL;
+
+ if (!iface->backend.setstate)
+ return ENOSYS;
+
+ return iface->backend.setstate(iface, state);
+}
+
+int fddi_iface_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd)
+{
+ if (!iface)
+ return EINVAL;
+
+ if (!iface->backend.cmd)
+ return ENOSYS;
+
+ return iface->backend.cmd(iface, cmd);
+}
+
+int fddi_iface_getid(fddi_iface_t *iface, fddi_id_t *id)
+{
+ if ((!iface) || (!id))
+ return EINVAL;
+
+ memcpy(id, &iface->id, sizeof(fddi_id_t));
+
+ return 0;
+}
+
+int fddi_iface_setid(fddi_iface_t *iface, fddi_id_t id)
+{
+ if (!iface)
+ return EINVAL;
+
+ memcpy(&iface->id, &id, sizeof(fddi_id_t));
+
+ return 0;
+}
+
+int fddi_iface_getnodev(fddi_iface_t *iface)
+{
+ if (!iface)
+ return EINVAL;
+
+ return -1; /* FIXME: not implemented yet */
+}
+
+int fddi_iface_getnotpus(fddi_iface_t *iface)
+{
+ if (!iface)
+ return EINVAL;
+
+ return -1; /* FIXME: not implemented yet */
+}
+
+int fddi_iface_getnopvs(fddi_iface_t *iface)
+{
+ if (!iface)
+ return EINVAL;
+
+ return -1; /* FIXME: not implemented yet */
+}
+
+int fddi_iface_getdevlist(fddi_iface_t *iface, fddi_device_t **dev)
+{
+ if ((!iface) || (!dev))
+ return EINVAL;
+
+ *dev = iface->devlist_head;
+ return 0;
+}
+
+int fddi_iface_gettpulist(fddi_iface_t *iface, fddi_tpu_t **tpu)
+{
+ if ((!iface) || (!tpu))
+ return EINVAL;
+
+ *tpu = iface->tpulist_head;
+ return 0;
+}
+
+int fddi_iface_getversionstr(fddi_iface_t *iface, const char **version)
+{
+ if (!iface)
+ return EINVAL;
+
+ *version = fddi_version_str;
+
+ return 0;
+}
+
+int fddi_iface_getversion(fddi_iface_t *iface, int *version)
+{
+ /* FIXME: use the kernel mechanics to get a numerical version here */
+ return 0;
+}
+
+
+/* fddi_device_t */
+int fddi_dev_getnext(fddi_device_t **dev)
+{
+ if (!dev)
+ return ENODEV;
+
+ *dev = (*dev)->next;
+ return 0;
+}
+
+int fddi_dev_getid(fddi_device_t *dev, fddi_id_t *id)
+{
+ if ((!dev) || (!id))
+ return EINVAL;
+
+ memcpy(id, &dev->id, sizeof(fddi_id_t));
+
+ return 0;
+}
+
+int fddi_dev_getstate(fddi_device_t *dev, fddi_state_enum_t *state)
+{
+ if ((!dev) || (!state))
+ return EINVAL;
+
+ *state = dev->state;
+ return 0;
+}
+
+int fddi_dev_getstatestr(fddi_device_t *dev, char **state)
+{
+ if ((!dev) || (!state))
+ return EINVAL;
+
+ *state = NULL;
+ return 0;
+}
+
+int fddi_dev_getphysid(fddi_device_t *dev, int *id)
+{
+ if (!dev)
+ return EINVAL;
+
+ return -1; /* FIXME: not implemented yet */
+}
+
+int fddi_dev_getlogicalid(fddi_device_t *dev, int *id)
+{
+ if (!dev)
+ return EINVAL;
+
+ return -1; /* FIXME: not implemented yet */
+}
+
+int fddi_dev_getparamlist(fddi_device_t *dev, fddi_param_t **param)
+{
+ if ((!dev) || (!param))
+ return EINVAL;
+
+ *param = dev->param_list;
+ return 0;
+}
+
+int fddi_dev_getnotpus(fddi_device_t *dev)
+{
+ if (!dev)
+ return EINVAL;
+
+ return -1; /* FIXME: not implemented yet */
+}
+
+int fddi_dev_read_async(fddi_device_t *dev /* FIXME */)
+{
+ if (!dev)
+ return EINVAL;
+
+ return -1; /* FIXME: not implemented yet */
+}
+
+int fddi_dev_write_async(fddi_device_t *dev /* FIXME */)
+{
+ if (!dev)
+ return EINVAL;
+
+ return -1; /* FIXME: not implemented yet */
+}
+
+
+/* fddi_param_t */
+int fddi_param_getnext(fddi_param_t **param)
+{
+ if (!param)
+ return EINVAL;
+
+ *param = (*param)->next;
+ return 0;
+}
+
+int fddi_param_getkey(fddi_param_t *param, char **key)
+{
+ if ((!param) || (!key))
+ return EINVAL;
+
+ *key = param->key;
+ return 0;
+}
+
+int fddi_param_getval(fddi_param_t *param, char **val)
+{
+ if ((!param) || (!val))
+ return EINVAL;
+
+ *val = param->val;
+ return 0;
+}
+
+int fddi_param_getflags(fddi_param_t *param, unsigned long *flags) /* FIXME */
+{
+ if ((!param) || (!flags))
+ return ENODEV;
+
+ *flags = param->flags;
+ return 0;
+}
+
+int fddi_param_getnotpus(fddi_param_t *param, int *notpus)
+{
+ if ((!param) || (!notpus))
+ return EINVAL;
+
+ return -1; /* FIXME: not implemented yet */
+}
+
+
+/* fddi_tpu_t */
+int fddi_tpu_getnext(fddi_tpu_t **tpu)
+{
+ if (!tpu)
+ return EINVAL;
+
+ *tpu = (*tpu)->next;
+ return 0;
+}
+
+int fddi_tpu_getid(fddi_tpu_t *tpu, fddi_id_t *id)
+{
+ if ((!tpu) || (!id))
+ return EINVAL;
+
+ memcpy(id, &tpu->id, sizeof(fddi_id_t));
+
+ return 0;
+}
+
+int fddi_tpu_gettimestamp(fddi_tpu_t *tpu, int *timestamp) /* FIXME tv */
+{
+ if ((!tpu) || (!timestamp))
+ return EINVAL;
+
+ *timestamp = 0; /* FIMXE */
+ return 0;
+}
+
+int fddi_tpu_setcallback(fddi_tpu_t *tpu, int(*tpu_callback)(fddi_tpu_t *tpu, void *arg), void *arg)
+{
+ if ((!tpu) || (!tpu_callback))
+ return EINVAL;
+
+ tpu->callback = tpu_callback;
+ tpu->callback_arg = arg;
+
+ return 0;
+}
+
+int fddi_tpu_getpvlist(fddi_tpu_t *tpu, fddi_pv_t **pv)
+{
+ if ((!tpu) || (!pv))
+ return EINVAL;
+
+ *pv = tpu->pv_list_head;
+ return 0;
+}
+
+int fddi_tpu_getpayload(fddi_tpu_t *tpu, char **payload)
+{
+ if ((!tpu) || (!payload))
+ return EINVAL;
+
+ *payload = tpu->payload;
+ return 0;
+}
+
+int fddi_tpu_transfer(fddi_tpu_t *tpu)
+{
+ if ((tpu->direction == IN) || (tpu->direction == INOUT)) {
+
+
+ }
+
+ if ((tpu->direction == OUT) || (tpu->direction == INOUT)) {
+
+
+ }
+
+ return 0;
+}
+
+
+/* fddi_id_t */
+
+int fddi_id_init(fddi_id_t *fddi_id, const char *prefix, int index, const char *suffix)
+{
+ int prefix_len;
+ int index_len;
+ int suffix_len;
+ char index_as_string[30]; /* FIXME: find out max strlen of printf(int) */
+
+ memset(fddi_id, 0, sizeof(fddi_id_t));
+
+ /* FIXME: is it allowed to have things without index? */
+ snprintf(index_as_string, 30, "%i", index);
+ index_len = strlen(index_as_string);
+
+ if (prefix) {
+ prefix_len = strlen(prefix);
+ fddi_id->prefix = strdup(prefix);
+ if (!fddi_id->prefix)
+ goto prefix_err;
+ } else
+ prefix_len = 0;
+
+ if (suffix) {
+ suffix_len = strlen(suffix);
+ fddi_id->suffix = strdup(suffix);
+ if (!fddi_id->suffix)
+ goto suffix_err;
+ } else
+ suffix_len = 0;
+
+
+ fddi_id->id_as_str_len = prefix_len + index_len + suffix_len;
+
+ fddi_id->id_as_string = malloc(fddi_id->id_as_str_len + 1);
+ if (!fddi_id->id_as_string)
+ goto id_as_str_err;
+
+ sprintf(fddi_id->id_as_string, "%s%s%s",
+ fddi_id->prefix ? fddi_id->prefix : "",
+ index_as_string ? index_as_string : "",
+ fddi_id->suffix ? fddi_id->suffix: "");
+
+ return 0;
+
+id_as_str_err:
+ fddi_id->id_as_str_len = 0;
+ free(fddi_id->suffix);
+ fddi_id->suffix = NULL;
+suffix_err:
+ free(fddi_id->prefix);
+ fddi_id->prefix = NULL;
+prefix_err:
+ return ENOMEM;
+}
+
+int fddi_id_getid(fddi_id_t *fddi_id, char *id_string, size_t len)
+{
+ if (len < fddi_id->id_as_str_len)
+ return EINVAL; /* FIXME */
+
+ strcpy(id_string, fddi_id->id_as_string);
+
+ return 0;
+}
+
+int fddi_id_destroy(fddi_id_t *fddi_id)
+{
+ free(fddi_id->prefix);
+ free(fddi_id->suffix);
+ free(fddi_id->id_as_string);
+
+ return 0;
+}
+
Added: branches/fddi-mapping/src/libfddi_can.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/src/libfddi_can.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,461 @@
+/*
+ * fddi backend for arbitrary CAN messages
+ */
+
+/* FIXME: this file is an uggly hack which hardcodes everything, as long
+ * as we have a proper xml parser
+ */
+
+#if 0
+#include <pthread.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <time.h>
+#endif
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <net/if.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+
+#include <linux/can.h>
+#include <linux/can/raw.h>
+
+#include <osadl/fddi.h>
+#include <libpv.h>
+
+static fddi_tpu_t tpu1 = {
+ .id = {
+ .prefix = "cantpu",
+ .index = 0,
+ .suffix = "",
+ },
+ .direction = IN,
+ .cycletime = 0,
+};
+
+static fddi_tpu_t tpu2 = {
+ .id = {
+ .prefix = "cantpu",
+ .index = 1,
+ .suffix = "",
+ },
+ .direction = IN,
+ .cycletime = 0,
+};
+
+/* ----- */
+
+static fddi_pv_t pv_v_can = {
+ .id = {
+ .prefix = "v_can",
+ .index = -1,
+ .suffix = "",
+ },
+ .param_list_head = NULL,
+ .name = NULL,
+ .type = BE_UINT16,
+ .offset = 0,
+ .bit = 0,
+};
+
+static fddi_pv_t pv_n_can = {
+ .id = {
+ .prefix = "n_can",
+ .index = -1,
+ .suffix = "",
+ },
+ .param_list_head = NULL,
+ .name = NULL,
+ .type = BE_UINT16,
+ .offset = 2,
+ .bit = 0,
+};
+
+static fddi_pv_t pv_u_can = {
+ .id = {
+ .prefix = "u_can",
+ .index = -1,
+ .suffix = "",
+ },
+ .param_list_head = NULL,
+ .name = NULL,
+ .type = BE_UINT16,
+ .offset = 4,
+ .bit = 0,
+};
+
+static fddi_pv_t pv_i_can = {
+ .id = {
+ .prefix = "i_can",
+ .index = -1,
+ .suffix = "",
+ },
+ .param_list_head = NULL,
+ .name = NULL,
+ .type = BE_UINT16,
+ .offset = 6,
+ .bit = 0,
+};
+
+static fddi_pv_t pv_arate_can = {
+ .id = {
+ .prefix = "arate_can",
+ .index = -1,
+ .suffix = "",
+ },
+ .param_list_head = NULL,
+ .name = NULL,
+ .type = BE_UINT16,
+ .offset = 0,
+ .bit = 0,
+};
+
+static fddi_pv_t pv_srate_can = {
+ .id = {
+ .prefix = "srate_can",
+ .index = -1,
+ .suffix = "",
+ },
+ .param_list_head = NULL,
+ .name = NULL,
+ .type = BE_UINT16,
+ .offset = 2,
+ .bit = 0,
+};
+
+#if 0
+struct modbus_tpu {
+ timer_t timer;
+ struct sigevent event;
+ struct itimerspec timer_spec;
+ modbus_dev_t *modbus_dev;
+};
+struct modbus_tpu modbus_tpu1;
+#endif
+
+struct can_tpu {
+ pthread_t can_thread_id;
+ int endme;
+} can_tpu;
+
+typedef struct can_iface {
+ struct sockaddr_can addr;
+ struct can_frame frame;
+ struct ifreq ifr;
+ int socket;
+} can_iface_t;
+
+can_iface_t can_iface1;
+
+
+struct priv {
+ pv_engine_t pv_engine;
+
+ float *pv_v_tractor;
+ float *pv_n_diesel;
+ float *pv_u_dc;
+ float *pv_i_dc;
+ float *pv_agitation_rate;
+ float *pv_spray_rate;
+};
+
+struct priv priv;
+
+#define MAXDEV 6
+
+void* _can_thread(void *arg)
+{
+ fd_set rdfs;
+ int fd = can_iface1.socket;
+ ssize_t bytes;
+ int retval;
+ struct can_frame frame;
+ struct timeval to;
+
+ FD_ZERO(&rdfs);
+
+ while (!(can_tpu.endme)) {
+ to.tv_sec = 1;
+ to.tv_usec = 0;
+ FD_SET(fd, &rdfs);
+
+ retval = select(fd + 1, &rdfs, NULL, NULL, &to);
+
+ /* timeout */
+ if (retval == 0)
+ continue;
+
+ if (retval == -1) {
+ retval = -errno;
+ if (retval == -EINTR)
+ continue;
+
+ perror("select");
+ can_tpu.endme = 1;
+ continue;
+ }
+
+ bytes = recv(fd, &frame, sizeof(struct can_frame), 0);
+ if (bytes < (ssize_t)sizeof(struct can_frame)) {
+ fprintf(stderr, "error: received short frame");
+ exit(-1);
+ }
+
+ switch (frame.can_id) {
+ case (0x18E0F108 & CAN_EFF_MASK) | CAN_EFF_FLAG: {
+ int v_tractor_can =
+ frame.data[0] << 8 |
+ frame.data[1] << 0;
+ int n_diesel_can =
+ frame.data[2] << 8 |
+ frame.data[3] << 0;
+ int u_dc_can =
+ frame.data[4] << 8 |
+ frame.data[5] << 0;
+ int i_dc_can =
+ frame.data[6] << 8 |
+ frame.data[7] << 0;
+
+ pv_lock(&priv.pv_engine);
+ *(priv.pv_v_tractor) = v_tractor_can;
+ *(priv.pv_n_diesel) = n_diesel_can;
+ *(priv.pv_u_dc) = u_dc_can;
+ *(priv.pv_i_dc) = i_dc_can;
+ pv_unlock(&priv.pv_engine);
+ break;
+ }
+ case (0x18E0F208 & CAN_EFF_MASK) | CAN_EFF_FLAG: {
+ int agitation_rate_can =
+ frame.data[0] << 8 |
+ frame.data[1] << 0;
+ int spray_rate_can =
+ frame.data[2] << 8 |
+ frame.data[3] << 0;
+
+ pv_lock(&priv.pv_engine);
+ *(priv.pv_agitation_rate) = agitation_rate_can;
+ *(priv.pv_spray_rate) = spray_rate_can;
+ pv_unlock(&priv.pv_engine);
+ break;
+ }
+ default:
+ fprintf(stderr, "Unknown can_id 0x%08x\n", frame.can_id & CAN_EFF_MASK);
+ }
+
+
+ }
+
+ return NULL;
+}
+
+
+#if 0
+void _modbus_tpu_out(fddi_tpu_t *tpu)
+{
+ struct modbus_tpu *modbus_tpu = (struct modbus_tpu*)(tpu->priv);
+
+ /* application callback */
+ if (tpu->callback)
+ tpu->callback(tpu, NULL);
+
+ /* bus transfer */
+ modbus_w_single_coil(modbus_tpu->modbus_dev, 1, coil);
+ coil = coil == 0 ? 1:0;
+}
+
+void _modbus_tpu_in(fddi_tpu_t *tpu)
+{
+ /* bus transfer */
+
+ /* application callback */
+ if (tpu->callback)
+ tpu->callback(tpu, NULL);
+}
+
+
+void modbus_timer_handler(sigval_t sigval)
+{
+ fddi_tpu_t *tpu = (fddi_tpu_t*)sigval.sival_ptr;
+
+ if ((tpu->direction == OUT) || (tpu->direction == INOUT))
+ _modbus_tpu_out(tpu);
+
+ if ((tpu->direction == IN) || (tpu->direction == INOUT))
+ _modbus_tpu_in(tpu);
+
+ return;
+}
+#endif
+
+/*
+ * fddi backend functions
+ */
+
+int fddi_backend_init(fddi_iface_t *iface);
+int fddi_backend_destroy(fddi_iface_t *iface);
+int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data);
+int fddi_backend_setstate(fddi_iface_t *iface, fddi_state_enum_t state);
+int fddi_backend_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd);
+
+int fddi_backend_init(fddi_iface_t *iface)
+{
+ return 0;
+}
+
+int fddi_backend_destroy(fddi_iface_t *iface)
+{
+ can_iface_t *can_iface = (can_iface_t*)(iface->priv);
+
+ pv_destroy(&priv.pv_engine);
+
+ close(can_iface->socket);
+
+ return 0;
+}
+
+int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data)
+{
+ printf("parsing configfile: %s\n", configfile);
+// printf("for interface: %s\n", iface->id.id_as_string); /* FIXME private */
+
+ /*
+ * create socket for specified CAN interface
+ */
+ if ((can_iface1.socket = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
+ perror("opening can socket");
+ return -ESOCKTNOSUPPORT;
+ }
+
+ can_iface1.addr.can_family = AF_CAN;
+
+ strcpy(can_iface1.ifr.ifr_name, "can0");
+ if (ioctl(can_iface1.socket, SIOCGIFINDEX, &can_iface1.ifr) < 0) {
+ perror("attaching to can interface");
+ return 1;
+ }
+ can_iface1.addr.can_ifindex = can_iface1.ifr.ifr_ifindex;
+
+ if (bind(can_iface1.socket, (struct sockaddr *)&can_iface1.addr, sizeof(can_iface1.addr)) < 0) {
+ perror("binding to can socket");
+ return 1;
+ }
+
+ iface->priv = &can_iface1;
+ /* FIXME: everything's hardcoded & static for now, we add an xml parser later */
+
+ iface->tpulist_head = &tpu1;
+ tpu1.pv_list_head = &pv_v_can;
+ tpu1.next = &tpu2;
+
+ pv_v_can.next = &pv_n_can;
+ pv_n_can.previous = &pv_v_can;
+ pv_n_can.next = &pv_u_can;
+ pv_u_can.previous = &pv_n_can;
+ pv_u_can.next = &pv_i_can;
+ pv_i_can.previous = &pv_u_can;
+
+ tpu2.pv_list_head = &pv_arate_can;
+ tpu2.previous = &tpu1;
+
+ pv_arate_can.next = &pv_srate_can;
+ pv_srate_can.previous = &pv_arate_can;
+
+ {
+ pv_engine_attr_t attr;
+ int err;
+
+ err = pv_engine_attr_init_from_env(&attr);
+ if (err)
+ return err;
+
+ err = pv_init(&priv.pv_engine, &attr);
+ if (err) {
+ printf("couldn't init pv engine\n");
+ return err;
+ }
+ priv.pv_v_tractor = pv_register_float(&priv.pv_engine, "v_tractor");
+ priv.pv_n_diesel = pv_register_float(&priv.pv_engine, "n_diesel");
+ priv.pv_u_dc = pv_register_float(&priv.pv_engine, "u_dc");
+ priv.pv_i_dc = pv_register_float(&priv.pv_engine, "i_dc");
+ priv.pv_agitation_rate = pv_register_float(&priv.pv_engine, "agitation_rate");
+ priv.pv_spray_rate = pv_register_float(&priv.pv_engine, "spray_rate");
+
+ if ((priv.pv_v_tractor == NULL) || (priv.pv_n_diesel == NULL) || (priv.pv_u_dc == NULL) ||
+ (priv.pv_i_dc == NULL) || (priv.pv_agitation_rate == NULL) || (priv.pv_spray_rate == NULL)) {
+ fprintf(stderr, "could not register variables\n");
+ pv_destroy(&priv.pv_engine);
+ return -EINVAL;
+ }
+ }
+
+
+ /* we are ready now and go into preoperational state */
+ fddi_backend_setstate(iface, STATE_PREOPERATIONAL);
+
+ return 0;
+}
+
+int fddi_backend_setstate(fddi_iface_t *iface, fddi_state_enum_t state)
+{
+ int retval = -1;
+
+ switch(state) {
+ case STATE_UNCONFIGURED:
+ case STATE_MISSING:
+ case STATE_CONFIG_ERROR:
+ case STATE_PREOPERATIONAL:
+ case STATE_OPERATIONAL:
+ case STATE_OPERATION_ERROR:
+ iface->state = state;
+ retval = 0;
+ break;
+ default:
+ break;
+ }
+
+ return retval;
+}
+
+int fddi_backend_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd)
+{
+ int retval = -1;
+
+ switch (cmd) {
+
+ case CMD_START:
+
+ /* FIXME: check if we have already a thread running */
+ retval = pthread_create(&can_tpu.can_thread_id, NULL, _can_thread, NULL);
+ if (retval != 0)
+ perror("creating can_thread");
+ break;
+
+ case CMD_STOP:
+
+ can_tpu.endme = 1;
+ printf("waiting for can_thread to finish...");
+ pthread_join(can_tpu.can_thread_id, NULL);
+ printf("done\n");
+
+ retval = 0;
+ break;
+
+ case CMD_RESET:
+ case CMD_IDENTIFY:
+ case CMD_QUITERR:
+ retval = 0;
+ break;
+ default:
+ break;
+
+ }
+
+ return retval;
+}
+
Added: branches/fddi-mapping/src/libfddi_hess.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/src/libfddi_hess.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,289 @@
+#include <memory.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <osadl/fddi.h>
+
+#define MAX_IO_INTERFACES 16
+#define MAX_IO_INTERFACE_INSTS 64
+
+/* managment of io-interfaces */
+static int num_of_interfaces = 0;
+static IO_INTERFACE io_interfaces[MAX_IO_INTERFACES];
+
+
+static int num_of_interface_instances = 0;
+static IO_INTERFACE_INST io_interface_instances[MAX_IO_INTERFACE_INSTS];
+
+int register_io_interface(IO_INTERFACE ioitf)
+{
+ if (num_of_interfaces >= MAX_IO_INTERFACES)
+ return RESERR_OUT_OF_MEM;
+ io_interfaces[num_of_interfaces++] = ioitf;
+ return RESOK;
+}
+
+int bind_io_interface(IO_INTERFACE ioitf, char* name, LL_INTERFACE llitf, IO_INTERFACE_INST* res)
+{
+ int ret;
+ if (num_of_interface_instances >= MAX_IO_INTERFACE_INSTS)
+ return RESERR_OUT_OF_MEM;
+ /* call to function pointer from registered io-interface */
+ ret = (*ioitf->_fptr_bind_io_interface)(name, llitf, res);
+ if (ret == RESOK)
+ io_interface_instances[num_of_interface_instances++] = *res;
+ return ret;
+}
+
+int enum_io_interfaces(IO_INTERFACE** ioitfs)
+{
+ *ioitfs = io_interfaces;
+ return num_of_interfaces;
+}
+
+int enum_io_interface_instances(IO_INTERFACE_INST** ioitfinsts)
+{
+ *ioitfinsts = io_interface_instances;
+ return num_of_interface_instances;
+}
+
+IO_INTERFACE get_io_interface(char* name)
+{
+ int i;
+ for (i = 0; i < num_of_interfaces; i++)
+ if (strcmp(name, io_interfaces[i]->name) == 0)
+ return io_interfaces[i];
+ return NULL;
+}
+
+IO_INTERFACE_INST get_io_interface_inst(char* name)
+{
+ int i;
+ for (i = 0; i < num_of_interface_instances; i++)
+ if (strcmp(name, io_interface_instances[i]->name) == 0)
+ return io_interface_instances[i];
+ return NULL;
+}
+
+int enum_io_transport_units(IO_INTERFACE_INST ioitfinst, IO_TRANSPORT_UNIT** iotpus)
+{
+ *iotpus = ioitfinst->tpus;
+ return ioitfinst->num_tpus;
+}
+
+int enum_io_devices(IO_INTERFACE_INST ioitfinst, IO_DEVICE** iodevices)
+{
+ *iodevices = ioitfinst->devlist;
+ return ioitfinst->num_dev;
+}
+
+int enum_io_variables(IO_INTERFACE_INST ioitfinst, IO_VARIABLE** iovars)
+{
+ *iovars = ioitfinst->varlist;
+ return ioitfinst->num_var;
+}
+
+static int count_devices(IO_DEVICE io_device)
+{
+ int n_dev;
+ IO_DEVICE dev_child;
+
+ if (io_device == NULL)
+ return 0;
+
+ n_dev = 1; // the device itself
+ dev_child = io_device->first_child;
+
+ while (dev_child != NULL)
+ {
+ n_dev += count_devices(dev_child);
+ dev_child = dev_child->next_child;
+ }
+ return n_dev;
+}
+
+static IO_DEVICE* fill_devices(IO_DEVICE dev, IO_DEVICE* devlist)
+/* return adress to continue. devlist must be large enough */
+{
+ IO_DEVICE* list = devlist;
+ IO_DEVICE dev_child;
+
+ *list = dev;
+ list++;
+
+ dev_child = dev->first_child;
+
+ while (dev_child != NULL)
+ {
+ list = fill_devices(dev_child, list);
+ dev_child = dev_child->next_child;
+ }
+ return list;
+}
+
+int configure_io_interface_inst(IO_INTERFACE_INST ioitfinst, IO_DEVICE root)
+{
+ int ret;
+ /* call to function pointer from registered io-interface */
+ ret = (*ioitfinst->ioitf->_fptr_configure_io_interface_inst)(ioitfinst, root);
+ if (ret == RESOK)
+ {
+ int i;
+ IO_VARIABLE* list;
+
+ /* the configure method fills the tpu-list */
+ /* the other lists are filled by the fddi interface in this function */
+
+ /* fill device list */
+ ioitfinst->num_dev = count_devices(root);
+ ioitfinst->devlist = malloc(ioitfinst->num_dev * sizeof(IO_DEVICE));
+ fill_devices(root, ioitfinst->devlist);
+
+ /* fill variable list */
+ ioitfinst->num_var = 0;
+ for (i = 0; i < ioitfinst->num_tpus; i++)
+ ioitfinst->num_var += ioitfinst->tpus[i]->num_var;
+
+ ioitfinst->varlist = malloc(ioitfinst->num_var * sizeof(IO_VARIABLE));
+ list = ioitfinst->varlist;
+ for (i = 0; i < ioitfinst->num_tpus; i++)
+ {
+ memcpy(list, ioitfinst->tpus[i]->varlist, ioitfinst->tpus[i]->num_var * sizeof(IO_VARIABLE));
+ list += ioitfinst->tpus[i]->num_var;
+ }
+ }
+ return ret;
+}
+
+int scan_io_interface_inst(IO_INTERFACE_INST ioitfinst, IO_DEVICE *root)
+{
+ int ret;
+ /* call to function pointer from registered io-interface */
+ ret = (*ioitfinst->ioitf->_fptr_scan_io_interface_inst)(ioitfinst, root);
+ return ret;
+}
+
+int read_iodevice_async(IO_DEVICE iodev, unsigned long address, unsigned char* buf, unsigned long buf_size, unsigned long* read_size)
+{
+ int ret;
+ /* call to function pointer from registered io-interface */
+ ret = (*iodev->itfinst->ioitf->_fptr_read_device_async)(iodev, address, buf, buf_size, read_size);
+ return ret;
+}
+
+int write_iodevice_async(IO_DEVICE iodev, unsigned long address, unsigned char* buf, unsigned long size)
+{
+ int ret;
+ /* call to function pointer from registered io-interface */
+ ret = (*iodev->itfinst->ioitf->_fptr_write_device_async)(iodev, address, buf, size);
+ return ret;
+}
+
+int cmd_iodevice(IO_DEVICE iodev, IO_DEVICE_COMMAND cmd)
+{
+ int ret;
+ /* call to function pointer from registered io-interface */
+ ret = (*iodev->itfinst->ioitf->_fptr_cmd_device)(iodev, cmd);
+ return ret;
+}
+
+int enum_io_variables_of_iodevice(IO_DEVICE iodev, IO_VARIABLE** iovars)
+{
+ // todo
+ return 0;
+}
+
+/* A very simple implementation of transport units with a lot of improvement possibilities */
+/* While anyone is reading the buffer all write operations are done in a extra buffer to keep the read buffer consistent */
+
+unsigned char* address_to_read(IO_TRANSPORT_UNIT iotpu)
+{
+ iotpu->read_count++;
+ return iotpu->buf_read;
+}
+
+unsigned char* address_to_write(IO_TRANSPORT_UNIT iotpu)
+{
+ if (iotpu->write_count != 0)
+ return NULL;
+
+ iotpu->write_count++;
+ if (iotpu->buf_read == iotpu->buf_write)
+ {
+ iotpu->buf_write = malloc(iotpu->size);
+ memcpy(iotpu->buf_write, iotpu->buf_read, iotpu->size);
+ }
+ return iotpu->buf_write;
+}
+
+unsigned char* address_to_replace(IO_TRANSPORT_UNIT iotpu)
+{
+ if (iotpu->write_count != 0)
+ return NULL;
+
+ iotpu->write_count++;
+ if (iotpu->buf_read == iotpu->buf_write)
+ iotpu->buf_write = malloc(iotpu->size);
+ return iotpu->buf_write;
+}
+
+int release_adress(IO_TRANSPORT_UNIT iotpu, unsigned char* address)
+{
+ if (address == iotpu->buf_read)
+ {
+ iotpu->read_count--;
+ /* assert iotpu->read_count >= 0 */
+ if (iotpu->read_count == 0 && iotpu->write_count == 0 && iotpu->buf_read != iotpu->buf_write)
+ {
+ free(iotpu->buf_read);
+ iotpu->buf_read = iotpu->buf_write;
+ }
+ return RESOK;
+ }
+ else if (address == iotpu->buf_write)
+ {
+ int i;
+ iotpu->write_count--;
+ /* assert iotpu->write_count >= 0 */
+ if (iotpu->read_count == 0 && iotpu->write_count == 0 && iotpu->buf_read != iotpu->buf_write)
+ {
+ free(iotpu->buf_read);
+ iotpu->buf_read = iotpu->buf_write;
+ }
+
+ /* trigger callbacks */
+ for (i = 0; i < iotpu->num_callbacks; i++)
+ (*iotpu->callback[i])(iotpu);
+
+ return RESOK;
+ }
+ return RESERR_UNKOWNADDRESS;
+}
+
+int send_iotransport_unit(IO_TRANSPORT_UNIT iotpu)
+{
+ // FIXME int res = 0;
+ /* pseudo code, because low level interface is not ready */
+ /* may be redirected trough stack */
+ /*
+ res = iotpu->itfinst->llitf->Send(iotpu->id, iotpu->buf_write, iotpu->size);
+ */
+ return 0;
+}
+
+int register_callback_to_iotransport_unit(IO_TRANSPORT_UNIT iotpu, void (*callback)(IO_TRANSPORT_UNIT iotpu))
+{
+ if (iotpu->num_callbacks >= MAXCALLBACKS)
+ return RESERR_OUT_OF_MEM;
+ iotpu->callback[iotpu->num_callbacks] = callback;
+ iotpu->num_callbacks++;
+ return RESOK;
+}
+
+int enum_io_variables_of_iotransport_unit(IO_TRANSPORT_UNIT iotpu, IO_VARIABLE** iovars)
+{
+ *iovars = iotpu->varlist;
+ return iotpu->num_var;
+}
+
Added: branches/fddi-mapping/src/libfddi_libmodbus.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/src/libfddi_libmodbus.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,271 @@
+/*
+ * fddi backend for libmodbus
+ */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include <modbus.h>
+
+#include <osadl/fddi.h>
+
+static fddi_tpu_t tpu1 = {
+ .id = {
+ .prefix = "dout",
+ .index = -1,
+ .suffix = "",
+ },
+ .direction = OUT,
+ .cycletime = (10*1000*1000),
+};
+
+static fddi_pv_t pv1 = {
+ .id = {
+ .prefix = "signal_red",
+ .index = -1,
+ .suffix = "",
+ },
+ .param_list_head = NULL,
+ .name = NULL,
+ .type = BOOL,
+ .offset = 0,
+ .bit = 0,
+};
+
+static fddi_pv_t pv2 = {
+ .id = {
+ .prefix = "signal_yellow",
+ .index = -1,
+ .suffix = "",
+ },
+ .param_list_head = NULL,
+ .name = NULL,
+ .type = BOOL,
+ .offset = 0,
+ .bit = 1,
+};
+
+static fddi_pv_t pv3 = {
+ .id = {
+ .prefix = "signal_green",
+ .index = -1,
+ .suffix = "",
+ },
+ .param_list_head = NULL,
+ .name = NULL,
+ .type = BOOL,
+ .offset = 0,
+ .bit = 2,
+};
+
+struct modbus_tpu {
+ timer_t timer;
+ struct sigevent event;
+ struct itimerspec timer_spec;
+ modbus_dev_t *modbus_dev;
+};
+struct modbus_tpu modbus_tpu1;
+
+struct modbus_iface {
+ modbus_dev_t modbus_dev;
+};
+struct modbus_iface modbus_iface1;
+
+int coil;
+
+void _modbus_tpu_out(fddi_tpu_t *tpu)
+{
+ struct modbus_tpu *modbus_tpu = (struct modbus_tpu*)(tpu->priv);
+
+ /* application callback */
+ if (tpu->callback)
+ tpu->callback(tpu, NULL);
+
+ /* bus transfer */
+ modbus_w_single_coil(modbus_tpu->modbus_dev, 1, coil);
+ coil = coil == 0 ? 1:0;
+}
+
+void _modbus_tpu_in(fddi_tpu_t *tpu)
+{
+ /* bus transfer */
+
+ /* application callback */
+ if (tpu->callback)
+ tpu->callback(tpu, NULL);
+}
+
+
+void modbus_timer_handler(sigval_t sigval)
+{
+ fddi_tpu_t *tpu = (fddi_tpu_t*)sigval.sival_ptr;
+
+ if ((tpu->direction == OUT) || (tpu->direction == INOUT))
+ _modbus_tpu_out(tpu);
+
+ if ((tpu->direction == IN) || (tpu->direction == INOUT))
+ _modbus_tpu_in(tpu);
+
+ return;
+}
+
+/*
+ * fddi backend functions
+ */
+
+int fddi_backend_init(fddi_iface_t *iface);
+int fddi_backend_destroy(fddi_iface_t *iface);
+int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data);
+int fddi_backend_setstate(fddi_iface_t *iface, fddi_state_enum_t state);
+int fddi_backend_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd);
+
+int fddi_backend_init(fddi_iface_t *iface)
+{
+ iface->priv = &modbus_iface1;
+ return 0;
+}
+
+int fddi_backend_destroy(fddi_iface_t *iface)
+{
+ modbus_dev_t *modbus_dev = (modbus_dev_t*)(iface->priv);
+
+ if (modbus_unbind (modbus_dev) == -1)
+ return -1;
+
+ return 0;
+}
+
+int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data)
+{
+ int ret;
+ modbus_dev_t *modbus_dev = (modbus_dev_t*)(iface->priv);
+
+ printf("parsing configfile: %s\n", configfile);
+ printf("for interface: %s\n", iface->id.id_as_string); /* FIXME private */
+
+ /* FIXME: everything's hardcoded & static for now, we add an xml parser later */
+
+ iface->tpulist_head = &tpu1;
+ tpu1.pv_list_head = &pv1;
+
+ pv1.next = &pv2;
+ pv2.previous = &pv1;
+ pv2.next = &pv3;
+ pv3.previous = &pv2;
+
+ /* modbus has no hardware bus cycle, emulate one for each tpu */
+ /* FIXME: loop */
+ {
+ modbus_tpu1.event.sigev_notify = SIGEV_THREAD;
+ modbus_tpu1.event.sigev_notify_function = modbus_timer_handler;
+ modbus_tpu1.event.sigev_notify_attributes = NULL;
+ modbus_tpu1.event.sigev_value.sival_ptr = &tpu1;
+ tpu1.priv = &modbus_tpu1;
+
+ if ((ret = timer_create(CLOCK_REALTIME, &modbus_tpu1.event, &modbus_tpu1.timer)) < 0 ) {
+ perror("timer create");
+ return -1;
+ }
+ }
+
+ if (modbus_bind(modbus_dev, "192.168.23.242", 502) == -1) {
+ fprintf(stderr, "modbus_bind() failed\n");
+ return -1;
+ }
+
+ /* FIXME: modbus_dev must be put into the device, not iface! */
+ modbus_tpu1.modbus_dev = modbus_dev;
+
+ /* we are ready now and go into preoperational state */
+
+ fddi_backend_setstate(iface, STATE_PREOPERATIONAL);
+
+ return 0;
+}
+
+int fddi_backend_setstate(fddi_iface_t *iface, fddi_state_enum_t state)
+{
+ int retval = -1;
+
+ switch(state) {
+ case STATE_UNCONFIGURED:
+ case STATE_MISSING:
+ case STATE_CONFIG_ERROR:
+ case STATE_PREOPERATIONAL:
+ case STATE_OPERATIONAL:
+ case STATE_OPERATION_ERROR:
+ iface->state = state;
+ retval = 0;
+ break;
+ default:
+ break;
+ }
+
+ return retval;
+}
+
+int fddi_backend_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd)
+{
+ int retval = -1;
+
+ switch (cmd) {
+
+ case CMD_START:
+
+ printf("start\n");
+ /* FIXME loop over all tpus here */
+ {
+ struct modbus_tpu *mtpu = ((struct modbus_tpu*)(iface->tpulist_head->priv));
+
+ mtpu->timer_spec.it_value.tv_sec = 1;
+ mtpu->timer_spec.it_value.tv_nsec = 0;
+ mtpu->timer_spec.it_interval.tv_sec = 0;
+ mtpu->timer_spec.it_interval.tv_nsec = 500*1000*1000;
+
+ if ((retval = timer_settime(mtpu->timer, 0, &mtpu->timer_spec, NULL)) < 0 ) {
+ perror("timer settime");
+ /* FIXME: disarm timers here */
+ return -1;
+ }
+ }
+
+ retval = 0;
+ break;
+
+ case CMD_STOP:
+
+ /* FIXME: loop over all tpus here */
+ {
+ struct modbus_tpu *mtpu = ((struct modbus_tpu*)(iface->tpulist_head->priv));
+
+ mtpu->timer_spec.it_value.tv_sec = 0;
+ mtpu->timer_spec.it_value.tv_nsec = 0;
+ mtpu->timer_spec.it_interval.tv_sec = 0;
+ mtpu->timer_spec.it_interval.tv_nsec = 0;
+
+ if ((retval = timer_settime(mtpu->timer, 0, &mtpu->timer_spec, NULL)) < 0 ) {
+ perror("timer settime");
+ return -1;
+ }
+ }
+
+ retval = 0;
+ break;
+
+ case CMD_RESET:
+ case CMD_IDENTIFY:
+ case CMD_QUITERR:
+ retval = 0;
+ break;
+ default:
+ break;
+
+ }
+
+ return retval;
+}
+
Added: branches/fddi-mapping/tests/GNUmakefile.am
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/GNUmakefile.am Tue Oct 2 16:30:06 2007
@@ -0,0 +1,222 @@
+BACKEND_EXAMPLEBUS_TESTS = \
+ test_fddi_examplebus_attach_backend \
+ test_fddi_examplebus_configure \
+ test_fddi_examplebus_cmd_start \
+ test_fddi_examplebus_cmd_stop \
+ test_fddi_examplebus_cmd_quiterr \
+ test_fddi_examplebus_cmd_identify \
+ test_fddi_examplebus_cmd_reset \
+ test_fddi_examplebus_setstate_configerror \
+ test_fddi_examplebus_setstate_missing \
+ test_fddi_examplebus_setstate_operational \
+ test_fddi_examplebus_setstate_operation_error \
+ test_fddi_examplebus_setstate_preoperational \
+ test_fddi_examplebus_setstate_unconfigured
+
+# test_fddi_examplebus1
+
+if BACKEND_CAN
+BACKEND_CAN_TESTS = \
+ test_fddi_can1
+endif
+
+if BACKEND_LIBMODBUS
+BACKEND_LIBMODBUS_TESTS = \
+ test_fddi_libmodbus1
+endif
+
+TESTS = \
+ test_examplebus1 \
+ test_fddi_versionstr \
+ usecase_controller \
+ $(BACKEND_CAN_TESTS) \
+ $(BACKEND_EXAMPLEBUS_TESTS) \
+ $(BACKEND_LIBMODBUS_TESTS)
+
+TESTS_ENVIRONMENT = \
+ LD_LIBRARY_PATH=$(top_builddir)/tests/.libs
+
+noinst_PROGRAMS = \
+ test_examplebus1 \
+ test_fddi_versionstr \
+ usecase_controller \
+ $(BACKEND_CAN_TESTS) \
+ $(BACKEND_EXAMPLEBUS_TESTS) \
+ $(BACKEND_LIBMODBUS_TESTS)
+
+lib_LTLIBRARIES = \
+ libexamplebus.la \
+ libfddi_examplebus.la
+
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/include \
+ -I$(top_builddir)/include \
+ $(LTDLINCL)
+
+#
+# libraries
+#
+
+libexamplebus_la_SOURCES = \
+ libexamplebus.c
+
+libfddi_examplebus_la_SOURCES = \
+ libfddi_examplebus.c
+
+libfddi_examplebus_la_LDFLAGS = \
+ -module
+
+#
+# can backend
+#
+
+test_fddi_can1_SOURCES = \
+ test_fddi_can1.c
+
+test_fddi_can1_LDADD = \
+ -lpthread -lrt \
+ $(top_builddir)/src/libfddi.la
+
+test_fddi_can1_DEPENDENCIES = \
+ test_fddi_can1.xml
+
+test_fddi_can1.xml:
+ cp $(top_srcdir)/busconfig/Pengutronix/can-example.xml test_fddi_can1.xml
+
+
+#
+# examplebus backend
+#
+
+test_examplebus1_SOURCES = \
+ test_examplebus1.c
+
+test_examplebus1_LDADD = \
+ libexamplebus.la
+
+#test_fddi_examplebus1_SOURCES = \
+# test_fddi_examplebus1.c
+#
+#test_fddi_examplebus1_LDADD = \
+# $(top_builddir)/src/libfddi.la
+
+test_fddi_examplebus_attach_backend_SOURCES = \
+ test_fddi_examplebus_attach_backend.c
+
+test_fddi_examplebus_attach_backend_LDADD = \
+ $(top_builddir)/src/libfddi.la
+
+test_fddi_versionstr_SOURCES = \
+ test_fddi_versionstr.c
+
+test_fddi_versionstr_LDADD = \
+ $(top_builddir)/src/libfddi.la
+
+test_fddi_examplebus_configure_SOURCES = \
+ test_fddi_examplebus_configure.c
+
+test_fddi_examplebus_configure_LDADD = \
+ $(top_builddir)/src/libfddi.la
+
+test_fddi_examplebus_cmd_start_SOURCES = \
+ test_fddi_examplebus_cmd_start.c
+
+test_fddi_examplebus_cmd_start_LDADD = \
+ $(top_builddir)/src/libfddi.la
+
+test_fddi_examplebus_cmd_stop_SOURCES = \
+ test_fddi_examplebus_cmd_stop.c
+
+test_fddi_examplebus_cmd_stop_LDADD = \
+ $(top_builddir)/src/libfddi.la
+
+test_fddi_examplebus_cmd_quiterr_SOURCES = \
+ test_fddi_examplebus_cmd_quiterr.c
+
+test_fddi_examplebus_cmd_quiterr_LDADD = \
+ $(top_builddir)/src/libfddi.la
+
+test_fddi_examplebus_cmd_identify_SOURCES = \
+ test_fddi_examplebus_cmd_identify.c
+
+test_fddi_examplebus_cmd_identify_LDADD = \
+ $(top_builddir)/src/libfddi.la
+
+test_fddi_examplebus_cmd_reset_SOURCES = \
+ test_fddi_examplebus_cmd_reset.c
+
+test_fddi_examplebus_cmd_reset_LDADD = \
+ $(top_builddir)/src/libfddi.la
+
+test_fddi_examplebus_setstate_configerror_SOURCES = \
+ test_fddi_examplebus_setstate_configerror.c
+
+test_fddi_examplebus_setstate_configerror_LDADD = \
+ $(top_builddir)/src/libfddi.la
+
+test_fddi_examplebus_setstate_missing_SOURCES = \
+ test_fddi_examplebus_setstate_missing.c
+
+test_fddi_examplebus_setstate_missing_LDADD = \
+ $(top_builddir)/src/libfddi.la
+
+test_fddi_examplebus_setstate_operational_SOURCES = \
+ test_fddi_examplebus_setstate_operational.c
+
+test_fddi_examplebus_setstate_operational_LDADD = \
+ $(top_builddir)/src/libfddi.la
+
+test_fddi_examplebus_setstate_operation_error_SOURCES = \
+ test_fddi_examplebus_setstate_operation_error.c
+
+test_fddi_examplebus_setstate_operation_error_LDADD = \
+ $(top_builddir)/src/libfddi.la
+
+test_fddi_examplebus_setstate_preoperational_SOURCES = \
+ test_fddi_examplebus_setstate_preoperational.c
+
+test_fddi_examplebus_setstate_preoperational_LDADD = \
+ $(top_builddir)/src/libfddi.la
+
+test_fddi_examplebus_setstate_unconfigured_SOURCES = \
+ test_fddi_examplebus_setstate_unconfigured.c
+
+test_fddi_examplebus_setstate_unconfigured_LDADD = \
+ $(top_builddir)/src/libfddi.la
+
+#
+# libmodbus backend
+#
+
+test_fddi_libmodbus1_SOURCES = \
+ test_fddi_libmodbus1.c
+
+test_fddi_libmodbus1_LDADD = \
+ -lpthread -lrt \
+ $(top_builddir)/src/libfddi_libmodbus.la
+
+test_fddi_libmodbus1_DEPENDENCIES = \
+ test_fddi_libmodbus1.xml
+
+test_fddi_libmodbus1.xml:
+ cp $(top_srcdir)/busconfig/Pengutronix/modbus-example.xml test_fddi_libmodbus1.xml
+
+#
+# usecases
+#
+usecase_controller_SOURCES = \
+ usecase_controller.c
+
+usecase_controller_LDADD = \
+ -lpthread -lrt \
+ $(top_builddir)/src/libfddi.la
+
+EXTRA_DIST = \
+ examplebus.h
+
+MAINTAINERCLEANFILES = \
+ GNUmakefile.in
+
+CLEANFILES = \
+ test_fddi_libmodbus1.xml
+
Added: branches/fddi-mapping/tests/example.xml
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/example.xml Tue Oct 2 16:30:06 2007
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="iso8859-1"?>
+
+<oio>
+
+ <system prefix="setup" index="0">
+
+ <name>Examplebus Test Setup</name>
+
+ <system prefix="controllerbox" index="0">
+
+ <name>IPC Controller Box</name>
+
+ <iointerface prefix="examplebus" index="0">
+ <device prefix="exb" index="0"/>
+ <iointerfaceExamplebus>
+ <role>master</role>
+ </iointerfaceExamplebus>
+
+ <iodevice>
+ <transportationUnit>
+ <pv prefix="ain" index="0" val="0">
+ <name>Analog Input 1</name>
+ <type>uint32_t</type>
+ <offset>0</offset>
+ </pv>
+ </transportationUnit>
+ </iodevice>
+
+ </io_interface>
+
+ </system>
+
+</oio>
Added: branches/fddi-mapping/tests/examplebus.h
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/examplebus.h Tue Oct 2 16:30:06 2007
@@ -0,0 +1,38 @@
+#ifndef EXAMPLEBUS_H
+#define EXAMPLEBUS_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef struct {
+ int logfile_fd;
+} examplebus_t;
+
+
+typedef struct {
+ char *logfile;
+} examplebus_attr_t;
+
+
+/* API */
+
+/* attribute handling */
+extern int examplebus_attr_init(examplebus_attr_t *attr);
+extern int examplebus_attr_setlogfile(examplebus_attr_t *attr, char *logfile);
+
+/* object lifetime */
+extern int examplebus_init(examplebus_t *bus, examplebus_attr_t *attr);
+extern int examplebus_destroy(examplebus_t *bus);
+
+/* some arbitrary bus functions */
+extern int examplebus_r_din(examplebus_t *dev, int index, int *value);
+extern int examplebus_w_dout(examplebus_t *dev, int index, int value);
+extern int examplebus_r_ain(examplebus_t *dev, int index, int *value);
+extern int examplebus_w_aout(examplebus_t *dev, int reg, int value);
+
+# ifdef __cplusplus
+}
+# endif
+#endif /* EXAMPLEBUS_H */
Added: branches/fddi-mapping/tests/fddi_examplebus.h
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/fddi_examplebus.h Tue Oct 2 16:30:06 2007
@@ -0,0 +1,40 @@
+#ifndef EXAMPLEBUS_H
+#define EXAMPLEBUS_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef struct {
+ int logfile_fd;
+} fddi_examplebus_t;
+
+
+typedef struct {
+ char *logfile;
+} fddi_examplebus_attr_t;
+
+
+/* API */
+
+/* attribute handling */
+extern int fddi_examplebus_attr_init(fddi_examplebus_attr_t *attr);
+extern int fddi_examplebus_attr_setxmlconfig(fddi_examplebus_attr_t *attr, char *configfile);
+
+/* object lifetime */
+extern int fddi_examplebus_init(fddi_examplebus_t *bus, fddi_examplebus_attr_t *attr);
+extern int fddi_examplebus_destroy(fddi_examplebus_t *bus);
+
+/* some arbitrary bus functions */
+#if 0
+extern int examplebus_r_din(examplebus_t *dev, int index, int *value);
+extern int examplebus_w_dout(examplebus_t *dev, int index, int value);
+extern int examplebus_r_ain(examplebus_t *dev, int index, int *value);
+extern int examplebus_w_aout(examplebus_t *dev, int reg, int value);
+#endif
+
+# ifdef __cplusplus
+}
+# endif
+#endif /* EXAMPLEBUS_H */
Added: branches/fddi-mapping/tests/libexamplebus.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/libexamplebus.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,97 @@
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+typedef struct {
+ int logfile_fd;
+ int simulate_ain;
+ int simulate_din;
+} examplebus_t;
+
+typedef struct {
+ char *logfile;
+} examplebus_attr_t;
+
+int examplebus_attr_init(examplebus_attr_t *attr)
+{
+ memset(attr, 0, sizeof(examplebus_attr_t));
+ return 0;
+}
+
+int examplebus_attr_setlogfile(examplebus_attr_t *attr, char *logfile)
+{
+ if (!attr)
+ return ENODEV;
+
+ if (attr->logfile)
+ free(attr->logfile);
+
+ attr->logfile = malloc(strlen(logfile));
+ if (!attr->logfile)
+ return ENOMEM;
+ strcpy(attr->logfile, logfile);
+ return 0;
+}
+
+int examplebus_init(examplebus_t *bus, examplebus_attr_t *attr)
+{
+ if ((!attr) || (!bus))
+ return EINVAL;
+
+ if (!attr->logfile)
+ return EINVAL;
+
+ memset(bus, 0, sizeof(examplebus_t));
+ bus->logfile_fd = open(attr->logfile, O_RDWR);
+ if (bus->logfile_fd < 0)
+ return ENOENT;
+
+ return 0;
+}
+
+int examplebus_destroy(examplebus_t *bus)
+{
+ close(bus->logfile_fd);
+ return 0;
+}
+
+int examplebus_r_din(examplebus_t *bus, int index, int *value)
+{
+ if (!bus)
+ return ENODEV;
+
+ if (!value)
+ return EINVAL;
+
+ bus->simulate_din = bus->simulate_din == 1 ? 0 : 1;
+ *value = bus->simulate_din;
+
+ return 0;
+}
+
+int examplebus_w_dout(examplebus_t *bus, int index, int value)
+{
+ /* FIXME do something */
+ return 0;
+}
+
+int examplebus_r_ain(examplebus_t *bus, int index, int *value)
+{
+ bus->simulate_ain += 1;
+ if (bus->simulate_ain == 10)
+ bus->simulate_ain = 0;
+ *value = bus->simulate_ain;
+
+ return 0;
+}
+
+int examplebus_w_aout(examplebus_t *bus, int index, int value)
+{
+ /* FIXME do something */
+ return 0;
+}
+
Added: branches/fddi-mapping/tests/libfddi_examplebus.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/libfddi_examplebus.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,61 @@
+/*
+ * This is an example fieldbus library implementation
+ */
+
+#include <stdio.h>
+#include <osadl/fddi.h>
+
+int fddi_backend_init(fddi_iface_t *iface)
+{
+ return 0;
+}
+
+int fddi_backend_destroy(fddi_iface_t *iface)
+{
+ return 0;
+}
+
+int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data)
+{
+ return 0;
+}
+
+int fddi_backend_setstate(fddi_iface_t *iface, fddi_state_enum_t state)
+{
+ int retval = -1;
+
+ switch(state) {
+ case STATE_UNCONFIGURED:
+ case STATE_MISSING:
+ case STATE_CONFIG_ERROR:
+ case STATE_PREOPERATIONAL:
+ case STATE_OPERATIONAL:
+ case STATE_OPERATION_ERROR:
+ retval = 0;
+ break;
+ default:
+ break;
+ }
+
+ return retval;
+}
+
+int fddi_backend_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd)
+{
+ int retval = -1;
+
+ switch (cmd) {
+ case CMD_START:
+ case CMD_STOP:
+ case CMD_RESET:
+ case CMD_IDENTIFY:
+ case CMD_QUITERR:
+ retval = 0;
+ break;
+ default:
+ break;
+ }
+
+ return retval;
+}
+
Added: branches/fddi-mapping/tests/test_examplebus1.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_examplebus1.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <examplebus.h>
+
+int main(void)
+{
+ examplebus_attr_t attr;
+ examplebus_t examplebus;
+ int val;
+ int ret;
+
+ examplebus_attr_init(&attr);
+ examplebus_attr_setlogfile(&attr, "logfile");
+
+ examplebus_init(&examplebus, &attr);
+
+ /* test digital ins */
+ ret = examplebus_r_din(&examplebus, 0, &val);
+ if (val != 1)
+ exit(-1);
+
+ ret = examplebus_r_din(&examplebus, 0, &val);
+ if (val != 0)
+ exit(-1);
+
+ examplebus_destroy(&examplebus);
+
+ exit(0);
+}
+
Added: branches/fddi-mapping/tests/test_fddi_can1.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_can1.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,96 @@
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <osadl/fddi.h>
+
+static int endme;
+
+void signalhandler(int sig)
+{
+ if (sig == SIGPIPE)
+ return;
+ if (sig == SIGHUP) {
+ fprintf(stderr, "SIGHUP received\n");
+ }
+ if (sig == SIGTERM || sig == SIGINT) {
+ fprintf(stderr, "ctrl-c pressed, shutting down\n");
+ endme = 1;
+ }
+}
+
+
+int tpu_callback(fddi_tpu_t *tpu, void *arg)
+{
+ printf("callback\n");
+ return 0;
+}
+
+/*
+ * FIXME: we have to agree on a bus start workflow!
+ */
+
+int main(void)
+{
+ struct sigaction action;
+
+ fddi_iface_attr_t can0_attr;
+ fddi_iface_t can0_iface;
+ fddi_id_t can0_id;
+ fddi_tpu_t *tpu;
+
+ int ret;
+
+ /* setup signal handler */
+ action.sa_handler = signalhandler;
+ sigemptyset(&action.sa_mask);
+ action.sa_flags = 0;
+ sigaction(SIGTERM, &action, 0); /* catches kill from the shell */
+ sigaction(SIGINT, &action, 0); /* catches Ctrl-C from the shell */
+ sigaction(SIGPIPE, &action, 0); /* catches Broken Pipe exception */
+ sigaction(SIGHUP, &action, 0); /* catches HUP */
+
+ fddi_id_init(&can0_id, "can", 0, NULL);
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&can0_attr);
+ fddi_iface_attr_setclass(&can0_attr, "libfddi_can.so");
+ fddi_iface_attr_setid(&can0_attr, "demosystem.boardcomputer", can0_id);
+
+ ret = fddi_iface_init(&can0_iface, &can0_attr);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_init() failed\n");
+ return ret;
+ }
+
+ ret = fddi_iface_configure(&can0_iface, "test_fddi_can1.xml", NULL);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_configure() failed\n");
+ return ret;
+ }
+
+ /* attach callbacks to TPUs */
+ fddi_iface_gettpulist(&can0_iface, &tpu);
+ while (tpu) {
+ fddi_tpu_setcallback(tpu, tpu_callback, NULL);
+ fddi_tpu_getnext(&tpu);
+ }
+
+ /* everything is configured, now we can start */
+ ret = fddi_iface_cmd(&can0_iface, CMD_START);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_cmd() failed\n");
+ return ret;
+ }
+
+ printf("entering main loop, press ctrl-c to end\n");
+ while (!endme)
+ sleep(1);
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&can0_iface);
+
+ exit(0);
+}
+
Added: branches/fddi-mapping/tests/test_fddi_can1.xml
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_can1.xml Tue Oct 2 16:30:06 2007
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="iso8859-1"?>
+
+<!--
+ TODO:
+
+ - let jfr fix the schema for CAN entries
+ - version bump
+ - clarify: who is the owner of a transportation unit?
+ always the data source -> ioInterface...?
+ - discuss with mkl if the filter mechanics makes sense
+ - prefix...index...suffix must be in id, not in system
+
+ - transportation units are not necessarily located! We want to
+ be able to define 1000 TPUs on an IoConnection, but only
+ instanciate 2 on a certain I/O interface. Consequence:
+
+ TPUs is to be defined in the ioConnection.
+
+ ioInterfaces instanciate TPUs.
+
+ Direction is a property of the instance.
+-->
+
+<openIO>
+
+ <system prefix="demosystem" index="0">
+
+ <name>CAN Demo System</name>
+
+ <system prefix="boardcomputer" index="0">
+
+ <name>Board Computer</name>
+
+ <portCan>
+ <id prefix="can" index="0"/>
+ <device prefix="can" index="0" direction="inout"/>
+ <name>CAN</name>
+ <baudrate>500000</baudrate>
+ </portCan>
+
+ <ioInterfaceCan>
+ <id prefix="can" index="0"/>
+ <device prefix="can" index="0" direction="inout"/>
+
+ <transportationUnit direction="in" cycletime="0" ref="0x18E0F108"/>
+ <transportationUnit direction="in" cycletime="0" ref="0x18E0F108"/>
+
+ </ioInterfaceCan>
+
+ </system>
+
+ <system prefix="vehicle" index="0">
+
+ <name>The Vehicle</name>
+
+ <portCan>
+ <id prefix="can" index="0"/>
+ <device prefix="can" index="0" direction="inout"/>
+ <name>CAN</name>
+ <baudrate>500000</baudrate>
+ </portCan>
+
+ <ioInterfaceCan>
+ <id prefix="can" index="0"/>
+ <device prefix="can" index="0" direction="inout"/>
+ </ioInterfaceCan>
+
+ </system>
+
+ <connection>
+ <node system_id="boardcomputer0" port_id="can0"/>
+ <node system_id="car0" port_id="can0"/>
+ </connection>
+
+ <ioConnection>
+
+ <node system_id="boardcomputer0" ioInterface_id="can0"/>
+ <node system_id="car0" ioInterface_id="can0"/>
+
+ <transportationUnit direction="undef" cycletime="0">
+ <id prefix="0x18E0F108"/>
+ <size>8</size>
+ <property name="canid-type" value="extended"/>
+ <property name="canid" value="0x18E0F108"/>
+ <property name="canid-andmask" value="0xffffffff"/>
+ <property name="canid-ormask" value="0x00000000"/>
+ <pv id="can_speed" val="0">
+ <name>Car Speed (from CAN)</name>
+ <type>uint16_t</type>
+ <offset>0</offset>
+ <bit></bit>
+ </pv>
+ <pv id="can_rpm" val="0">
+ <name>RPM (from CAN)</name>
+ <type>uint16_t</type>
+ <offset>2</offset>
+ <bit></bit>
+ </pv>
+ <pv id="can_voltage" val="0">
+ <name>Voltage (from CAN)</name>
+ <type>uint16_t</type>
+ <offset>4</offset>
+ <bit></bit>
+ </pv>
+ <pv id="can_current" val="0">
+ <name>Current (from CAN)</name>
+ <type>uint16_t</type>
+ <offset>6</offset>
+ <bit></bit>
+ </pv>
+ </transportationUnit>
+
+ <transportationUnit direction="undef" cycletime="0">
+ <id prefix="0x18E0F108"/>
+ <size>4</size>
+ <property name="canid-type" value="extended"/>
+ <property name="canid" value="0x18E0F108"/>
+ <property name="canid-andmask" value="0xffffffff"/>
+ <property name="canid-ormask" value="0x00000000"/>
+ <pv id="can_arate" val="0">
+ <name>A Rate (from CAN)</name>
+ <type>uint16_t</type>
+ <offset>0</offset>
+ <bit></bit>
+ </pv>
+ <pv id="can_srate" val="0">
+ <name>S Rate (from CAN)</name>
+ <type>uint16_t</type>
+ <offset>2</offset>
+ <bit></bit>
+ </pv>
+ </transportationUnit>
+
+ </ioConnection>
+
+ </system>
+
+</openIO>
+
Added: branches/fddi-mapping/tests/test_fddi_examplebus1.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_examplebus1.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,145 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <osadl/fddi.h>
+
+/*
+ * application usage of fddi
+ *
+ * FIXME: make this an example and split test case into smaller pieces
+ */
+
+int tpu_callback(fddi_tpu_t *tpu)
+{
+ printf("hallo\n");
+ return 0;
+}
+
+int main(void)
+{
+ fddi_device_t *dev;
+
+ fddi_iface_attr_t exb0_attr;
+ fddi_iface_t exb0_iface;
+ fddi_id_t exb0_id = {
+ .prefix="exb",
+ .index=0,
+ };
+
+ fddi_tpu_t *tpu;
+ fddi_pv_t *pv; /* FIXME: pv_t ? */
+ fddi_param_t *param;
+ char *strbuf;
+ int i;
+ unsigned long ul;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id);
+
+ fddi_iface_init(&exb0_iface, &exb0_attr);
+
+ /* some things you can do with ifaces */
+ fddi_iface_configure(&exb0_iface, "config.xml", NULL);
+
+ fddi_iface_setstate(&exb0_iface, STATE_UNCONFIGURED); /* add blocking/nonblocking */
+ fddi_iface_cmd(&exb0_iface, CMD_START); /* propagates to devices behind iface */
+
+ if (fddi_iface_getnodev(&exb0_iface) != 0)
+ return 1;
+
+ if (fddi_iface_getnotpus(&exb0_iface) != 0)
+ return 1;
+
+ if (fddi_iface_getnopvs(&exb0_iface) != 0)
+ return 1;
+
+ /* do something with all devices */
+ fddi_iface_getdevlist(&exb0_iface, &dev);
+ while (dev) {
+ fddi_dev_getname(dev, &strbuf);
+// printf("device=%s\n", strbuf);
+ fddi_dev_getstatestr(dev, &strbuf);
+// printf(" state=%s\n", strbuf);
+ fddi_dev_getphysid(dev, &i);
+// printf(" phys_id=%i\n", i);
+ fddi_dev_getlogicalid(dev, &i);
+// printf(" logical_id=%i\n", i);
+
+ fddi_dev_getparamlist(dev, ¶m);
+ while (param) {
+ fddi_param_getkey(param, &strbuf);
+// printf(" key=%s", strbuf);
+ fddi_param_getval(param, &strbuf);
+// printf(" value=%s", strbuf);
+ fddi_param_getnext(¶m);
+ }
+
+// printf(" tpus=%i\n", fddi_dev_getnotpus(dev));
+// printf("\n");
+
+ fddi_dev_read_async(dev); /* add arguments */
+ fddi_dev_write_async(dev); /* add arguments */
+
+ fddi_dev_getnext(&dev);
+ }
+
+ /* do something with all tpus */
+ fddi_iface_gettpulist(&exb0_iface, &tpu);
+ while (tpu) {
+ fddi_tpu_getname(tpu, &strbuf);
+// printf("tpu=%s\n", strbuf);
+ fddi_tpu_getid(tpu, &i);
+// printf(" id=%i\n", i);
+ fddi_tpu_gettimestamp(tpu, &i);
+// printf(" timestamp=%i\n", i); /* FIXME tv */
+ fddi_tpu_getflags(tpu, &ul);
+// printf(" flags=%li\n", ul);
+
+ fddi_tpu_setcallback(tpu, tpu_callback);
+
+ /* iterate over process variables */
+ fddi_tpu_getpvlist(tpu, &pv);
+ while (pv) {
+ fddi_pv_getname(pv, &strbuf);
+// printf("pv=%s\n",strbuf);
+ fddi_pv_getnext(&pv);
+ }
+ fddi_tpu_getpayload(tpu, &strbuf);
+// printf(" payload=0x%p\n", strbuf);
+
+ fddi_tpu_send(tpu);
+
+// printf("\n");
+
+ fddi_tpu_getnext(&tpu);
+ }
+
+ /*
+ * Questions:
+ *
+ * - Can an io_interface be deconfigured? Otherwhise we should put the
+ * configure() method into init(). If not, we should add deconfigure
+ * or document that it can be re-run.
+ * -> re-configure is possible
+ * -> null config -> clean
+ *
+ * - Why isn't read_device_async() a method of the io_device?
+ * -> it is, but the stack has to trigger it
+ *
+ * - Are transport units a property of the device or of the io_interface?
+ * Probably io_interface (knows how to collect the process data)
+ * -> the io_interface instance (configured) generates the tpus
+ *
+ * - State handling: isn't that a method of the io_interface? It should
+ * know what to do internally, to bring up it's devices.
+ */
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
Added: branches/fddi-mapping/tests/test_fddi_examplebus_attach_backend.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_examplebus_attach_backend.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,32 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <osadl/fddi.h>
+
+int main(void)
+{
+ fddi_iface_attr_t exb0_attr;
+ fddi_iface_t exb0_iface;
+ fddi_id_t exb0id = {
+ .prefix="exb",
+ .index=0,
+ };
+
+ int ret;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setid(&exb0_attr, NULL, exb0id);
+
+ ret = fddi_iface_init(&exb0_iface, &exb0_attr);
+ if (ret)
+ return ret;
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
Added: branches/fddi-mapping/tests/test_fddi_examplebus_cmd_identify.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_examplebus_cmd_identify.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <osadl/fddi.h>
+
+int main(void)
+{
+ fddi_iface_attr_t exb0_attr;
+ fddi_iface_t exb0_iface;
+ fddi_id_t exb0_id = {
+ .prefix="exb",
+ .index=0,
+ };
+
+ int ret;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id);
+
+ ret = fddi_iface_init(&exb0_iface, &exb0_attr);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_init() failed\n");
+ return ret;
+ }
+
+ ret = fddi_iface_cmd(&exb0_iface, CMD_IDENTIFY);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_cmd(CMD_IDENTIFY) failed\n");
+ return ret;
+ }
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
Added: branches/fddi-mapping/tests/test_fddi_examplebus_cmd_quiterr.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_examplebus_cmd_quiterr.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <osadl/fddi.h>
+
+int main(void)
+{
+ fddi_iface_attr_t exb0_attr;
+ fddi_iface_t exb0_iface;
+ fddi_id_t exb0_id = {
+ .prefix="exb",
+ .index=0,
+ };
+
+ int ret;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id);
+
+ ret = fddi_iface_init(&exb0_iface, &exb0_attr);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_init() failed\n");
+ return ret;
+ }
+
+ ret = fddi_iface_cmd(&exb0_iface, CMD_QUITERR);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_cmd(CMD_QUITERR) failed\n");
+ return ret;
+ }
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
Added: branches/fddi-mapping/tests/test_fddi_examplebus_cmd_reset.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_examplebus_cmd_reset.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <osadl/fddi.h>
+
+int main(void)
+{
+ fddi_iface_attr_t exb0_attr;
+ fddi_iface_t exb0_iface;
+ fddi_id_t exb0_id = {
+ .prefix="exb",
+ .index=0,
+ };
+
+ int ret;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id);
+
+ ret = fddi_iface_init(&exb0_iface, &exb0_attr);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_init() failed\n");
+ return ret;
+ }
+
+ ret = fddi_iface_cmd(&exb0_iface, CMD_RESET);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_cmd(CMD_RESET) failed\n");
+ return ret;
+ }
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
Added: branches/fddi-mapping/tests/test_fddi_examplebus_cmd_start.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_examplebus_cmd_start.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <osadl/fddi.h>
+
+int main(void)
+{
+ fddi_iface_attr_t exb0_attr;
+ fddi_iface_t exb0_iface;
+ fddi_id_t exb0_id = {
+ .prefix="exb",
+ .index=0,
+ };
+
+ int ret;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id);
+
+ ret = fddi_iface_init(&exb0_iface, &exb0_attr);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_init() failed\n");
+ return ret;
+ }
+
+ ret = fddi_iface_cmd(&exb0_iface, CMD_START);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_cmd(CMD_START) failed\n");
+ return ret;
+ }
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
Added: branches/fddi-mapping/tests/test_fddi_examplebus_cmd_stop.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_examplebus_cmd_stop.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <osadl/fddi.h>
+
+int main(void)
+{
+ fddi_iface_attr_t exb0_attr;
+ fddi_iface_t exb0_iface;
+ fddi_id_t exb0_id = {
+ .prefix="exb",
+ .index=0,
+ };
+
+ int ret;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id);
+
+ ret = fddi_iface_init(&exb0_iface, &exb0_attr);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_init() failed\n");
+ return ret;
+ }
+
+ ret = fddi_iface_cmd(&exb0_iface, CMD_STOP);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_cmd(CMD_STOP) failed\n");
+ return ret;
+ }
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
Added: branches/fddi-mapping/tests/test_fddi_examplebus_configure.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_examplebus_configure.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <osadl/fddi.h>
+
+int main(void)
+{
+ fddi_iface_attr_t exb0_attr;
+ fddi_iface_t exb0_iface;
+ fddi_id_t exb0_id = {
+ .prefix="exb",
+ .index=0,
+ };
+
+ int ret;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id);
+
+ ret = fddi_iface_init(&exb0_iface, &exb0_attr);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_init() failed\n");
+ return ret;
+ }
+
+ ret = fddi_iface_configure(&exb0_iface, "test_fddi_examplebus_configure.xml", NULL);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_configure() failed\n");
+ return ret;
+ }
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
Added: branches/fddi-mapping/tests/test_fddi_examplebus_setstate_configerror.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_examplebus_setstate_configerror.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <osadl/fddi.h>
+
+int main(void)
+{
+ fddi_iface_attr_t exb0_attr;
+ fddi_iface_t exb0_iface;
+ fddi_id_t exb0_id = {
+ .prefix="exb",
+ .index=0,
+ };
+
+ int ret;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id);
+
+ ret = fddi_iface_init(&exb0_iface, &exb0_attr);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_init() failed\n");
+ return ret;
+ }
+
+ ret = fddi_iface_setstate(&exb0_iface, STATE_CONFIG_ERROR);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_setstate(STATE_CONFIG_ERROR) failed\n");
+ return ret;
+ }
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
Added: branches/fddi-mapping/tests/test_fddi_examplebus_setstate_missing.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_examplebus_setstate_missing.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <osadl/fddi.h>
+
+int main(void)
+{
+ fddi_iface_attr_t exb0_attr;
+ fddi_iface_t exb0_iface;
+ fddi_id_t exb0_id = {
+ .prefix="exb",
+ .index=0,
+ };
+
+ int ret;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id);
+
+ ret = fddi_iface_init(&exb0_iface, &exb0_attr);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_init() failed\n");
+ return ret;
+ }
+
+ ret = fddi_iface_setstate(&exb0_iface, STATE_MISSING);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_setstate(STATE_MISSING) failed\n");
+ return ret;
+ }
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
Added: branches/fddi-mapping/tests/test_fddi_examplebus_setstate_operation_error.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_examplebus_setstate_operation_error.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <osadl/fddi.h>
+
+int main(void)
+{
+ fddi_iface_attr_t exb0_attr;
+ fddi_iface_t exb0_iface;
+ fddi_id_t exb0_id = {
+ .prefix="exb",
+ .index=0,
+ };
+
+ int ret;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id);
+
+ ret = fddi_iface_init(&exb0_iface, &exb0_attr);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_init() failed\n");
+ return ret;
+ }
+
+ ret = fddi_iface_setstate(&exb0_iface, STATE_OPERATION_ERROR);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_setstate(STATE_OPERATION_ERROR) failed\n");
+ return ret;
+ }
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
Added: branches/fddi-mapping/tests/test_fddi_examplebus_setstate_operational.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_examplebus_setstate_operational.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <osadl/fddi.h>
+
+int main(void)
+{
+ fddi_iface_attr_t exb0_attr;
+ fddi_iface_t exb0_iface;
+ fddi_id_t exb0_id = {
+ .prefix="exb",
+ .index=0,
+ };
+
+ int ret;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id);
+
+ ret = fddi_iface_init(&exb0_iface, &exb0_attr);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_init() failed\n");
+ return ret;
+ }
+
+ ret = fddi_iface_setstate(&exb0_iface, STATE_OPERATIONAL);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_setstate(STATE_OPERATIONAL) failed\n");
+ return ret;
+ }
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
Added: branches/fddi-mapping/tests/test_fddi_examplebus_setstate_preoperational.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_examplebus_setstate_preoperational.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <osadl/fddi.h>
+
+int main(void)
+{
+ fddi_iface_attr_t exb0_attr;
+ fddi_iface_t exb0_iface;
+ fddi_id_t exb0_id = {
+ .prefix="exb",
+ .index=0,
+ };
+
+ int ret;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id);
+
+ ret = fddi_iface_init(&exb0_iface, &exb0_attr);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_init() failed\n");
+ return ret;
+ }
+
+ ret = fddi_iface_setstate(&exb0_iface, STATE_PREOPERATIONAL);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_setstate(STATE_PREOPERATIONAL) failed\n");
+ return ret;
+ }
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
Added: branches/fddi-mapping/tests/test_fddi_examplebus_setstate_unconfigured.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_examplebus_setstate_unconfigured.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <osadl/fddi.h>
+
+int main(void)
+{
+ fddi_iface_attr_t exb0_attr;
+ fddi_iface_t exb0_iface;
+ fddi_id_t exb0_id = {
+ .prefix="exb",
+ .index=0,
+ };
+
+ int ret;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id);
+
+ ret = fddi_iface_init(&exb0_iface, &exb0_attr);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_init() failed\n");
+ return ret;
+ }
+
+ ret = fddi_iface_setstate(&exb0_iface, STATE_UNCONFIGURED);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_setstate(STATE_UNCONFIGURED) failed\n");
+ return ret;
+ }
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
Added: branches/fddi-mapping/tests/test_fddi_examplebus_tpu_usecase.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_examplebus_tpu_usecase.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,154 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <osadl/fddi.h>
+
+int main(void)
+{
+ fddi_iface_attr_t exb0_attr;
+ fddi_iface_t exb0_iface;
+ fddi_tpu_t *tpu;
+ fddi_id_t exb0_id = {
+ .prefix="exb",
+ .index=0,
+ };
+
+ int ret;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id);
+
+ ret = fddi_iface_init(&exb0_iface, &exb0_attr);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_init() failed\n");
+ return ret;
+ }
+
+ ret = fddi_iface_configure(&exb0_iface, "config.xml", NULL);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_configure() failed\n");
+ fddi_iface_destroy(&exb0_iface);
+ return ret;
+ }
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
+/* FIXME pseudocode */
+
+int main1(void)
+{
+ int endme;
+ pv_engine_t engine;
+ pv_engine_attr_t engine_attr;
+ pv_group_t group;
+ int ret;
+
+ struct pv {
+ pv_uint32_t voltage;
+ pv_uint32_t speed;
+ pv_uint32_t x;
+ pv_bool_t end_switch_left;
+ pv_bool_t end_switch_right;
+ }
+
+ /* instanciate a pv_engine */
+ ret = pv_engine_init(&engine, &engine_attr);
+ if (ret) {
+ fprintf(stderr, "pv_init() failed\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /*
+ * now register a pv_group (lockable set of pvs)
+ * let's take for example a linear drive
+ */
+
+ ret = pv_group_init(&group);
+ if (ret) {
+ fprintf(stderr, "pv_group_init() failed\n");
+ pv_engine_destroy(&engine);
+ exit(EXIT_FAILURE);
+ }
+
+ ret = 0;
+ ret += pv_group_register_uint32(&group, "voltage", &pv.voltage, O_RDWR);
+ ret += pv_group_register_uint32(&group, "current_speed", &pv.current_speed, O_RDONLY);
+ ret += pv_group_register_uint32(&group, "current_x", &pv.current_x, O_RDONLY);
+ ret += pv_group_register_bool(&group, "end_switch_left", &pv.end_switch_left, O_RDONLY);
+ ret += pv_group_register_bool(&group, "end_switch_right", &pv.end_switch_right, O_RDONLY);
+
+ if (ret != 0) {
+ fprintf(stderr, "error registering process variables\n");
+ pv_group_destroy(&group);
+ pv_engine_destroy(&engine);
+ exit(EXIT_FAILURE);
+ }
+
+ /* example for "active / locking" scenario */
+
+ while (!endme) {
+
+ /*
+ * "lock" the pv_group while updating the pvs; note that the
+ * pv_group contains a list of all affected TPUs, and locking
+ * means that we "allocate" a tpu (usecount+=1) while accessing it
+ */
+ pv_group_lock(&group, timeout);
+
+ /* starting from here, we have our exclusive sets of TPU buffers */
+
+ /* yes, printf is not realtime, just for demonstration */
+ printf("current speed: \n", pv_uint32_get(&pv.current_speed));
+ printf("current x: \n", pv_uint32_get(&pv.current_x));
+ printf("end_switch_left: \n", pv_bool_get(&pv.end_switch_left));
+ printf("end_switch_right: \n", pv_bool_get(&pv.end_switch_right));
+
+ /* now calculate the outputs */
+ pv_uint32_set(&pv.voltage, 12345);
+
+ /*
+ * update outputs
+ */
+ pv_group_unlock(&group);
+
+ sleep_until_next_period();
+
+ }
+
+ /* example for "blocking" scenario, for group */
+
+ while (!endme) {
+ /* sleep until one of the TPUs in the group updates */
+ pv_group_lock_on_group_change(&group, timeout);
+ /* do something with the pvs, or find out which pvs have changed */
+ pv_group_unlock(&group);
+ }
+
+ /* example for "blocking" scenario, for pv */
+
+ while (!endme) {
+ pv_group_lock_on_pv_change(&group, &pv.current.speed, timeout);
+ /* ... */
+ pv_group_unlock(&group);
+ }
+
+ /* example for "callback" scenario */
+ pv_group_callback_on_group_change(&group, function);
+ pv_group_callback_on_pv_change(&group, &pv.current.speed, function);
+
+ while (!endme)
+ sleep(1);
+
+ /* destruct */
+ pv_set_destroy(&set);
+ pv_engine_destroy(&engine);
+
+ return 0;
+}
+
Added: branches/fddi-mapping/tests/test_fddi_libmodbus1.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_libmodbus1.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,96 @@
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <osadl/fddi.h>
+
+static int endme;
+
+void signalhandler(int sig)
+{
+ if (sig == SIGPIPE)
+ return;
+ if (sig == SIGHUP) {
+ fprintf(stderr, "SIGHUP received\n");
+ }
+ if (sig == SIGTERM || sig == SIGINT) {
+ fprintf(stderr, "ctrl-c pressed, shutting down\n");
+ endme = 1;
+ }
+}
+
+
+int tpu_callback(fddi_tpu_t *tpu, void *arg)
+{
+ printf("callback\n");
+ return 0;
+}
+
+/*
+ * FIXME: we have to agree on a bus start workflow!
+ */
+
+int main(void)
+{
+ struct sigaction action;
+
+ fddi_iface_attr_t modbus0_attr;
+ fddi_iface_t modbus0_iface;
+ fddi_id_t modbus0_id;
+ fddi_tpu_t *tpu;
+
+ int ret;
+
+ /* setup signal handler */
+ action.sa_handler = signalhandler;
+ sigemptyset(&action.sa_mask);
+ action.sa_flags = 0;
+ sigaction(SIGTERM, &action, 0); /* catches kill from the shell */
+ sigaction(SIGINT, &action, 0); /* catches Ctrl-C from the shell */
+ sigaction(SIGPIPE, &action, 0); /* catches Broken Pipe exception */
+ sigaction(SIGHUP, &action, 0); /* catches HUP */
+
+ fddi_id_init(&modbus0_id, "modbus", 0, NULL);
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&modbus0_attr);
+ fddi_iface_attr_setclass(&modbus0_attr, "libfddi_libmodbus.so");
+ fddi_iface_attr_setid(&modbus0_attr, "demosystem.controller", modbus0_id);
+
+ ret = fddi_iface_init(&modbus0_iface, &modbus0_attr);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_init() failed\n");
+ return ret;
+ }
+
+ ret = fddi_iface_configure(&modbus0_iface, "test_fddi_libmodbus1.xml", NULL);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_configure() failed\n");
+ return ret;
+ }
+
+ /* attach callbacks to TPUs */
+ fddi_iface_gettpulist(&modbus0_iface, &tpu);
+ while (tpu) {
+ fddi_tpu_setcallback(tpu, tpu_callback, NULL);
+ fddi_tpu_getnext(&tpu);
+ }
+
+ /* everything is configured, now we can start */
+ ret = fddi_iface_cmd(&modbus0_iface, CMD_START);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_cmd() failed\n");
+ return ret;
+ }
+
+ printf("entering main loop, press ctrl-c to end\n");
+ while (!endme)
+ sleep(1);
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&modbus0_iface);
+
+ exit(0);
+}
+
Added: branches/fddi-mapping/tests/test_fddi_versionstr.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/test_fddi_versionstr.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,36 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <osadl/fddi.h>
+
+int main(void)
+{
+ fddi_iface_attr_t exb0_attr;
+ fddi_iface_t exb0_iface;
+
+ int ret;
+ const char *version;
+ fddi_id_t exb0_id = {
+ .prefix="exb",
+ .index=0,
+ };
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id);
+
+ ret = fddi_iface_init(&exb0_iface, &exb0_attr);
+ if (ret)
+ return ret;
+
+ fddi_iface_getversionstr(&exb0_iface, &version);
+ printf("fddi version: %s\n", version);
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
Added: branches/fddi-mapping/tests/usecase_controller.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/usecase_controller.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,149 @@
+#include <signal.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <osadl/fddi.h>
+
+/*
+ * FIXME:
+ * - for timeout, invent a mechanism which wakes up _all_
+ * wait_and_locks and lets them return with an error
+ * - do we need the type for pv_attr and pv_*_init?
+ */
+
+#define PV_CREATE(var, thetype, group) \
+ do { \
+ int ret; \
+ char *name = strdup(#var); \
+ fddi_pv_attr_t pv_##var##_attr = { .type = thetype, .name = name, .pv_group = group, }; \
+ ret = fddi_pv_##thetype##_init(&pv_##var, &pv_##var##_attr); \
+ if (ret) { \
+ fprintf(stderr, "error: could not register process variable '"#var"'\n"); \
+ goto out_pv_##var; \
+ } \
+ } while(0)
+
+#define PV_DESTROY(var, type) \
+ fddi_pv_##type##_destroy(&pv_##var); \
+ out_pv_##var: \
+ do {} while(0)
+
+static int shutdown = 0;
+static int Ta = (10*1000*1000); /* 10 ms */
+
+void
+signalhandler(int sig)
+{
+ if ((sig == SIGPIPE) || (sig == SIGHUP))
+ return;
+ if (sig == SIGTERM || sig == SIGINT)
+ shutdown = 1;
+}
+
+int main(int argc, char *argv[])
+{
+ struct sigaction action;
+ fddi_pv_engine_t pv_engine;
+ fddi_pv_group_attr_t pv_group_attr;
+ fddi_pv_group_t pv_group;
+ int ret;
+
+ fddi_pv_t pv_input;
+ fddi_pv_t pv_output;
+ fddi_pv_t pv_Kp;
+ fddi_pv_t pv_Ki;
+ fddi_pv_t pv_Kd;
+
+ /* setup signal handler */
+ action.sa_handler = signalhandler;
+ sigemptyset (&action.sa_mask);
+ action.sa_flags = 0;
+ sigaction (SIGTERM, &action, 0); /* catches kill from the shell */
+ sigaction (SIGINT, &action, 0); /* catches Ctrl-C from the shell */
+ sigaction (SIGPIPE, &action, 0); /* catches Broken Pipe exception */
+ sigaction (SIGHUP, &action, 0); /* catches HUP */
+
+ /* initialize */
+ ret = fddi_pv_engine_init(&pv_engine);
+ if (ret) {
+ fprintf(stderr, "error: could not create pv_engine\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* fddi_pv_engine_configure(&pv_engine, "model.xml", "/path/for/module"); */
+ ret = fddi_pv_engine_configure_from_cmdline(&pv_engine, argc, argv);
+ if (ret) {
+ fprintf(stderr, "error: could not configure pv_engine\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* initialize pv_group */
+ ret = fddi_pv_group_attr_init(&pv_group_attr, &pv_engine);
+ if (ret) {
+ fprintf(stderr, "error: could not init pv_group_attr\n");
+ exit(EXIT_FAILURE);
+ }
+ ret = fddi_pv_group_attr_setname(&pv_group_attr, "controller");
+ if (ret) {
+ fprintf(stderr, "error: could not set pv_group's name\n");
+ exit(EXIT_FAILURE);
+ }
+ ret = fddi_pv_group_init(&pv_group, &pv_group_attr);
+ if (ret) {
+ fprintf(stderr, "error: couldn't create pv_group\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* register process variables and put them into pv_group */
+ PV_CREATE(input, UINT32, &pv_group);
+ PV_CREATE(output, UINT32, &pv_group);
+ PV_CREATE(Kp, UINT32, &pv_group);
+ PV_CREATE(Ki, UINT32, &pv_group);
+ PV_CREATE(Kd, UINT32, &pv_group);
+
+ /* control loop */
+ while (!shutdown) {
+
+ uint32_t e, x, esum, ealt;
+
+ /*
+ * make this compile time configurable:
+ *
+ * a) lock
+ * b) lock -> make local pv copy into priv -> unlock
+ * c) rcu_lock
+ */
+
+ ret = fddi_pv_group_wait_and_lock(&pv_group);
+
+ e = fddi_pv_uint32_get(&pv_input) - x; /* comparism */
+ esum = esum + e; /* I part */
+ fddi_pv_uint32_set(&pv_output,
+ fddi_pv_uint32_get(&pv_Kp)*e +
+ fddi_pv_uint32_get(&pv_Ki)*Ta*esum +
+ fddi_pv_uint32_get(&pv_Kd)/Ta * (e ? ealt : e)
+ );
+ ealt = e;
+
+ /*
+ * a) unlock
+ * b) lock -> make local pv copy from priv -> unlock
+ * c) rcu_unlock
+ */
+ fddi_pv_group_unlock(&pv_group);
+ }
+
+ PV_DESTROY(Kd, uint32);
+ PV_DESTROY(Ki, uint32);
+ PV_DESTROY(Kp, uint32);
+ PV_DESTROY(output, uint32);
+ PV_DESTROY(input, uint32);
+
+ fddi_pv_group_destroy(&pv_group);
+ fddi_pv_group_attr_destroy(&pv_group_attr);
+
+ return ret;
+}
+
Added: branches/fddi-mapping/tests/usecase_streaming.c
==============================================================================
--- (empty file)
+++ branches/fddi-mapping/tests/usecase_streaming.c Tue Oct 2 16:30:06 2007
@@ -0,0 +1,110 @@
+#include <signal.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+//#include <osadl/ldi.h>
+
+/* FIXME put into header file */
+
+ typedef struct ldi_attr {
+ } ldi_attr_t;
+
+ typedef struct ldi {
+ } ldi_t;
+ typedef struct pv {
+ } pv_t;
+ typedef struct tpu {
+ } tpu_t;
+
+ /* pv */
+ int pv_uint32_create(pv_t *pv, ldi_t *ldi, const char *name);
+ int pv_uint32_destroy(pv_t *pv);
+ uint32_t pv_uint32_get(pv_t *pv);
+ void pv_uint32_set(pv_t *pv, uint32_t val);
+
+ /* tpu */
+ int tpu_create(tpu_t *tpu /*, FIXME */);
+ int tpu_destroy(tpu_t *tpu);
+
+ /* ldi_attr */
+ int ldi_attr_init_from_cmdline(ldi_attr_t *attr, int argc, char *argv[]);
+ int ldi_attr_destroy(ldi_attr_t *attr);
+
+ /* ldi */
+ int ldi_create(ldi_t *ldi, ldi_attr_t *attr);
+ int ldi_destroy(ldi_t *ldi);
+ int ldi_trigger_define(ldi_t *ldi, pv_t *pv);
+ int ldi_trigger_wait(ldi_t *ldi, uint64_t timeout_ns);
+ int ldi_tpu_trigger_define(ldi_t *ldi, tpu_t *tpu);
+
+
+static int shutdown = 0;
+
+void
+signalhandler(int sig)
+{
+ if ((sig == SIGPIPE) || (sig == SIGHUP))
+ return;
+ if (sig == SIGTERM || sig == SIGINT)
+ shutdown = 1;
+}
+
+int main(int argc, char *argv[])
+{
+ struct sigaction action;
+ ldi_attr_t ldi_attr;
+ ldi_t ldi;
+ int ret;
+
+ tpu_t tpu;
+
+ /* setup signal handler */
+ action.sa_handler = signalhandler;
+ sigemptyset (&action.sa_mask);
+ action.sa_flags = 0;
+ sigaction (SIGTERM, &action, 0); /* catches kill from the shell */
+ sigaction (SIGINT, &action, 0); /* catches Ctrl-C from the shell */
+ sigaction (SIGPIPE, &action, 0); /* catches Broken Pipe exception */
+ sigaction (SIGHUP, &action, 0); /* catches HUP */
+
+ /* initialize ldi */
+ ret = ldi_attr_init_from_cmdline(&ldi_attr, argc, argv);
+ if (ret) {
+ fprintf(stderr, "error: could not init ldi_attr\n");
+ exit(EXIT_FAILURE);
+ }
+
+ ret = ldi_create(&ldi, &ldi_attr);
+ if (ret) {
+ fprintf(stderr, "error: couldn't create ldi\n");
+ exit(EXIT_FAILURE);
+ }
+
+ ret = tpu_create(&tpu); /* FIXME: how to find out which one? */
+ if (ret) {
+ fprintf(stderr, "error: could not register tpu\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* this TPU is our trigger */
+ ret = ldi_tpu_trigger_define(&ldi, &tpu);
+
+ /* control loop */
+ while (!shutdown) {
+
+ ret = ldi_trigger_wait(&ldi, 100*1000*1000); /* wait until trigger fires, with timeout in ns */
+ if (ret)
+ continue;
+
+ /* FIXME now what to do with the tpu payload? */
+ /* FIXME how to decide when TPUs are pushed back to the pool? */
+
+ }
+
+ tpu_destroy(&tpu);
+
+ ldi_destroy(&ldi);
+ ldi_attr_destroy(&ldi_attr);
+ return ret;
+}
More information about the OSADL-svn-commits
mailing list