[OSADL-svn-commits] r19 - in fddi-20070618-1-trunk: . include/osadl libltdl src tests
OSADL repository commits
osadl-svn-commits at lists.osadl.org
Tue Oct 2 11:42:10 CEST 2007
Author: robert
Date: Sat Jun 30 00:08:14 2007
New Revision: 19
Log:
backend example built, testing added
Added:
fddi-20070618-1-trunk/include/osadl/fddi_hess.h
fddi-20070618-1-trunk/libltdl/
fddi-20070618-1-trunk/libltdl/.secret-world-domination-project
fddi-20070618-1-trunk/src/libfddi_hess.c
fddi-20070618-1-trunk/tests/example.xml
fddi-20070618-1-trunk/tests/examplebus.h
fddi-20070618-1-trunk/tests/fddi_examplebus.h
fddi-20070618-1-trunk/tests/libexamplebus.c
fddi-20070618-1-trunk/tests/libfddi_examplebus.c
fddi-20070618-1-trunk/tests/test_examplebus1.c
fddi-20070618-1-trunk/tests/test_fddi_examplebus1.c
fddi-20070618-1-trunk/tests/test_fddi_examplebus1.sh (contents, props changed)
fddi-20070618-1-trunk/tests/test_fddi_examplebus_attach_backend.c
fddi-20070618-1-trunk/tests/test_fddi_examplebus_attach_backend.sh (contents, props changed)
fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd (contents, props changed)
fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd.c
fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd.sh (contents, props changed)
fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_identify.c
fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_identify.sh (contents, props changed)
fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_quiterr.c
fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_quiterr.sh (contents, props changed)
fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_reset.c
fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_reset.sh (contents, props changed)
fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_start.c
fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_start.sh (contents, props changed)
fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_stop.c
fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_stop.sh (contents, props changed)
fddi-20070618-1-trunk/tests/test_fddi_examplebus_readconfig.c
fddi-20070618-1-trunk/tests/test_fddi_examplebus_readconfig.sh (contents, props changed)
fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate.c
fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate.sh (contents, props changed)
Removed:
fddi-20070618-1-trunk/tests/test_hess_1.c
Modified:
fddi-20070618-1-trunk/GNUmakefile.am
fddi-20070618-1-trunk/autogen.sh
fddi-20070618-1-trunk/configure.ac
fddi-20070618-1-trunk/include/osadl/fddi.h
fddi-20070618-1-trunk/src/GNUmakefile.am
fddi-20070618-1-trunk/src/libfddi.c
fddi-20070618-1-trunk/tests/GNUmakefile.am
Modified: fddi-20070618-1-trunk/GNUmakefile.am
==============================================================================
--- fddi-20070618-1-trunk/GNUmakefile.am (original)
+++ fddi-20070618-1-trunk/GNUmakefile.am Sat Jun 30 00:08:14 2007
@@ -1,4 +1,4 @@
-SUBDIRS = include config src tests
+SUBDIRS = libltdl include config src tests
EXTRA_DIST = \
autogen.sh \
Modified: fddi-20070618-1-trunk/autogen.sh
==============================================================================
--- fddi-20070618-1-trunk/autogen.sh (original)
+++ fddi-20070618-1-trunk/autogen.sh Sat Jun 30 00:08:14 2007
@@ -30,12 +30,12 @@
# '{if ($1 == PROG) {gsub ("-.*","",$4); if ($4 < VERS) print PROG" < version "VERS"\nThis may result in errors\n"}}'
-banner "running libtoolize"
-libtoolize --force || exit
-
banner "running aclocal"
$ACLOCAL -I config/m4 || exit
+banner "running libtoolize"
+libtoolize --force --ltdl --copy || exit
+
banner "running autoheader"
$AUTOHEADER || exit
Modified: fddi-20070618-1-trunk/configure.ac
==============================================================================
--- fddi-20070618-1-trunk/configure.ac (original)
+++ fddi-20070618-1-trunk/configure.ac Sat Jun 30 00:08:14 2007
@@ -28,22 +28,24 @@
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)
#
# Checks for programs.
#
AC_PROG_CC
-#AM_MISSING_PROG(PERL, perl, $missing_dir)
-# libtool, old:
-AC_LIBTOOL_WIN32_DLL
-#AC_LIBTOOL_TAGS([])
-AC_PROG_LIBTOOL
-# libtool, new:
-# LT_INIT(win32-dll)
AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2])
-
#
# Checks for libraries.
#
Modified: fddi-20070618-1-trunk/include/osadl/fddi.h
==============================================================================
--- fddi-20070618-1-trunk/include/osadl/fddi.h (original)
+++ fddi-20070618-1-trunk/include/osadl/fddi.h Sat Jun 30 00:08:14 2007
@@ -1,422 +1,145 @@
-#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 */
-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
-
+#ifndef OSADL_FDDI_H
+#define OSADL_FDDI_H
+
+typedef 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 */
+
+} fddi_state_enum_t;
+
+typedef 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 */
+
+} fddi_cmd_enum_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_tpu fddi_tpu_t;
+typedef struct fddi_iface_backend_ops fddi_iface_backend_ops_t;
+typedef struct fddi_iface fddi_iface_t;
+
+struct fddi_param {
+
+ char *key;
+ char *val;
+ unsigned long flags;
+ struct fddi_param *next;
+ struct fddi_param *previous;
+
+};
+
+struct fddi_device {
+
+ char *name;
+ fddi_state_enum_t state;
+ struct fddi_device *next;
+ struct fddi_device *previous;
+ fddi_param_t *param_list;
+
+};
+
+struct fddi_iface_attr {
+
+ char *fddi_class_name;
+ char *fddi_device_name;
+
+};
+
+struct fddi_pv {
+ struct fddi_pv *next;
+ struct fddi_pv *previous;
+};
+
+struct fddi_tpu {
+ char *name;
+ int id;
+ unsigned long flags;
+ struct fddi_tpu *next;
+ struct fddi_tpu *previous;
+ fddi_pv_t *pv_list;
+ char *payload;
+};
+
+struct fddi_iface_backend_ops {
+ int (*readconfig) (fddi_iface_t *iface, const char *configfile);
+ 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 {
+
+ char *name; /* FIXME: add access functions */
+ unsigned long version; /* FIXME: auto generate from configure.ac */
+ fddi_state_enum_t state;
+ fddi_device_t *devlist_head;
+ fddi_tpu_t *tpulist_head;
+
+ void *backend_lib;
+ fddi_iface_backend_ops_t backend;
+
+};
+
+/* 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_setdevice(fddi_iface_attr_t *attr, char *device_name);
+
+/* 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_readconfig(fddi_iface_t *iface, const char *configfile);
+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_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);
+
+/* 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 */);
+
+/* 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);
+
+/* fddi_tpu_t */
+extern int fddi_tpu_getnext(fddi_tpu_t **tpu);
+extern int fddi_tpu_getname(fddi_tpu_t *tpu, char **name);
+extern int fddi_tpu_getid(fddi_tpu_t *tpu, int *id);
+extern int fddi_tpu_gettimestamp(fddi_tpu_t *tpu, int *timestamp); /* FIXME tv */
+extern int fddi_tpu_getflags(fddi_tpu_t *tpu, unsigned long *flags);
+extern int fddi_tpu_setcallback(fddi_tpu_t *tpu, int(*tpu_callback)(fddi_tpu_t *tpu));
+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_send(fddi_tpu_t *tpu);
+
+/* fddi_pv_t */
+extern int fddi_pv_getnext(fddi_pv_t **pv);
+extern int fddi_pv_getname(fddi_pv_t *pv, char **name);
+
+#endif
Added: fddi-20070618-1-trunk/include/osadl/fddi_hess.h
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/include/osadl/fddi_hess.h Sat Jun 30 00:08:14 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: fddi-20070618-1-trunk/libltdl/.secret-world-domination-project
==============================================================================
Modified: fddi-20070618-1-trunk/src/GNUmakefile.am
==============================================================================
--- fddi-20070618-1-trunk/src/GNUmakefile.am (original)
+++ fddi-20070618-1-trunk/src/GNUmakefile.am Sat Jun 30 00:08:14 2007
@@ -1,7 +1,5 @@
lib_LTLIBRARIES = libfddi.la
-#bin_PROGRAMS = fddi
-
AM_CPPFLAGS = \
-I$(top_srcdir)/include \
-I$(top_builddir)/include
@@ -9,12 +7,13 @@
libfddi_la_SOURCES = \
libfddi.c
-#fddi_la_LDFLAGS = \
-# -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
-# -no-undefined # win32_dll stuff only
+libfddi_la_LDFLAGS = \
+ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
+ -no-undefined \
+ -export-dynamic
-#fddi_SOURCES = \
-# fddi.c
+libfddi_la_LIBADD = \
+ $(LIBLTDL)
MAINTAINERCLEANFILES = \
GNUmakefile.in
Modified: fddi-20070618-1-trunk/src/libfddi.c
==============================================================================
--- fddi-20070618-1-trunk/src/libfddi.c (original)
+++ fddi-20070618-1-trunk/src/libfddi.c Sat Jun 30 00:08:14 2007
@@ -1,289 +1,423 @@
-#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;
-}
-
+#include <errno.h>
+#include <ltdl.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <osadl/fddi.h>
+
+static pthread_mutex_t lt_dl_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* 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 *fddi_class_name)
+{
+ if ((!attr) || (!fddi_class_name))
+ return EINVAL;
+
+ attr->fddi_class_name = fddi_class_name;
+
+ return 0;
+}
+
+int fddi_iface_attr_setdevice(fddi_iface_attr_t *attr, char *fddi_device_name)
+{
+ if (!attr)
+ return EINVAL;
+
+ attr->fddi_device_name = fddi_device_name;
+
+ return 0;
+}
+
+/* fddi_iface_t */
+int fddi_iface_init(fddi_iface_t *iface, fddi_iface_attr_t *attr)
+{
+ const char *error_string;
+
+ if ((!iface) || (!attr))
+ return EINVAL;
+
+ if ((attr->fddi_class_name == NULL) || (attr->fddi_device_name == NULL))
+ return EINVAL;
+
+ /* initialize instance variables */
+ iface->devlist_head = NULL;
+ iface->tpulist_head = NULL;
+
+ /* 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.readconfig = lt_dlsym(iface->backend_lib, "readconfig");
+ if ((error_string = lt_dlerror())) {
+ pthread_mutex_unlock(<_dl_mutex);
+ goto iface_init_err;
+ }
+
+ iface->backend.setstate = lt_dlsym(iface->backend_lib, "setstate");
+ if ((error_string = lt_dlerror())) {
+ pthread_mutex_unlock(<_dl_mutex);
+ goto iface_init_err;
+ }
+
+ iface->backend.cmd = lt_dlsym(iface->backend_lib, "cmd");
+ if ((error_string = lt_dlerror())) {
+ pthread_mutex_unlock(<_dl_mutex);
+ goto iface_init_err;
+ }
+
+ pthread_mutex_unlock(<_dl_mutex);
+
+ return 0;
+
+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
+}
+
+int fddi_iface_destroy(fddi_iface_t *iface)
+{
+ if (!iface)
+ return EINVAL;
+
+ pthread_mutex_lock(<_dl_mutex);
+ lt_dlclose(iface->backend_lib);
+ pthread_mutex_unlock(<_dl_mutex);
+
+ return 0;
+}
+
+int fddi_iface_readconfig(fddi_iface_t *iface, const char *configfile)
+{
+ if ((!iface) || (!configfile))
+ return EINVAL;
+
+ if (!iface->backend.readconfig)
+ return ENOSYS;
+
+ return iface->backend.readconfig(iface, configfile);
+}
+
+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_getnodev(fddi_iface_t *iface)
+{
+ if (!iface)
+ return EINVAL;
+ /* FIXME */
+ return 0;
+}
+
+int fddi_iface_getnotpus(fddi_iface_t *iface)
+{
+ if (!iface)
+ return EINVAL;
+ /* FIXME */
+ return 0;
+}
+
+int fddi_iface_getnopvs(fddi_iface_t *iface)
+{
+ if (!iface)
+ return EINVAL;
+ /* FIXME */
+ return 0;
+}
+
+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;
+}
+
+
+/* fddi_device_t */
+int fddi_dev_getnext(fddi_device_t **dev)
+{
+ if (!dev)
+ return ENODEV;
+
+ *dev = (*dev)->next;
+ return 0;
+}
+
+int fddi_dev_getname(fddi_device_t *dev, char **name)
+{
+ if ((!dev) || (!name))
+ return EINVAL;
+
+ *name = dev->name;
+ 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;
+ /* FIXME */
+ *id = 0;
+ return 0;
+}
+
+int fddi_dev_getlogicalid(fddi_device_t *dev, int *id)
+{
+ if (!dev)
+ return EINVAL;
+ /* FIXME */
+ *id = 0;
+ return 0;
+}
+
+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 0;
+}
+
+int fddi_dev_read_async(fddi_device_t *dev /* FIXME */)
+{
+ if (!dev)
+ return EINVAL;
+ return 0;
+}
+
+int fddi_dev_write_async(fddi_device_t *dev /* FIXME */)
+{
+ if (!dev)
+ return EINVAL;
+ return 0;
+}
+
+
+/* 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;
+
+ *notpus = 0; /* FIXME */
+ return 0;
+}
+
+
+/* fddi_tpu_t */
+int fddi_tpu_getnext(fddi_tpu_t **tpu)
+{
+ if (!tpu)
+ return EINVAL;
+
+ *tpu = (*tpu)->next;
+ return 0;
+}
+
+int fddi_tpu_getname(fddi_tpu_t *tpu, char **name)
+{
+ if ((!tpu) || (!name))
+ return EINVAL;
+
+ *name = tpu->name;
+ return 0;
+}
+
+int fddi_tpu_getid(fddi_tpu_t *tpu, int *id)
+{
+ if ((!tpu) || (!id))
+ return EINVAL;
+
+ *id = tpu->id;
+ 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_getflags(fddi_tpu_t *tpu, unsigned long *flags)
+{
+ if ((!tpu) || (!flags))
+ return EINVAL;
+
+ *flags = tpu->flags;
+ return 0;
+}
+
+int fddi_tpu_setcallback(fddi_tpu_t *tpu, int(*tpu_callback)(fddi_tpu_t *tpu))
+{
+ if ((!tpu) || (!tpu_callback))
+ return EINVAL;
+ return 0;
+}
+
+int fddi_tpu_getpvlist(fddi_tpu_t *tpu, fddi_pv_t **pv)
+{
+ if ((!tpu) || (!pv))
+ return EINVAL;
+
+ *pv = tpu->pv_list;
+ 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_send(fddi_tpu_t *tpu)
+{
+ return 0;
+}
+
+
+/* fddi_pv_t */
+int fddi_pv_getnext(fddi_pv_t **pv)
+{
+ if (!pv)
+ return EINVAL;
+
+ *pv = (*pv)->next;
+ return 0;
+}
+
+int fddi_pv_getname(fddi_pv_t *pv, char **name)
+{
+ if ((!pv) || (!name))
+ return EINVAL;
+
+ *name = NULL;
+ return 0;
+}
+
Added: fddi-20070618-1-trunk/src/libfddi_hess.c
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/src/libfddi_hess.c Sat Jun 30 00:08:14 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;
+}
+
Modified: fddi-20070618-1-trunk/tests/GNUmakefile.am
==============================================================================
--- fddi-20070618-1-trunk/tests/GNUmakefile.am (original)
+++ fddi-20070618-1-trunk/tests/GNUmakefile.am Sat Jun 30 00:08:14 2007
@@ -1,15 +1,116 @@
TESTS = \
- test_hess_1
+ test_examplebus1 \
+ test_fddi_examplebus1.sh \
+ test_fddi_examplebus_attach_backend.sh \
+ test_fddi_examplebus_readconfig.sh \
+ test_fddi_examplebus_cmd_start.sh \
+ test_fddi_examplebus_cmd_stop.sh \
+ test_fddi_examplebus_cmd_quiterr.sh \
+ test_fddi_examplebus_cmd_identify.sh \
+ test_fddi_examplebus_cmd_reset.sh \
+ test_fddi_examplebus_setstate.sh
noinst_PROGRAMS = \
- test_hess_1
+ test_examplebus1 \
+ test_fddi_examplebus1 \
+ test_fddi_examplebus_attach_backend \
+ test_fddi_examplebus_readconfig \
+ 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
-test_hess_1_SOURCES = test_hess_1.c
-#test_LDADD = $(top_builddir)/src/libfddi.la
+lib_LTLIBRARIES = \
+ libexamplebus.la \
+ libfddi_examplebus.la
AM_CPPFLAGS = \
-I$(top_srcdir)/include \
- -I$(top_builddir)/include
+ -I$(top_builddir)/include \
+ $(LTDLINCL)
+
+#
+# libraries
+#
+
+libexamplebus_la_SOURCES = \
+ libexamplebus.c
+
+libfddi_examplebus_la_SOURCES = \
+ libfddi_examplebus.c
+
+libfddi_examplebus_la_LDFLAGS = \
+ -module
+
+#
+# tests
+#
+
+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_examplebus_readconfig_SOURCES = \
+ test_fddi_examplebus_readconfig.c
+
+test_fddi_examplebus_readconfig_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_SOURCES = \
+ test_fddi_examplebus_setstate.c
+
+test_fddi_examplebus_setstate_LDADD = \
+ $(top_builddir)/src/libfddi.la
+
+#fddi_la_LDFLAGS = \
+# -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
+# -no-undefined # win32_dll stuff only
MAINTAINERCLEANFILES = \
GNUmakefile.in
Added: fddi-20070618-1-trunk/tests/example.xml
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/example.xml Sat Jun 30 00:08:14 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: fddi-20070618-1-trunk/tests/examplebus.h
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/examplebus.h Sat Jun 30 00:08:14 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: fddi-20070618-1-trunk/tests/fddi_examplebus.h
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/fddi_examplebus.h Sat Jun 30 00:08:14 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: fddi-20070618-1-trunk/tests/libexamplebus.c
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/libexamplebus.c Sat Jun 30 00:08:14 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: fddi-20070618-1-trunk/tests/libfddi_examplebus.c
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/libfddi_examplebus.c Sat Jun 30 00:08:14 2007
@@ -0,0 +1,54 @@
+/*
+ * This is an example fieldbus library implementation
+ */
+
+#include <stdio.h>
+#include <osadl/fddi.h>
+
+int readconfig(fddi_iface_t *iface, const char *configfile)
+{
+ //printf("%s\n", __FUNCTION__);
+ return 0;
+}
+
+int setstate(fddi_iface_t *iface, fddi_state_enum_t state)
+{
+ //printf("%s\n", __FUNCTION__);
+ return 0;
+}
+
+int cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd)
+{
+ int retval = 0;
+
+ switch (cmd) {
+
+ case CMD_START:
+ retval = -1;
+ break;
+
+ case CMD_STOP:
+ retval = -1;
+ break;
+
+ case CMD_RESET:
+ retval = -1;
+ break;
+
+ case CMD_IDENTIFY:
+ retval = -1;
+ break;
+
+ case CMD_QUITERR:
+ retval = -1;
+ break;
+
+ default:
+ retval = -1;
+ break;
+
+ }
+
+ return retval;
+}
+
Added: fddi-20070618-1-trunk/tests/test_examplebus1.c
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_examplebus1.c Sat Jun 30 00:08:14 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: fddi-20070618-1-trunk/tests/test_fddi_examplebus1.c
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus1.c Sat Jun 30 00:08:14 2007
@@ -0,0 +1,141 @@
+#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_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_setdevice(&exb0_attr, "exb0");
+
+ fddi_iface_init(&exb0_iface, &exb0_attr);
+
+ /* some things you can do with ifaces */
+ fddi_iface_readconfig(&exb0_iface, "config.xml");
+
+ 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: fddi-20070618-1-trunk/tests/test_fddi_examplebus1.sh
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus1.sh Sat Jun 30 00:08:14 2007
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+here=$(dirname $0)
+export LD_LIBRARY_PATH=${here}/.libs
+${here}/test_fddi_examplebus1
+
Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_attach_backend.c
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_attach_backend.c Sat Jun 30 00:08:14 2007
@@ -0,0 +1,28 @@
+#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;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setdevice(&exb0_attr, "exb0");
+
+ ret = fddi_iface_init(&exb0_iface, &exb0_attr);
+ if (ret)
+ return ret;
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_attach_backend.sh
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_attach_backend.sh Sat Jun 30 00:08:14 2007
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+here=$(dirname $0)
+export LD_LIBRARY_PATH=${here}/.libs
+${here}/test_fddi_examplebus_attach_backend
+
Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd Sat Jun 30 00:08:14 2007
@@ -0,0 +1,117 @@
+#! /bin/sh
+
+# test_fddi_examplebus_cmd - temporary wrapper script for .libs/test_fddi_examplebus_cmd
+# Generated by ltmain.sh - GNU libtool 1.5.22 Debian 1.5.22-4 (1.1220.2.365 2005/12/18 22:14:06)
+#
+# The test_fddi_examplebus_cmd program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='/bin/sed -e 1s/^X//'
+sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+relink_command="(cd /home/rsc/svn/osadl/software/fieldbus-framework/fddi-20070618-1-trunk/tests; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=\"/home/rsc/.python/bin:/ptx/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games\"; export PATH; gcc -Wall -Werror -Wsign-compare -Wfloat-equal -Wformat-security -g -O1 -o \$progdir/\$file test_fddi_examplebus_cmd.o ../src/.libs/libfddi.so -Wl,--rpath -Wl,/home/rsc/svn/osadl/software/fieldbus-framework/fddi-20070618-1-trunk/src/.libs -Wl,--rpath -Wl,/usr/local/lib)"
+
+# This environment variable determines our operation mode.
+if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
+ # install mode needs the following variable:
+ notinst_deplibs=' ../src/libfddi.la'
+else
+ # When we are sourced in execute mode, $file and $echo are already set.
+ if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
+ echo="echo"
+ file="$0"
+ # Make sure echo works.
+ if test "X$1" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+ elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
+ # Yippee, $echo works!
+ :
+ else
+ # Restart under the correct shell, and then maybe $echo will work.
+ exec /bin/sh "$0" --no-reexec ${1+"$@"}
+ fi
+ fi
+
+ # Find the directory that this script lives in.
+ thisdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+ test "x$thisdir" = "x$file" && thisdir=.
+
+ # Follow symbolic links until we get to the real thisdir.
+ file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'`
+ while test -n "$file"; do
+ destdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+
+ # If there was a directory component, then change thisdir.
+ if test "x$destdir" != "x$file"; then
+ case "$destdir" in
+ [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;;
+ *) thisdir="$thisdir/$destdir" ;;
+ esac
+ fi
+
+ file=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+ file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'`
+ done
+
+ # Try to get the absolute directory name.
+ absdir=`cd "$thisdir" && pwd`
+ test -n "$absdir" && thisdir="$absdir"
+
+ program=lt-'test_fddi_examplebus_cmd'
+ progdir="$thisdir/.libs"
+
+ if test ! -f "$progdir/$program" || \
+ { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \
+ test "X$file" != "X$progdir/$program"; }; then
+
+ file="$$-$program"
+
+ if test ! -d "$progdir"; then
+ mkdir "$progdir"
+ else
+ rm -f "$progdir/$file"
+ fi
+
+ # relink executable if necessary
+ if test -n "$relink_command"; then
+ if relink_command_output=`eval $relink_command 2>&1`; then :
+ else
+ echo "$relink_command_output" >&2
+ rm -f "$progdir/$file"
+ exit 1
+ fi
+ fi
+
+ mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null ||
+ { rm -f "$progdir/$program";
+ mv -f "$progdir/$file" "$progdir/$program"; }
+ rm -f "$progdir/$file"
+ fi
+
+ if test -f "$progdir/$program"; then
+ if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
+ # Run the actual program with our arguments.
+
+ exec "$progdir/$program" ${1+"$@"}
+
+ $echo "$0: cannot exec $program ${1+"$@"}"
+ exit 1
+ fi
+ else
+ # The program doesn't exist.
+ $echo "$0: error: \`$progdir/$program' does not exist" 1>&2
+ $echo "This script is just a wrapper for $program." 1>&2
+ echo "See the libtool documentation for more information." 1>&2
+ exit 1
+ fi
+fi
Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd.c
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd.c Sat Jun 30 00:08:14 2007
@@ -0,0 +1,59 @@
+#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;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setdevice(&exb0_attr, "exb0");
+
+ 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;
+ }
+
+ ret = fddi_iface_cmd(&exb0_iface, CMD_STOP);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_cmd(CMD_STOP) 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;
+ }
+
+ ret = fddi_iface_cmd(&exb0_iface, CMD_IDENTIFY);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_cmd(CMD_IDENTIFY) 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: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd.sh
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd.sh Sat Jun 30 00:08:14 2007
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+here=$(dirname $0)
+export LD_LIBRARY_PATH=${here}/.libs
+${here}/test_fddi_examplebus_readconfig
+
Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_identify.c
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_identify.c Sat Jun 30 00:08:14 2007
@@ -0,0 +1,35 @@
+#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;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setdevice(&exb0_attr, "exb0");
+
+ 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: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_identify.sh
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_identify.sh Sat Jun 30 00:08:14 2007
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+here=$(dirname $0)
+export LD_LIBRARY_PATH=${here}/.libs
+${here}/test_fddi_examplebus_cmd_identify
+
Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_quiterr.c
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_quiterr.c Sat Jun 30 00:08:14 2007
@@ -0,0 +1,35 @@
+#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;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setdevice(&exb0_attr, "exb0");
+
+ 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: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_quiterr.sh
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_quiterr.sh Sat Jun 30 00:08:14 2007
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+here=$(dirname $0)
+export LD_LIBRARY_PATH=${here}/.libs
+${here}/test_fddi_examplebus_cmd_quiterr
+
Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_reset.c
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_reset.c Sat Jun 30 00:08:14 2007
@@ -0,0 +1,35 @@
+#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;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setdevice(&exb0_attr, "exb0");
+
+ 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: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_reset.sh
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_reset.sh Sat Jun 30 00:08:14 2007
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+here=$(dirname $0)
+export LD_LIBRARY_PATH=${here}/.libs
+${here}/test_fddi_examplebus_cmd_reset
+
Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_start.c
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_start.c Sat Jun 30 00:08:14 2007
@@ -0,0 +1,35 @@
+#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;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setdevice(&exb0_attr, "exb0");
+
+ 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: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_start.sh
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_start.sh Sat Jun 30 00:08:14 2007
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+here=$(dirname $0)
+export LD_LIBRARY_PATH=${here}/.libs
+${here}/test_fddi_examplebus_cmd_start
+
Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_stop.c
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_stop.c Sat Jun 30 00:08:14 2007
@@ -0,0 +1,35 @@
+#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;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setdevice(&exb0_attr, "exb0");
+
+ 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: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_stop.sh
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_stop.sh Sat Jun 30 00:08:14 2007
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+here=$(dirname $0)
+export LD_LIBRARY_PATH=${here}/.libs
+${here}/test_fddi_examplebus_cmd_stop
+
Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_readconfig.c
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_readconfig.c Sat Jun 30 00:08:14 2007
@@ -0,0 +1,35 @@
+#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;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setdevice(&exb0_attr, "exb0");
+
+ ret = fddi_iface_init(&exb0_iface, &exb0_attr);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_init() failed\n");
+ return ret;
+ }
+
+ ret = fddi_iface_readconfig(&exb0_iface, "test_fddi_examplebus_readconfig.xml");
+ if (ret) {
+ fprintf(stderr, "fddi_iface_readconfig() failed\n");
+ return ret;
+ }
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_readconfig.sh
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_readconfig.sh Sat Jun 30 00:08:14 2007
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+here=$(dirname $0)
+export LD_LIBRARY_PATH=${here}/.libs
+${here}/test_fddi_examplebus_readconfig
+
Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate.c
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate.c Sat Jun 30 00:08:14 2007
@@ -0,0 +1,35 @@
+#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;
+
+ /* instanciate io_interface */
+ fddi_iface_attr_init(&exb0_attr);
+ fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so");
+ fddi_iface_attr_setdevice(&exb0_attr, "exb0");
+
+ ret = fddi_iface_init(&exb0_iface, &exb0_attr);
+ if (ret) {
+ fprintf(stderr, "fddi_iface_init() failed\n");
+ return ret;
+ }
+
+ ret = fddi_iface_readconfig(&exb0_iface, "test_fddi_examplebus_readconfig.xml");
+ if (ret) {
+ fprintf(stderr, "fddi_iface_readconfig() failed\n");
+ return ret;
+ }
+
+ /* destruct io_interface */
+ fddi_iface_destroy(&exb0_iface);
+
+ exit(0);
+}
+
Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate.sh
==============================================================================
--- (empty file)
+++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate.sh Sat Jun 30 00:08:14 2007
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+here=$(dirname $0)
+export LD_LIBRARY_PATH=${here}/.libs
+${here}/test_fddi_examplebus_readconfig
+
More information about the OSADL-svn-commits
mailing list