From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:41:05 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:41:05 +0200 Subject: [OSADL-svn-commits] r1 - documentation protocols src test Message-ID: <200710020941.l929f5ES018516@www.osadl.org> Author: robert Date: Thu Mar 1 11:50:39 2007 New Revision: 1 Log: initial project structure Added: documentation/ protocols/ src/ test/ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:41:08 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:41:08 +0200 Subject: [OSADL-svn-commits] r2 - documentation fddi-20070502-1 fddi-20070502-1/doc fddi-20070502-1/src fddi-20070529-1 fddi-20070529-1/doc fddi-20070529-1/src fddi-20070618-1 fddi-20070618-1/doc fddi-20070618-1/src protocols src Message-ID: <200710020941.l929f8oA018528@www.osadl.org> Author: robert Date: Mon Jun 18 19:44:22 2007 New Revision: 2 Log: added dhe's versions from the mailing list Added: fddi-20070502-1/ fddi-20070502-1/doc/ fddi-20070502-1/doc/Fieldbus-Device-Driver-Interface.pdf (contents, props changed) fddi-20070502-1/src/ fddi-20070529-1/ fddi-20070529-1/doc/ fddi-20070529-1/doc/Fieldbus-Device-Driver-Interface.odt (contents, props changed) fddi-20070529-1/src/ fddi-20070529-1/src/fddi.h fddi-20070618-1/ fddi-20070618-1/doc/ fddi-20070618-1/doc/Fieldbus-Device-Driver-Interface.odt (contents, props changed) fddi-20070618-1/src/ fddi-20070618-1/src/fddi.c fddi-20070618-1/src/fddi.h Removed: documentation/ protocols/ src/ Added: fddi-20070502-1/doc/Fieldbus-Device-Driver-Interface.pdf ============================================================================== Binary file. No diff available. Added: fddi-20070529-1/doc/Fieldbus-Device-Driver-Interface.odt ============================================================================== Binary file. No diff available. Added: fddi-20070529-1/src/fddi.h ============================================================================== --- (empty file) +++ fddi-20070529-1/src/fddi.h Mon Jun 18 19:44:22 2007 @@ -0,0 +1,392 @@ +/* fieldbus device driver interface */ + + +/* #include "lldi.h" */ +typedef void *LL_INTERFACE; + +/* 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 + +/* 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) */ +}; + +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_units *tpus; /* list of io-transport units (set after configuration) */ + + 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; + + +/* 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; +}; + +#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: the adress + */ + +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 + */ + Added: fddi-20070618-1/doc/Fieldbus-Device-Driver-Interface.odt ============================================================================== Binary file. No diff available. Added: fddi-20070618-1/src/fddi.c ============================================================================== --- (empty file) +++ fddi-20070618-1/src/fddi.c Mon Jun 18 19:44:22 2007 @@ -0,0 +1,286 @@ +#include +#include +#include +#include "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) +{ + int res = 0; + /* pseudo code, because low level interface is not ready */ + /* may be redirected trough stack */ + /* + res = iotpu->itfinst->llitf->Send(iotpu->id, iotpu->buf_write, iotpu->size); + */ + return 0; +} + +int register_callback_to_iotransport_unit(IO_TRANSPORT_UNIT iotpu, void (*callback)(IO_TRANSPORT_UNIT iotpu)) +{ + if (iotpu->num_callbacks >= MAXCALLBACKS) + return RESERR_OUT_OF_MEM; + iotpu->callback[iotpu->num_callbacks] = callback; + iotpu->num_callbacks++; + return RESOK; +} + +int enum_io_variables_of_iotransport_unit(IO_TRANSPORT_UNIT iotpu, IO_VARIABLE** iovars) +{ + *iovars = iotpu->varlist; + return iotpu->num_var; +} Added: fddi-20070618-1/src/fddi.h ============================================================================== --- (empty file) +++ fddi-20070618-1/src/fddi.h Mon Jun 18 19:44:22 2007 @@ -0,0 +1,414 @@ +/* fieldbus device driver interface */ + + +/* #include "lldi.h" */ +typedef void *LL_INTERFACE; + +/* 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 + */ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:41:12 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:41:12 +0200 Subject: [OSADL-svn-commits] r3 - fddi-trunk Message-ID: <200710020941.l929fCgp018554@www.osadl.org> Author: robert Date: Mon Jun 18 19:44:51 2007 New Revision: 3 Log: open trunk Added: fddi-trunk/ - copied from r2, /fddi-20070618-1/ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:41:16 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:41:16 +0200 Subject: [OSADL-svn-commits] r4 - fddi-20070618-1-ptx1 Message-ID: <200710020941.l929fGLZ018583@www.osadl.org> Author: robert Date: Mon Jun 18 21:43:28 2007 New Revision: 4 Log: Added: fddi-20070618-1-ptx1/ - copied from r2, /fddi-20070618-1/ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:41:19 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:41:19 +0200 Subject: [OSADL-svn-commits] r5 - in fddi-20070618-1-ptx1: . config config/autoconf config/m4 include src tests Message-ID: <200710020941.l929fJOj018614@www.osadl.org> Author: robert Date: Mon Jun 18 21:44:10 2007 New Revision: 5 Log: started autotoolization Added: fddi-20070618-1-ptx1/GNUmakefile.am fddi-20070618-1-ptx1/autogen.sh (contents, props changed) fddi-20070618-1-ptx1/config/ fddi-20070618-1-ptx1/config/GNUmakefile.am fddi-20070618-1-ptx1/config/autoconf/ fddi-20070618-1-ptx1/config/fddi.pc.in fddi-20070618-1-ptx1/config/m4/ fddi-20070618-1-ptx1/config/m4/.secret-world-domination-project fddi-20070618-1-ptx1/config/m4/acx_pthread.m4 fddi-20070618-1-ptx1/configure.ac fddi-20070618-1-ptx1/include/ fddi-20070618-1-ptx1/include/GNUmakefile.am fddi-20070618-1-ptx1/include/fddi.h fddi-20070618-1-ptx1/include/fddistuff.h fddi-20070618-1-ptx1/src/GNUmakefile.am fddi-20070618-1-ptx1/src/libfddi.c fddi-20070618-1-ptx1/tests/ fddi-20070618-1-ptx1/tests/GNUmakefile.am fddi-20070618-1-ptx1/tests/test.c Modified: fddi-20070618-1-ptx1/src/fddi.c Added: fddi-20070618-1-ptx1/GNUmakefile.am ============================================================================== --- (empty file) +++ fddi-20070618-1-ptx1/GNUmakefile.am Mon Jun 18 21:44:10 2007 @@ -0,0 +1,23 @@ +SUBDIRS = include config src tests + +EXTRA_DIST = \ + autogen.sh \ + config/m4/.secret-world-domination-project + +MAINTAINERCLEANFILES = \ + configure \ + GNUmakefile.in \ + aclocal.m4 \ + config/autoconf/compile \ + config/autoconf/config.guess \ + config/autoconf/config.sub \ + config/autoconf/depcomp \ + config/autoconf/install-sh \ + config/autoconf/ltmain.sh \ + config/autoconf/mdate-sh \ + config/autoconf/missing \ + config/autoconf/texinfo.tex \ + config/m4/libtool.m4 \ + config/m4/ltoptions.m4 \ + config/m4/ltsugar.m4 \ + config/m4/ltversion.m4 Added: fddi-20070618-1-ptx1/autogen.sh ============================================================================== --- (empty file) +++ fddi-20070618-1-ptx1/autogen.sh Mon Jun 18 21:44:10 2007 @@ -0,0 +1,48 @@ +#!/bin/bash + +# +# usage: +# +# banner +# +banner() { + echo + TG=`echo $1 | sed -e "s,/.*/,,g"` + LINE=`echo $TG |sed -e "s/./-/g"` + echo $LINE + echo $TG + echo $LINE + echo +} + + +ACLOCAL=${ACLOCAL:=aclocal} +AUTOHEADER=${AUTOHEADER:=autoheader} +AUTOMAKE=${AUTOMAKE:=automake} +AUTOCONF=${AUTOCONF:=autoconf} + +#$ACLOCAL --version | \ +# awk -vPROG="aclocal" -vVERS=1.7\ +# '{if ($1 == PROG) {gsub ("-.*","",$4); if ($4 < VERS) print PROG" < version "VERS"\nThis may result in errors\n"}}' + +#$AUTOMAKE --version | \ +# awk -vPROG="automake" -vVERS=1.7\ +# '{if ($1 == PROG) {gsub ("-.*","",$4); if ($4 < VERS) print PROG" < version "VERS"\nThis may result in errors\n"}}' + + +banner "running libtoolize" +libtoolize --force || exit + +banner "running aclocal" +$ACLOCAL -I config/m4 || exit + +banner "running autoheader" +$AUTOHEADER || exit + +banner "running automake" +$AUTOMAKE --gnu --add-missing -Wall || exit + +banner "running autoconf" +$AUTOCONF -Wall || exit + +banner "Finished" Added: fddi-20070618-1-ptx1/config/GNUmakefile.am ============================================================================== --- (empty file) +++ fddi-20070618-1-ptx1/config/GNUmakefile.am Mon Jun 18 21:44:10 2007 @@ -0,0 +1,7 @@ +EXTRA_DIST = fddi.pc.in + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = fddi.pc + +MAINTAINERCLEANFILES = \ + GNUmakefile.in Added: fddi-20070618-1-ptx1/config/fddi.pc.in ============================================================================== --- (empty file) +++ fddi-20070618-1-ptx1/config/fddi.pc.in Mon Jun 18 21:44:10 2007 @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: +Description: +Requires: @REQUIRES_LIBRN@ +Version: @VERSION@ +Libs: -L${libdir} -lfddi +#Libs.private: -lm -lpthread ...etc... +Cflags: -I${includedir} Added: fddi-20070618-1-ptx1/config/m4/.secret-world-domination-project ============================================================================== Added: fddi-20070618-1-ptx1/config/m4/acx_pthread.m4 ============================================================================== --- (empty file) +++ fddi-20070618-1-ptx1/config/m4/acx_pthread.m4 Mon Jun 18 21:44:10 2007 @@ -0,0 +1,238 @@ +dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +dnl +dnl @summary figure out how to build C programs using POSIX threads +dnl +dnl This macro figures out how to build C programs using POSIX threads. +dnl It sets the PTHREAD_LIBS output variable to the threads library and +dnl linker flags, and the PTHREAD_CFLAGS output variable to any special +dnl C compiler flags that are needed. (The user can also force certain +dnl compiler flags/libs to be tested by setting these environment +dnl variables.) +dnl +dnl Also sets PTHREAD_CC to any special C compiler that is needed for +dnl multi-threaded programs (defaults to the value of CC otherwise). +dnl (This is necessary on AIX to use the special cc_r compiler alias.) +dnl +dnl NOTE: You are assumed to not only compile your program with these +dnl flags, but also link it with them as well. e.g. you should link +dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS +dnl $LIBS +dnl +dnl If you are only building threads programs, you may wish to use +dnl these variables in your default LIBS, CFLAGS, and CC: +dnl +dnl LIBS="$PTHREAD_LIBS $LIBS" +dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +dnl CC="$PTHREAD_CC" +dnl +dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute +dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to +dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). +dnl +dnl ACTION-IF-FOUND is a list of shell commands to run if a threads +dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to +dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the +dnl default action will define HAVE_PTHREAD. +dnl +dnl Please let the authors know if this macro fails on any platform, or +dnl if you have any other suggestions or comments. This macro was based +dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with +dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros +dnl posted by Alejandro Forero Cuervo to the autoconf macro repository. +dnl We are also grateful for the helpful feedback of numerous users. +dnl +dnl @category InstalledPackages +dnl @author Steven G. Johnson +dnl @version 2005-06-15 +dnl @license GPLWithACException + +AC_DEFUN([ACX_PTHREAD], [ +AC_REQUIRE([AC_CANONICAL_HOST]) +AC_LANG_SAVE +AC_LANG_C +acx_pthread_ok=no + +# We used to check for pthread.h first, but this fails if pthread.h +# requires special compiler flags (e.g. on True64 or Sequent). +# It gets checked for in the link test anyway. + +# First of all, check if the user has set any of the PTHREAD_LIBS, +# etcetera environment variables, and if threads linking works using +# them: +if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) + AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) + AC_MSG_RESULT($acx_pthread_ok) + if test x"$acx_pthread_ok" = xno; then + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" + fi + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" +fi + +# We must check for the threads library under a number of different +# names; the ordering is very important because some systems +# (e.g. DEC) have both -lpthread and -lpthreads, where one of the +# libraries is broken (non-POSIX). + +# Create a list of thread flags to try. Items starting with a "-" are +# C compiler flags, and other items are library names, except for "none" +# which indicates that we try without any flags at all, and "pthread-config" +# which is a program returning the flags for the Pth emulation library. + +acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" + +# The ordering *is* (sometimes) important. Some notes on the +# individual items follow: + +# pthreads: AIX (must check this before -lpthread) +# none: in case threads are in libc; should be tried before -Kthread and +# other compiler flags to prevent continual compiler warnings +# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) +# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) +# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) +# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) +# -pthreads: Solaris/gcc +# -mthreads: Mingw32/gcc, Lynx/gcc +# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it +# doesn't hurt to check since this sometimes defines pthreads too; +# also defines -D_REENTRANT) +# ... -mt is also the pthreads flag for HP/aCC +# pthread: Linux, etcetera +# --thread-safe: KAI C++ +# pthread-config: use pthread-config program (for GNU Pth library) + +case "${host_cpu}-${host_os}" in + *solaris*) + + # On Solaris (at least, for some versions), libc contains stubbed + # (non-functional) versions of the pthreads routines, so link-based + # tests will erroneously succeed. (We need to link with -pthreads/-mt/ + # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather + # a function called by this macro, so we could check for that, but + # who knows whether they'll stub that too in a future libc.) So, + # we'll just look for -pthreads and -lpthread first: + + acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags" + ;; +esac + +if test x"$acx_pthread_ok" = xno; then +for flag in $acx_pthread_flags; do + + case $flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + + -*) + AC_MSG_CHECKING([whether pthreads work with $flag]) + PTHREAD_CFLAGS="$flag" + ;; + + pthread-config) + AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no) + if test x"$acx_pthread_config" = xno; then continue; fi + PTHREAD_CFLAGS="`pthread-config --cflags`" + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" + ;; + + *) + AC_MSG_CHECKING([for the pthreads library -l$flag]) + PTHREAD_LIBS="-l$flag" + ;; + esac + + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we + # need a special flag -Kthread to make this header compile.) + # We check for pthread_join because it is in -lpthread on IRIX + # while pthread_create is in libc. We check for pthread_attr_init + # due to DEC craziness with -lpthreads. We check for + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. + AC_TRY_LINK([#include ], + [pthread_t th; pthread_join(th, 0); + pthread_attr_init(0); pthread_cleanup_push(0, 0); + pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], + [acx_pthread_ok=yes]) + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + AC_MSG_RESULT($acx_pthread_ok) + if test "x$acx_pthread_ok" = xyes; then + break; + fi + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi + +# Various other checks: +if test "x$acx_pthread_ok" = xyes; then + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. + AC_MSG_CHECKING([for joinable pthread attribute]) + attr_name=unknown + for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do + AC_TRY_LINK([#include ], [int attr=$attr; return attr;], + [attr_name=$attr; break]) + done + AC_MSG_RESULT($attr_name) + if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then + AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, + [Define to necessary symbol if this constant + uses a non-standard name on your system.]) + fi + + AC_MSG_CHECKING([if more special flags are required for pthreads]) + flag=no + case "${host_cpu}-${host_os}" in + *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; + *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; + esac + AC_MSG_RESULT(${flag}) + if test "x$flag" != xno; then + PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" + fi + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + # More AIX lossage: must compile with cc_r + AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC}) +else + PTHREAD_CC="$CC" +fi + +AC_SUBST(PTHREAD_LIBS) +AC_SUBST(PTHREAD_CFLAGS) +AC_SUBST(PTHREAD_CC) + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test x"$acx_pthread_ok" = xyes; then + ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) + : +else + acx_pthread_ok=no + $2 +fi +AC_LANG_RESTORE +])dnl ACX_PTHREAD Added: fddi-20070618-1-ptx1/configure.ac ============================================================================== --- (empty file) +++ fddi-20070618-1-ptx1/configure.ac Mon Jun 18 21:44:10 2007 @@ -0,0 +1,135 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. +AC_PREREQ(2.59) + +AC_INIT([fddi], [0.0.0], [bugs at pengutronix.de]) +AC_CONFIG_HEADERS([include/fddi_config.h]) +AC_CONFIG_SRCDIR([src/fddi.c]) +AC_CONFIG_MACRO_DIR([config/m4]) +AC_CONFIG_AUX_DIR([config/autoconf]) +AC_CANONICAL_BUILD +AC_CANONICAL_HOST + +AM_MAINTAINER_MODE + +CFLAGS="${CFLAGS} -Wall" + +# +# libtool library versioning stuff +# +# Library code modified: REVISION++ +# Interfaces changed/added/removed: CURRENT++ REVISION=0 +# Interfaces added: AGE++ +# Interfaces removed: AGE=0 +LT_CURRENT=0 +LT_REVISION=0 +LT_AGE=0 +AC_SUBST(LT_CURRENT) +AC_SUBST(LT_REVISION) +AC_SUBST(LT_AGE) + + +# +# 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. +# + +## +# librn +## +# REQUIRES_LIBRN="librn >= 0.4.2" +# AC_SUBST(REQUIRES_LIBRN) +# PKG_CHECK_MODULES([librn], +# [${REQUIRES_LIBRN}], +# [], +# [AC_MSG_ERROR([*** ${REQUIRES_LIBRN} not found by pkg-config on your system])] +# ) +# AC_SUBST(librn_CFLAGS) +# AC_SUBST(librn_LIBS) + +# +# Checks for header files. +# +AC_HEADER_DIRENT +AC_HEADER_STDC +AC_HEADER_SYS_WAIT +AC_CHECK_HEADERS([ \ + arpa/inet.h \ + limits.h \ + netdb.h \ + netinet/in.h \ + stddef.h \ + stdlib.h \ + string.h \ + sys/param.h \ + sys/socket.h \ + sys/time.h \ + sys/un.h \ + unistd.h \ + utime.h \ + ]) + + +# +# Checks for typedefs, structures, and compiler characteristics. +# +AC_C_CONST +AC_C_INLINE +AC_TYPE_SIZE_T +AC_HEADER_TIME + + +# +# Checks for library functions. +# +AC_FUNC_MEMCMP +AC_TYPE_SIGNAL +AC_FUNC_STAT +AC_FUNC_UTIME_NULL +AC_CHECK_FUNCS([gethostbyaddr gethostbyname gethostname gettimeofday memset mkdir socket utime]) + + +# +# Debugging +# +AC_MSG_CHECKING([whether to enable debugging]) +AC_ARG_ENABLE(debug, + AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=yes@:>@]), + [case "$enableval" in + y | yes) CONFIG_DEBUG=yes ;; + *) CONFIG_DEBUG=no ;; + esac], + [CONFIG_DEBUG=yes]) +AC_MSG_RESULT([${CONFIG_DEBUG}]) +if test "${CONFIG_DEBUG}" = "yes"; then + CFLAGS="${CFLAGS} -Werror -Wsign-compare -Wfloat-equal -Wformat-security -g -O1" + AC_DEFINE(DEBUG, 1, [debugging]) +else + CFLAGS="${CFLAGS} -O2" +fi + + +AC_CONFIG_FILES([ + GNUmakefile + config/fddi.pc + config/GNUmakefile + include/GNUmakefile + src/GNUmakefile + tests/GNUmakefile + ]) +AC_OUTPUT + Added: fddi-20070618-1-ptx1/include/GNUmakefile.am ============================================================================== --- (empty file) +++ fddi-20070618-1-ptx1/include/GNUmakefile.am Mon Jun 18 21:44:10 2007 @@ -0,0 +1,9 @@ +noinst_HEADERS = \ + fddistuff.h + +nobase_include_HEADERS = \ + fddi.h + +MAINTAINERCLEANFILES = \ + fddi_config.h.in \ + GNUmakefile.in Added: fddi-20070618-1-ptx1/include/fddi.h ============================================================================== --- (empty file) +++ fddi-20070618-1-ptx1/include/fddi.h Mon Jun 18 21:44:10 2007 @@ -0,0 +1,5 @@ +#ifndef FDDI_H +#define FDDI_H + + +#endif Added: fddi-20070618-1-ptx1/include/fddistuff.h ============================================================================== --- (empty file) +++ fddi-20070618-1-ptx1/include/fddistuff.h Mon Jun 18 21:44:10 2007 @@ -0,0 +1,5 @@ +#ifndef FDDI_H +#define FDDI_H + + +#endif Added: fddi-20070618-1-ptx1/src/GNUmakefile.am ============================================================================== --- (empty file) +++ fddi-20070618-1-ptx1/src/GNUmakefile.am Mon Jun 18 21:44:10 2007 @@ -0,0 +1,20 @@ +lib_LTLIBRARIES = libfddi.la + +bin_PROGRAMS = fddi + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include + +libfddi_la_SOURCES = \ + libfddi.c + +fddi_la_LDFLAGS = \ + -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) +# -no-undefined # win32_dll stuff only + +fddi_SOURCES = \ + fddi.c + +MAINTAINERCLEANFILES = \ + GNUmakefile.in Modified: fddi-20070618-1-ptx1/src/fddi.c ============================================================================== --- fddi-20070618-1-ptx1/src/fddi.c (original) +++ fddi-20070618-1-ptx1/src/fddi.c Mon Jun 18 21:44:10 2007 @@ -1,286 +1,6 @@ -#include -#include -#include -#include "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) -{ - 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; -} +/* This is a sample main program */ + +int main(void) +{ + return 0; +} Added: fddi-20070618-1-ptx1/src/libfddi.c ============================================================================== --- (empty file) +++ fddi-20070618-1-ptx1/src/libfddi.c Mon Jun 18 21:44:10 2007 @@ -0,0 +1,6 @@ + +int template(void) +{ + return 0; +} + Added: fddi-20070618-1-ptx1/tests/GNUmakefile.am ============================================================================== --- (empty file) +++ fddi-20070618-1-ptx1/tests/GNUmakefile.am Mon Jun 18 21:44:10 2007 @@ -0,0 +1,13 @@ +TESTS = test + +noinst_PROGRAMS = test + +test_SOURCES = test.c +test_LDADD = $(top_builddir)/src/libfddi.la + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include + +MAINTAINERCLEANFILES = \ + GNUmakefile.in Added: fddi-20070618-1-ptx1/tests/test.c ============================================================================== --- (empty file) +++ fddi-20070618-1-ptx1/tests/test.c Mon Jun 18 21:44:10 2007 @@ -0,0 +1,6 @@ +#include + +int main(void) +{ + return 0; +} From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:41:24 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:41:24 +0200 Subject: [OSADL-svn-commits] r6 - fddi-20070618-1-ptx1/include Message-ID: <200710020941.l929fOdJ018651@www.osadl.org> Author: robert Date: Mon Jun 18 21:45:06 2007 New Revision: 6 Log: removed template Removed: fddi-20070618-1-ptx1/include/fddi.h From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:41:27 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:41:27 +0200 Subject: [OSADL-svn-commits] r7 - in fddi-20070618-1-ptx1: include/osadl src Message-ID: <200710020941.l929fRgh018676@www.osadl.org> Author: robert Date: Mon Jun 18 21:46:08 2007 New Revision: 7 Log: relocated files Added: fddi-20070618-1-ptx1/include/osadl/ fddi-20070618-1-ptx1/include/osadl/fddi.h - copied unchanged from r4, /fddi-20070618-1-ptx1/src/fddi.h Removed: fddi-20070618-1-ptx1/src/fddi.h From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:41:34 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:41:34 +0200 Subject: [OSADL-svn-commits] r8 - fddi-20070618-1-ptx1/include Message-ID: <200710020941.l929fYAj018726@www.osadl.org> Author: robert Date: Mon Jun 18 21:47:55 2007 New Revision: 8 Log: added fddi.h to makefile Modified: fddi-20070618-1-ptx1/include/GNUmakefile.am Modified: fddi-20070618-1-ptx1/include/GNUmakefile.am ============================================================================== --- fddi-20070618-1-ptx1/include/GNUmakefile.am (original) +++ fddi-20070618-1-ptx1/include/GNUmakefile.am Mon Jun 18 21:47:55 2007 @@ -2,7 +2,7 @@ fddistuff.h nobase_include_HEADERS = \ - fddi.h + osadl/fddi.h MAINTAINERCLEANFILES = \ fddi_config.h.in \ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:41:37 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:41:37 +0200 Subject: [OSADL-svn-commits] r9 - fddi-20070618-1-ptx1/src Message-ID: <200710020941.l929fbgb018752@www.osadl.org> Author: robert Date: Mon Jun 18 21:48:17 2007 New Revision: 9 Log: re-added correct version of fddi.c Modified: fddi-20070618-1-ptx1/src/fddi.c Modified: fddi-20070618-1-ptx1/src/fddi.c ============================================================================== --- fddi-20070618-1-ptx1/src/fddi.c (original) +++ fddi-20070618-1-ptx1/src/fddi.c Mon Jun 18 21:48:17 2007 @@ -1,6 +1,286 @@ -/* This is a sample main program */ - -int main(void) -{ - return 0; -} +#include +#include +#include +#include "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) +{ + 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; +} From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:41:40 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:41:40 +0200 Subject: [OSADL-svn-commits] r10 - in fddi-20070618-1-ptx1: src tests Message-ID: <200710020941.l929fdJQ018775@www.osadl.org> Author: robert Date: Mon Jun 18 21:49:11 2007 New Revision: 10 Log: relocated Added: fddi-20070618-1-ptx1/tests/test_hess_1.c - copied unchanged from r9, /fddi-20070618-1-ptx1/src/fddi.c Removed: fddi-20070618-1-ptx1/src/fddi.c From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:41:42 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:41:42 +0200 Subject: [OSADL-svn-commits] r11 - fddi-20070618-1-ptx1/tests Message-ID: <200710020941.l929fgdT018800@www.osadl.org> Author: robert Date: Mon Jun 18 22:07:32 2007 New Revision: 11 Log: * fixed header files * disable unused variable * added main Modified: fddi-20070618-1-ptx1/tests/test_hess_1.c Modified: fddi-20070618-1-ptx1/tests/test_hess_1.c ============================================================================== --- fddi-20070618-1-ptx1/tests/test_hess_1.c (original) +++ fddi-20070618-1-ptx1/tests/test_hess_1.c Mon Jun 18 22:07:32 2007 @@ -1,7 +1,9 @@ -#include #include +#include #include -#include "fddi.h" +#include + +#include #define MAX_IO_INTERFACES 16 #define MAX_IO_INTERFACE_INSTS 64 @@ -261,7 +263,7 @@ int send_iotransport_unit(IO_TRANSPORT_UNIT iotpu) { - int res = 0; + // FIXME int res = 0; /* pseudo code, because low level interface is not ready */ /* may be redirected trough stack */ /* @@ -284,3 +286,11 @@ *iovars = iotpu->varlist; return iotpu->num_var; } + +int main(void) +{ + printf("running test\n"); + return 0; +} + + From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:41:45 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:41:45 +0200 Subject: [OSADL-svn-commits] r12 - fddi-20070618-1-ptx1/tests Message-ID: <200710020941.l929fj4K018826@www.osadl.org> Author: robert Date: Mon Jun 18 22:08:03 2007 New Revision: 12 Log: fix makefile Modified: fddi-20070618-1-ptx1/tests/GNUmakefile.am Modified: fddi-20070618-1-ptx1/tests/GNUmakefile.am ============================================================================== --- fddi-20070618-1-ptx1/tests/GNUmakefile.am (original) +++ fddi-20070618-1-ptx1/tests/GNUmakefile.am Mon Jun 18 22:08:03 2007 @@ -1,9 +1,11 @@ -TESTS = test +TESTS = \ + test_hess_1 -noinst_PROGRAMS = test +noinst_PROGRAMS = \ + test_hess_1 -test_SOURCES = test.c -test_LDADD = $(top_builddir)/src/libfddi.la +test_hess_1_SOURCES = test_hess_1.c +#test_LDADD = $(top_builddir)/src/libfddi.la AM_CPPFLAGS = \ -I$(top_srcdir)/include \ @@ -11,3 +13,4 @@ MAINTAINERCLEANFILES = \ GNUmakefile.in + From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:41:48 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:41:48 +0200 Subject: [OSADL-svn-commits] r13 - fddi-20070618-1-ptx1 Message-ID: <200710020941.l929fm6I018849@www.osadl.org> Author: robert Date: Mon Jun 18 22:08:27 2007 New Revision: 13 Log: revision 0.0.1 Modified: fddi-20070618-1-ptx1/configure.ac Modified: fddi-20070618-1-ptx1/configure.ac ============================================================================== --- fddi-20070618-1-ptx1/configure.ac (original) +++ fddi-20070618-1-ptx1/configure.ac Mon Jun 18 22:08:27 2007 @@ -2,9 +2,9 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT([fddi], [0.0.0], [bugs at pengutronix.de]) +AC_INIT([fddi], [0.0.1], [bugs at pengutronix.de]) AC_CONFIG_HEADERS([include/fddi_config.h]) -AC_CONFIG_SRCDIR([src/fddi.c]) +AC_CONFIG_SRCDIR([src/libfddi.c]) AC_CONFIG_MACRO_DIR([config/m4]) AC_CONFIG_AUX_DIR([config/autoconf]) AC_CANONICAL_BUILD From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:41:51 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:41:51 +0200 Subject: [OSADL-svn-commits] r14 - fddi-20070618-1-ptx1/include/osadl Message-ID: <200710020941.l929fpsi018875@www.osadl.org> Author: robert Date: Mon Jun 18 22:09:09 2007 New Revision: 14 Log: * declare types before they are being used * added header file protection Modified: fddi-20070618-1-ptx1/include/osadl/fddi.h Modified: fddi-20070618-1-ptx1/include/osadl/fddi.h ============================================================================== --- fddi-20070618-1-ptx1/include/osadl/fddi.h (original) +++ fddi-20070618-1-ptx1/include/osadl/fddi.h Mon Jun 18 22:09:09 2007 @@ -1,8 +1,14 @@ +#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 @@ -412,3 +418,5 @@ * * result: Because this function can never fail, the number of io-variables is returned */ +#endif + From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:41:54 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:41:54 +0200 Subject: [OSADL-svn-commits] r15 - fddi-20070618-1-ptx1/src Message-ID: <200710020941.l929fsae018903@www.osadl.org> Author: robert Date: Mon Jun 18 22:09:22 2007 New Revision: 15 Log: fix makefile Modified: fddi-20070618-1-ptx1/src/GNUmakefile.am Modified: fddi-20070618-1-ptx1/src/GNUmakefile.am ============================================================================== --- fddi-20070618-1-ptx1/src/GNUmakefile.am (original) +++ fddi-20070618-1-ptx1/src/GNUmakefile.am Mon Jun 18 22:09:22 2007 @@ -1,6 +1,6 @@ lib_LTLIBRARIES = libfddi.la -bin_PROGRAMS = fddi +#bin_PROGRAMS = fddi AM_CPPFLAGS = \ -I$(top_srcdir)/include \ @@ -9,12 +9,12 @@ libfddi_la_SOURCES = \ libfddi.c -fddi_la_LDFLAGS = \ - -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) +#fddi_la_LDFLAGS = \ +# -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) # -no-undefined # win32_dll stuff only -fddi_SOURCES = \ - fddi.c +#fddi_SOURCES = \ +# fddi.c MAINTAINERCLEANFILES = \ GNUmakefile.in From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:41:57 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:41:57 +0200 Subject: [OSADL-svn-commits] r16 - fddi-20070618-1-ptx1/tests Message-ID: <200710020941.l929fvmb018926@www.osadl.org> Author: robert Date: Mon Jun 18 22:09:45 2007 New Revision: 16 Log: remove obsolete file Removed: fddi-20070618-1-ptx1/tests/test.c From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:42:00 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:42:00 +0200 Subject: [OSADL-svn-commits] r17 - in fddi-20070618-1-ptx1: src tests Message-ID: <200710020942.l929g05G018946@www.osadl.org> Author: robert Date: Mon Jun 18 22:14:05 2007 New Revision: 17 Log: moved library code to where it belongs Modified: fddi-20070618-1-ptx1/src/libfddi.c fddi-20070618-1-ptx1/tests/test_hess_1.c Modified: fddi-20070618-1-ptx1/src/libfddi.c ============================================================================== --- fddi-20070618-1-ptx1/src/libfddi.c (original) +++ fddi-20070618-1-ptx1/src/libfddi.c Mon Jun 18 22:14:05 2007 @@ -1,6 +1,289 @@ - -int template(void) -{ - return 0; -} - +#include +#include +#include +#include + +#include + +#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-ptx1/tests/test_hess_1.c ============================================================================== --- fddi-20070618-1-ptx1/tests/test_hess_1.c (original) +++ fddi-20070618-1-ptx1/tests/test_hess_1.c Mon Jun 18 22:14:05 2007 @@ -1,292 +1,7 @@ -#include #include -#include -#include #include -#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; -} - int main(void) { printf("running test\n"); From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:42:03 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:42:03 +0200 Subject: [OSADL-svn-commits] r18 - fddi-20070618-1-trunk Message-ID: <200710020942.l929g3Ex018979@www.osadl.org> Author: robert Date: Tue Jun 19 22:27:16 2007 New Revision: 18 Log: opened trunk Added: fddi-20070618-1-trunk/ - copied from r17, /fddi-20070618-1-ptx1/ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:42:10 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:42:10 +0200 Subject: [OSADL-svn-commits] r19 - in fddi-20070618-1-trunk: . include/osadl libltdl src tests Message-ID: <200710020942.l929gAmI019012@www.osadl.org> 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 -#include -#include -#include - -#include - -#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 +#include +#include +#include +#include +#include + +#include + +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 +#include +#include +#include + +#include + +#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 @@ + + + + + + + Examplebus Test Setup + + + + IPC Controller Box + + + + + master + + + + + + Analog Input 1 + uint32_t + 0 + + + + + + + + + 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 +#include +#include +#include +#include +#include +#include + +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 +#include + +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 +#include + +#include + +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 +#include +#include + +#include + +/* + * 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 +#include +#include + +#include + +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 +#include + +#include + +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 +#include + +#include + +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 +#include + +#include + +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 +#include + +#include + +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 +#include + +#include + +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 +#include + +#include + +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 +#include + +#include + +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 +#include + +#include + +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 + From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:42:28 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:42:28 +0200 Subject: [OSADL-svn-commits] r20 - fddi-20070618-1-trunk/tests Message-ID: <200710020942.l929gS0C019122@www.osadl.org> Author: robert Date: Sat Jun 30 00:16:34 2007 New Revision: 20 Log: make tests work for now Modified: fddi-20070618-1-trunk/tests/libfddi_examplebus.c Modified: fddi-20070618-1-trunk/tests/libfddi_examplebus.c ============================================================================== --- fddi-20070618-1-trunk/tests/libfddi_examplebus.c (original) +++ fddi-20070618-1-trunk/tests/libfddi_examplebus.c Sat Jun 30 00:16:34 2007 @@ -24,27 +24,27 @@ switch (cmd) { case CMD_START: - retval = -1; + retval = 0; break; case CMD_STOP: - retval = -1; + retval = 0; break; case CMD_RESET: - retval = -1; + retval = 0; break; case CMD_IDENTIFY: - retval = -1; + retval = 0; break; case CMD_QUITERR: - retval = -1; + retval = 0; break; default: - retval = -1; + retval = 0; break; } From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:42:33 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:42:33 +0200 Subject: [OSADL-svn-commits] r21 - in fddi-20070618-1-trunk: . libltdl Message-ID: <200710020942.l929gXBI019147@www.osadl.org> Author: robert Date: Sat Jun 30 00:17:25 2007 New Revision: 21 Log: Removed: fddi-20070618-1-trunk/libltdl/ Modified: fddi-20070618-1-trunk/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:17:25 2007 @@ -20,4 +20,5 @@ config/m4/libtool.m4 \ config/m4/ltoptions.m4 \ config/m4/ltsugar.m4 \ - config/m4/ltversion.m4 + config/m4/ltversion.m4 \ + libltdl From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:42:36 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:42:36 +0200 Subject: [OSADL-svn-commits] r22 - fddi-20070618-1-trunk/tests Message-ID: <200710020942.l929gaEv019168@www.osadl.org> Author: robert Date: Sat Jun 30 01:45:32 2007 New Revision: 22 Log: add sh scripts to EXTRA_DIST Modified: fddi-20070618-1-trunk/tests/GNUmakefile.am 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 01:45:32 2007 @@ -112,6 +112,19 @@ # -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) # -no-undefined # win32_dll stuff only +EXTRA_DIST = \ + examplebus.h \ + test_fddi_examplebus1.sh \ + test_fddi_examplebus_attach_backend.sh \ + test_fddi_examplebus_cmd.sh \ + test_fddi_examplebus_cmd_identify.sh \ + test_fddi_examplebus_cmd_quiterr.sh \ + test_fddi_examplebus_cmd_reset.sh \ + test_fddi_examplebus_cmd_start.sh \ + test_fddi_examplebus_cmd_stop.sh \ + test_fddi_examplebus_readconfig.sh \ + test_fddi_examplebus_setstate.sh + MAINTAINERCLEANFILES = \ GNUmakefile.in From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:42:47 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:42:47 +0200 Subject: [OSADL-svn-commits] r23 - fddi-20070618-1-trunk Message-ID: <200710020942.l929glLe019221@www.osadl.org> Author: robert Date: Sat Jun 30 01:46:04 2007 New Revision: 23 Log: fix maintainer-clean cycle Modified: fddi-20070618-1-trunk/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 01:46:04 2007 @@ -1,8 +1,26 @@ -SUBDIRS = libltdl include config src tests + +DIST_SUBDIRS = include config src tests +SUBDIRS = $(LIBLTDL_DIR) $(DIST_SUBDIRS) EXTRA_DIST = \ autogen.sh \ - config/m4/.secret-world-domination-project + config/m4/.secret-world-domination-project \ + libltdl/COPYING.LIB \ + libltdl/Makefile.am \ + libltdl/Makefile.in \ + libltdl/README \ + libltdl/acinclude.m4 \ + libltdl/aclocal.m4 \ + libltdl/config-h.in \ + libltdl/config.guess \ + libltdl/config.sub \ + libltdl/configure \ + libltdl/configure.ac \ + libltdl/install-sh \ + libltdl/ltdl.c \ + libltdl/ltdl.h \ + libltdl/ltmain.sh \ + libltdl/missing MAINTAINERCLEANFILES = \ configure \ @@ -20,5 +38,14 @@ config/m4/libtool.m4 \ config/m4/ltoptions.m4 \ config/m4/ltsugar.m4 \ - config/m4/ltversion.m4 \ - libltdl + config/m4/ltversion.m4 + +maintainer-clean-local: + -rm -fr libltdl + +install-data-hook: + cd libltdl && $(MAKE) local-install-files + +uninstall-local: + -rm -rf $(DESTDIR)$(pkgdatadir)/libltdl + From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:42:52 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:42:52 +0200 Subject: [OSADL-svn-commits] r24 - fddi-20070618-1-trunk/tests Message-ID: <200710020942.l929gqO0019234@www.osadl.org> Author: robert Date: Sat Jun 30 02:02:14 2007 New Revision: 24 Log: distcheck almost works Removed: fddi-20070618-1-trunk/tests/test_fddi_examplebus1.sh fddi-20070618-1-trunk/tests/test_fddi_examplebus_attach_backend.sh fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd.sh fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_identify.sh fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_quiterr.sh fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_reset.sh fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_start.sh fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_stop.sh fddi-20070618-1-trunk/tests/test_fddi_examplebus_readconfig.sh fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate.sh Modified: fddi-20070618-1-trunk/tests/GNUmakefile.am 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 02:02:14 2007 @@ -1,14 +1,17 @@ TESTS = \ 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 + 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 + +TESTS_ENVIRONMENT = \ + LD_LIBRARY_PATH=$(top_builddir)/tests/.libs noinst_PROGRAMS = \ test_examplebus1 \ @@ -113,17 +116,7 @@ # -no-undefined # win32_dll stuff only EXTRA_DIST = \ - examplebus.h \ - test_fddi_examplebus1.sh \ - test_fddi_examplebus_attach_backend.sh \ - test_fddi_examplebus_cmd.sh \ - test_fddi_examplebus_cmd_identify.sh \ - test_fddi_examplebus_cmd_quiterr.sh \ - test_fddi_examplebus_cmd_reset.sh \ - test_fddi_examplebus_cmd_start.sh \ - test_fddi_examplebus_cmd_stop.sh \ - test_fddi_examplebus_readconfig.sh \ - test_fddi_examplebus_setstate.sh + examplebus.h MAINTAINERCLEANFILES = \ GNUmakefile.in From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:43:02 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:43:02 +0200 Subject: [OSADL-svn-commits] r25 - fddi-20070618-1-trunk Message-ID: <200710020943.l929h20O019258@www.osadl.org> Author: robert Date: Sat Jun 30 11:05:07 2007 New Revision: 25 Log: added some misc files Added: fddi-20070618-1-trunk/AUTHORS fddi-20070618-1-trunk/COPYING fddi-20070618-1-trunk/ChangeLog fddi-20070618-1-trunk/README fddi-20070618-1-trunk/TODO Added: fddi-20070618-1-trunk/AUTHORS ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/AUTHORS Sat Jun 30 11:05:07 2007 @@ -0,0 +1,18 @@ +N: Dieter Hess +E: d.hess AT 3s-software.com +W: http://www.3s-software.com +D: Maintainer +S: 3S-Smart Software Solutions GmbH +S: Memminger Str.151 +S: 87439 Kempten +S: Germany + +N: Robert Schwebel +E: r.schwebel AT pengutronix.de +W: http://www.pengutronix.de +D: Maintainer +S: Pengutronix e.K. +S: Hannoversche Strasse 2 +S: 31134 Hildesheim +S: Germany + Added: fddi-20070618-1-trunk/COPYING ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/COPYING Sat Jun 30 11:05:07 2007 @@ -0,0 +1,31 @@ +LICENCING INFORMATION +--------------------- + +libfddi is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License version 2 as published by +the Free Software Foundation + +libfddi is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License along +with libfddi; if not, write to the Free Software Foundation, Inc., 59 +Temple Place, Suite 330, Boston, MA 02111-1307 USA. + +LINK EXCEPTION +-------------- + +For all source files required to build the libfddi library, which are +referenced by the term 'these files' in the following section. As a +special exception, if other files instantiate templates or use macros or +inline functions from these files, or you compile these files and link +them with other works to produce a work based on these files, these +files do not by themselves cause the resulting work to be covered by the +GNU General Public License. However the source code for these files must +still be made available in accordance with section (3) of the GNU +General Public License. This exception DOES NOT invalidate any other +reasons why a work based on these files might be covered by the GNU +General Public License. + Added: fddi-20070618-1-trunk/ChangeLog ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/ChangeLog Sat Jun 30 11:05:07 2007 @@ -0,0 +1,17 @@ +2007-06-30 Robert Schwebel + + * tests: added first bunch of unit tests + * libexamplebus: added example fieldbus library + * libfddi_examplebus: added fddi wrapper library + * libfddi: implement lt_dlopen loader for backends + * release: released 20070618-1-ptx2 (svn only) + +2007-06-18 Robert Schwebel + + * design: model fddi components as POSIX like objects + * release: released 20070618-1-ptx1 (svn only) + +2007-06-18 Dieter Hess + + * design: initial proposal for an API + Added: fddi-20070618-1-trunk/README ============================================================================== Added: fddi-20070618-1-trunk/TODO ============================================================================== From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:43:06 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:43:06 +0200 Subject: [OSADL-svn-commits] r26 - fddi-20070618-1-trunk/tests Message-ID: <200710020943.l929h60k019292@www.osadl.org> Author: robert Date: Sat Jun 30 15:31:32 2007 New Revision: 26 Log: removed unused files Removed: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd.c From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:43:09 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:43:09 +0200 Subject: [OSADL-svn-commits] r27 - fddi-20070618-1-trunk/tests Message-ID: <200710020943.l929h9h9019314@www.osadl.org> Author: robert Date: Sat Jun 30 15:50:24 2007 New Revision: 27 Log: added tests for setstate Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_configerror.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_missing.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_operation_error.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_operational.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_preoperational.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_unconfigured.c Removed: fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate.c Modified: fddi-20070618-1-trunk/tests/GNUmakefile.am fddi-20070618-1-trunk/tests/libfddi_examplebus.c 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 15:50:24 2007 @@ -8,7 +8,12 @@ test_fddi_examplebus_cmd_quiterr \ test_fddi_examplebus_cmd_identify \ test_fddi_examplebus_cmd_reset \ - test_fddi_examplebus_setstate + test_fddi_examplebus_setstate_configerror \ + test_fddi_examplebus_setstate_missing \ + test_fddi_examplebus_setstate_operational \ + test_fddi_examplebus_setstate_operation_error \ + test_fddi_examplebus_setstate_preoperational \ + test_fddi_examplebus_setstate_unconfigured TESTS_ENVIRONMENT = \ LD_LIBRARY_PATH=$(top_builddir)/tests/.libs @@ -23,7 +28,12 @@ test_fddi_examplebus_cmd_quiterr \ test_fddi_examplebus_cmd_identify \ test_fddi_examplebus_cmd_reset \ - test_fddi_examplebus_setstate + test_fddi_examplebus_setstate_configerror \ + test_fddi_examplebus_setstate_missing \ + test_fddi_examplebus_setstate_operational \ + test_fddi_examplebus_setstate_operation_error \ + test_fddi_examplebus_setstate_preoperational \ + test_fddi_examplebus_setstate_unconfigured lib_LTLIBRARIES = \ libexamplebus.la \ @@ -105,10 +115,40 @@ 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_configerror_SOURCES = \ + test_fddi_examplebus_setstate_configerror.c -test_fddi_examplebus_setstate_LDADD = \ +test_fddi_examplebus_setstate_configerror_LDADD = \ + $(top_builddir)/src/libfddi.la + +test_fddi_examplebus_setstate_missing_SOURCES = \ + test_fddi_examplebus_setstate_missing.c + +test_fddi_examplebus_setstate_missing_LDADD = \ + $(top_builddir)/src/libfddi.la + +test_fddi_examplebus_setstate_operational_SOURCES = \ + test_fddi_examplebus_setstate_operational.c + +test_fddi_examplebus_setstate_operational_LDADD = \ + $(top_builddir)/src/libfddi.la + +test_fddi_examplebus_setstate_operation_error_SOURCES = \ + test_fddi_examplebus_setstate_operation_error.c + +test_fddi_examplebus_setstate_operation_error_LDADD = \ + $(top_builddir)/src/libfddi.la + +test_fddi_examplebus_setstate_preoperational_SOURCES = \ + test_fddi_examplebus_setstate_preoperational.c + +test_fddi_examplebus_setstate_preoperational_LDADD = \ + $(top_builddir)/src/libfddi.la + +test_fddi_examplebus_setstate_unconfigured_SOURCES = \ + test_fddi_examplebus_setstate_unconfigured.c + +test_fddi_examplebus_setstate_unconfigured_LDADD = \ $(top_builddir)/src/libfddi.la #fddi_la_LDFLAGS = \ Modified: fddi-20070618-1-trunk/tests/libfddi_examplebus.c ============================================================================== --- fddi-20070618-1-trunk/tests/libfddi_examplebus.c (original) +++ fddi-20070618-1-trunk/tests/libfddi_examplebus.c Sat Jun 30 15:50:24 2007 @@ -7,46 +7,43 @@ 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 retval = -1; + + switch(state) { + case STATE_UNCONFIGURED: + case STATE_MISSING: + case STATE_CONFIG_ERROR: + case STATE_PREOPERATIONAL: + case STATE_OPERATIONAL: + case STATE_OPERATION_ERROR: + retval = 0; + break; + default: + break; + } + + return retval; } int cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd) { - int retval = 0; + int retval = -1; switch (cmd) { - case CMD_START: - retval = 0; - break; - case CMD_STOP: - retval = 0; - break; - case CMD_RESET: - retval = 0; - break; - case CMD_IDENTIFY: - retval = 0; - break; - case CMD_QUITERR: retval = 0; break; - default: - retval = 0; break; - } return retval; Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_configerror.c ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_configerror.c Sat Jun 30 15:50:24 2007 @@ -0,0 +1,35 @@ +#include +#include + +#include + +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_setstate(&exb0_iface, STATE_CONFIG_ERROR); + if (ret) { + fprintf(stderr, "fddi_iface_setstate(STATE_CONFIG_ERROR) failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_missing.c ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_missing.c Sat Jun 30 15:50:24 2007 @@ -0,0 +1,35 @@ +#include +#include + +#include + +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_setstate(&exb0_iface, STATE_MISSING); + if (ret) { + fprintf(stderr, "fddi_iface_setstate(STATE_MISSING) failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_operation_error.c ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_operation_error.c Sat Jun 30 15:50:24 2007 @@ -0,0 +1,35 @@ +#include +#include + +#include + +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_setstate(&exb0_iface, STATE_OPERATION_ERROR); + if (ret) { + fprintf(stderr, "fddi_iface_setstate(STATE_OPERATION_ERROR) failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_operational.c ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_operational.c Sat Jun 30 15:50:24 2007 @@ -0,0 +1,35 @@ +#include +#include + +#include + +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_setstate(&exb0_iface, STATE_OPERATIONAL); + if (ret) { + fprintf(stderr, "fddi_iface_setstate(STATE_OPERATIONAL) failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_preoperational.c ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_preoperational.c Sat Jun 30 15:50:24 2007 @@ -0,0 +1,35 @@ +#include +#include + +#include + +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_setstate(&exb0_iface, STATE_PREOPERATIONAL); + if (ret) { + fprintf(stderr, "fddi_iface_setstate(STATE_PREOPERATIONAL) failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_unconfigured.c ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_unconfigured.c Sat Jun 30 15:50:24 2007 @@ -0,0 +1,35 @@ +#include +#include + +#include + +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_setstate(&exb0_iface, STATE_UNCONFIGURED); + if (ret) { + fprintf(stderr, "fddi_iface_setstate(STATE_UNCONFIGURED) failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:43:15 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:43:15 +0200 Subject: [OSADL-svn-commits] r28 - fddi-20070618-1-trunk Message-ID: <200710020943.l929hFA2019344@www.osadl.org> Author: robert Date: Sat Jun 30 15:50:57 2007 New Revision: 28 Log: Modified: fddi-20070618-1-trunk/ChangeLog Modified: fddi-20070618-1-trunk/ChangeLog ============================================================================== --- fddi-20070618-1-trunk/ChangeLog (original) +++ fddi-20070618-1-trunk/ChangeLog Sat Jun 30 15:50:57 2007 @@ -1,5 +1,6 @@ 2007-06-30 Robert Schwebel + * tests: added tests for setstate * tests: added first bunch of unit tests * libexamplebus: added example fieldbus library * libfddi_examplebus: added fddi wrapper library From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:43:18 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:43:18 +0200 Subject: [OSADL-svn-commits] r29 - fddi-20070618-1-trunk/tests Message-ID: <200710020943.l929hIBA019357@www.osadl.org> Author: robert Date: Sat Jun 30 23:19:09 2007 New Revision: 29 Log: add test for versionstring Added: fddi-20070618-1-trunk/tests/test_fddi_versionstr.c Modified: fddi-20070618-1-trunk/tests/GNUmakefile.am 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 23:19:09 2007 @@ -2,6 +2,7 @@ test_examplebus1 \ test_fddi_examplebus1 \ test_fddi_examplebus_attach_backend \ + test_fddi_versionstr \ test_fddi_examplebus_readconfig \ test_fddi_examplebus_cmd_start \ test_fddi_examplebus_cmd_stop \ @@ -22,6 +23,7 @@ test_examplebus1 \ test_fddi_examplebus1 \ test_fddi_examplebus_attach_backend \ + test_fddi_versionstr \ test_fddi_examplebus_readconfig \ test_fddi_examplebus_cmd_start \ test_fddi_examplebus_cmd_stop \ @@ -79,6 +81,12 @@ test_fddi_examplebus_attach_backend_LDADD = \ $(top_builddir)/src/libfddi.la +test_fddi_versionstr_SOURCES = \ + test_fddi_versionstr.c + +test_fddi_versionstr_LDADD = \ + $(top_builddir)/src/libfddi.la + test_fddi_examplebus_readconfig_SOURCES = \ test_fddi_examplebus_readconfig.c Added: fddi-20070618-1-trunk/tests/test_fddi_versionstr.c ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/tests/test_fddi_versionstr.c Sat Jun 30 23:19:09 2007 @@ -0,0 +1,32 @@ +#include +#include +#include + +#include + +int main(void) +{ + fddi_iface_attr_t exb0_attr; + fddi_iface_t exb0_iface; + + int ret; + const char *version; + + /* 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; + + fddi_iface_getversionstr(&exb0_iface, &version); + printf("fddi version: %s\n", version); + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:43:25 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:43:25 +0200 Subject: [OSADL-svn-commits] r30 - fddi-20070618-1-trunk Message-ID: <200710020943.l929hPUH019390@www.osadl.org> Author: robert Date: Sat Jun 30 23:19:30 2007 New Revision: 30 Log: create fddi_config.h Modified: fddi-20070618-1-trunk/configure.ac Modified: fddi-20070618-1-trunk/configure.ac ============================================================================== --- fddi-20070618-1-trunk/configure.ac (original) +++ fddi-20070618-1-trunk/configure.ac Sat Jun 30 23:19:30 2007 @@ -45,6 +45,7 @@ AC_PROG_CC AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2]) +AC_CONFIG_HEADERS # # Checks for libraries. From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:43:28 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:43:28 +0200 Subject: [OSADL-svn-commits] r31 - in fddi-20070618-1-trunk: include/osadl src Message-ID: <200710020943.l929hSip019403@www.osadl.org> Author: robert Date: Sat Jun 30 23:20:34 2007 New Revision: 31 Log: add getversionstr; let unimplemented functions return -1 Modified: fddi-20070618-1-trunk/include/osadl/fddi.h fddi-20070618-1-trunk/src/libfddi.c 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 23:20:34 2007 @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + #ifndef OSADL_FDDI_H #define OSADL_FDDI_H @@ -80,8 +101,7 @@ struct fddi_iface { - char *name; /* FIXME: add access functions */ - unsigned long version; /* FIXME: auto generate from configure.ac */ + char *name; fddi_state_enum_t state; fddi_device_t *devlist_head; fddi_tpu_t *tpulist_head; @@ -102,11 +122,15 @@ 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_getname(fddi_iface_t *iface, char *name, size_t len); +extern int fddi_iface_setname(fddi_iface_t *iface, char *name); extern int fddi_iface_getnodev(fddi_iface_t *iface); extern int fddi_iface_getnotpus(fddi_iface_t *iface); extern int fddi_iface_getnopvs(fddi_iface_t *iface); extern int fddi_iface_getdevlist(fddi_iface_t *iface, fddi_device_t **dev); extern int fddi_iface_gettpulist(fddi_iface_t *iface, fddi_tpu_t **tpu); +extern int fddi_iface_getversionstr(fddi_iface_t *iface, const char **version); +extern int fddi_iface_getversion(fddi_iface_t *iface, int *version); /* fddi_device_t */ extern int fddi_dev_getnext(fddi_device_t **dev); 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 23:20:34 2007 @@ -1,13 +1,37 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + #include #include #include #include +#include #include #include #include +#include static pthread_mutex_t lt_dl_mutex = PTHREAD_MUTEX_INITIALIZER; +const char fddi_version_str[] = VERSION; /* fddi_iface_attr_t */ int fddi_iface_attr_init(fddi_iface_attr_t *attr) @@ -52,8 +76,7 @@ return EINVAL; /* initialize instance variables */ - iface->devlist_head = NULL; - iface->tpulist_head = NULL; + memset(iface, 0, sizeof(fddi_iface_t)); /* attach to backend library */ @@ -101,7 +124,7 @@ pthread_mutex_lock(<_dl_mutex); lt_dlclose(iface->backend_lib); pthread_mutex_unlock(<_dl_mutex); - return EINVAL; // FIXME + return EINVAL; /* FIXME better retval? */ } int fddi_iface_destroy(fddi_iface_t *iface) @@ -109,6 +132,9 @@ if (!iface) return EINVAL; + if (iface->name != NULL) + free(iface->name); + pthread_mutex_lock(<_dl_mutex); lt_dlclose(iface->backend_lib); pthread_mutex_unlock(<_dl_mutex); @@ -149,28 +175,55 @@ return iface->backend.cmd(iface, cmd); } +int fddi_iface_getname(fddi_iface_t *iface, char *name, size_t len) +{ + if ((!iface) || (!name)) + return EINVAL; + + strncpy(name, iface->name, len); + + return 0; +} + +int fddi_iface_setname(fddi_iface_t *iface, char *name) +{ + if ((!iface) || (!name)) + return EINVAL; + + if (iface->name != NULL) + free(iface->name); + + iface->name = malloc(strlen(name)+1); + if (!iface->name) + return ENOMEM; + + strncpy(iface->name, name, strlen(name)+1); + + return 0; +} + int fddi_iface_getnodev(fddi_iface_t *iface) { if (!iface) return EINVAL; - /* FIXME */ - return 0; + + return -1; /* FIXME: not implemented yet */ } int fddi_iface_getnotpus(fddi_iface_t *iface) { if (!iface) return EINVAL; - /* FIXME */ - return 0; + + return -1; /* FIXME: not implemented yet */ } int fddi_iface_getnopvs(fddi_iface_t *iface) { if (!iface) return EINVAL; - /* FIXME */ - return 0; + + return -1; /* FIXME: not implemented yet */ } int fddi_iface_getdevlist(fddi_iface_t *iface, fddi_device_t **dev) @@ -191,6 +244,22 @@ return 0; } +int fddi_iface_getversionstr(fddi_iface_t *iface, const char **version) +{ + if (!iface) + return EINVAL; + + *version = fddi_version_str; + + return 0; +} + +int fddi_iface_getversion(fddi_iface_t *iface, int *version) +{ + /* FIXME: use the kernel mechanics to get a numerical version here */ + return 0; +} + /* fddi_device_t */ int fddi_dev_getnext(fddi_device_t **dev) @@ -233,18 +302,16 @@ { if (!dev) return EINVAL; - /* FIXME */ - *id = 0; - return 0; + + return -1; /* FIXME: not implemented yet */ } int fddi_dev_getlogicalid(fddi_device_t *dev, int *id) { if (!dev) return EINVAL; - /* FIXME */ - *id = 0; - return 0; + + return -1; /* FIXME: not implemented yet */ } int fddi_dev_getparamlist(fddi_device_t *dev, fddi_param_t **param) @@ -260,21 +327,24 @@ { if (!dev) return EINVAL; - return 0; + + return -1; /* FIXME: not implemented yet */ } int fddi_dev_read_async(fddi_device_t *dev /* FIXME */) { if (!dev) return EINVAL; - return 0; + + return -1; /* FIXME: not implemented yet */ } int fddi_dev_write_async(fddi_device_t *dev /* FIXME */) { if (!dev) return EINVAL; - return 0; + + return -1; /* FIXME: not implemented yet */ } @@ -320,8 +390,7 @@ if ((!param) || (!notpus)) return EINVAL; - *notpus = 0; /* FIXME */ - return 0; + return -1; /* FIXME: not implemented yet */ } @@ -375,7 +444,8 @@ { if ((!tpu) || (!tpu_callback)) return EINVAL; - return 0; + + return -1; /* FIXME: not implemented yet */ } int fddi_tpu_getpvlist(fddi_tpu_t *tpu, fddi_pv_t **pv) @@ -398,7 +468,7 @@ int fddi_tpu_send(fddi_tpu_t *tpu) { - return 0; + return -1; /* FIXME: not implemented yet */ } From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:43:34 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:43:34 +0200 Subject: [OSADL-svn-commits] r32 - fddi-20070618-1-trunk Message-ID: <200710020943.l929hYfr019418@www.osadl.org> Author: robert Date: Sat Jun 30 23:21:23 2007 New Revision: 32 Log: Modified: fddi-20070618-1-trunk/ChangeLog Modified: fddi-20070618-1-trunk/ChangeLog ============================================================================== --- fddi-20070618-1-trunk/ChangeLog (original) +++ fddi-20070618-1-trunk/ChangeLog Sat Jun 30 23:21:23 2007 @@ -1,5 +1,7 @@ 2007-06-30 Robert Schwebel + * libfddi: return -1 for functions which are currently unimplemented + * tests: added test for fddi_getversionstr * tests: added tests for setstate * tests: added first bunch of unit tests * libexamplebus: added example fieldbus library From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:43:38 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:43:38 +0200 Subject: [OSADL-svn-commits] r33 - fddi-20070618-1-ptx2 Message-ID: <200710020943.l929hcdi019431@www.osadl.org> Author: robert Date: Mon Jul 2 19:44:54 2007 New Revision: 33 Log: next temporary release Added: fddi-20070618-1-ptx2/ - copied from r32, /fddi-20070618-1-trunk/ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:43:40 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:43:40 +0200 Subject: [OSADL-svn-commits] r34 - fddi-20070618-1-ptx2 Message-ID: <200710020943.l929heJu019451@www.osadl.org> Author: robert Date: Mon Jul 2 19:45:43 2007 New Revision: 34 Log: Modified: fddi-20070618-1-ptx2/configure.ac Modified: fddi-20070618-1-ptx2/configure.ac ============================================================================== --- fddi-20070618-1-ptx2/configure.ac (original) +++ fddi-20070618-1-ptx2/configure.ac Mon Jul 2 19:45:43 2007 @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT([fddi], [0.0.1], [bugs at pengutronix.de]) +AC_INIT([fddi], [20070618-1-ptx2], [bugs at pengutronix.de]) AC_CONFIG_HEADERS([include/fddi_config.h]) AC_CONFIG_SRCDIR([src/libfddi.c]) AC_CONFIG_MACRO_DIR([config/m4]) From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:43:43 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:43:43 +0200 Subject: [OSADL-svn-commits] r35 - fddi-20070618-1-trunk Message-ID: <200710020943.l929hh5a019464@www.osadl.org> Author: robert Date: Wed Jul 4 12:49:58 2007 New Revision: 35 Log: fix LIBLTDL_DIR; fix AC_CONFIG_HEADERS typo Modified: fddi-20070618-1-trunk/configure.ac Modified: fddi-20070618-1-trunk/configure.ac ============================================================================== --- fddi-20070618-1-trunk/configure.ac (original) +++ fddi-20070618-1-trunk/configure.ac Wed Jul 4 12:49:58 2007 @@ -38,6 +38,12 @@ AC_CONFIG_SUBDIRS(libltdl) AC_SUBST(INCLTDL) AC_SUBST(LIBLTDL) +if test "${enable_ltdl_install}" = "yes"; then + LIBLTDL_DIR=libltdl +else + LIBLTDL_DIR="" +fi +AC_SUBST(LIBLTDL_DIR) # # Checks for programs. @@ -45,7 +51,6 @@ AC_PROG_CC AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2]) -AC_CONFIG_HEADERS # # Checks for libraries. From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:43:46 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:43:46 +0200 Subject: [OSADL-svn-commits] r36 - fddi-20070618-1-trunk Message-ID: <200710020943.l929hkd2019477@www.osadl.org> Author: robert Date: Wed Jul 4 12:50:27 2007 New Revision: 36 Log: fix install-data-hook for libltdl Modified: fddi-20070618-1-trunk/GNUmakefile.am Modified: fddi-20070618-1-trunk/GNUmakefile.am ============================================================================== --- fddi-20070618-1-trunk/GNUmakefile.am (original) +++ fddi-20070618-1-trunk/GNUmakefile.am Wed Jul 4 12:50:27 2007 @@ -41,10 +41,7 @@ config/m4/ltversion.m4 maintainer-clean-local: - -rm -fr libltdl - -install-data-hook: - cd libltdl && $(MAKE) local-install-files + -rm -fr $(srcdir)/libltdl uninstall-local: -rm -rf $(DESTDIR)$(pkgdatadir)/libltdl From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:43:50 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:43:50 +0200 Subject: [OSADL-svn-commits] r37 - fddi-20070618-1-trunk/src Message-ID: <200710020943.l929hoH4019500@www.osadl.org> Author: robert Date: Wed Jul 4 12:50:51 2007 New Revision: 37 Log: tests need ltdl include flags Modified: fddi-20070618-1-trunk/src/GNUmakefile.am Modified: fddi-20070618-1-trunk/src/GNUmakefile.am ============================================================================== --- fddi-20070618-1-trunk/src/GNUmakefile.am (original) +++ fddi-20070618-1-trunk/src/GNUmakefile.am Wed Jul 4 12:50:51 2007 @@ -2,7 +2,8 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/include \ - -I$(top_builddir)/include + -I$(top_builddir)/include \ + $(INCLTDL) libfddi_la_SOURCES = \ libfddi.c From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:43:52 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:43:52 +0200 Subject: [OSADL-svn-commits] r38 - fddi-20070618-1-trunk Message-ID: <200710020943.l929hqhW019521@www.osadl.org> Author: robert Date: Wed Jul 4 14:27:10 2007 New Revision: 38 Log: fix maintainerclean Modified: fddi-20070618-1-trunk/GNUmakefile.am Modified: fddi-20070618-1-trunk/GNUmakefile.am ============================================================================== --- fddi-20070618-1-trunk/GNUmakefile.am (original) +++ fddi-20070618-1-trunk/GNUmakefile.am Wed Jul 4 14:27:10 2007 @@ -43,6 +43,9 @@ maintainer-clean-local: -rm -fr $(srcdir)/libltdl +distclean-local: + -cd $(builddir)/libltdl && make distclean + uninstall-local: -rm -rf $(DESTDIR)$(pkgdatadir)/libltdl From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:43:56 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:43:56 +0200 Subject: [OSADL-svn-commits] r39 - fddi-20070618-1-trunk Message-ID: <200710020943.l929huwg019543@www.osadl.org> Author: robert Date: Wed Jul 4 14:31:21 2007 New Revision: 39 Log: Modified: fddi-20070618-1-trunk/ChangeLog Modified: fddi-20070618-1-trunk/ChangeLog ============================================================================== --- fddi-20070618-1-trunk/ChangeLog (original) +++ fddi-20070618-1-trunk/ChangeLog Wed Jul 4 14:31:21 2007 @@ -1,3 +1,10 @@ +2007-07-04 Robert Schwebel + + * libftdl: added + * makefiles: fixed distcheck (works now if all tests would work, + which is not the case because of unimplemented functionality) + * release: released 20070618-1-ptx3 (svn only) + 2007-06-30 Robert Schwebel * libfddi: return -1 for functions which are currently unimplemented From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:43:59 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:43:59 +0200 Subject: [OSADL-svn-commits] r40 - fddi-20070618-1-ptx3 Message-ID: <200710020943.l929hxtN019565@www.osadl.org> Author: robert Date: Wed Jul 4 14:31:53 2007 New Revision: 40 Log: * release Added: fddi-20070618-1-ptx3/ - copied from r39, /fddi-20070618-1-trunk/ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:44:02 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:44:02 +0200 Subject: [OSADL-svn-commits] r41 - fddi-20070618-1-ptx3 Message-ID: <200710020944.l929i2D9019587@www.osadl.org> Author: robert Date: Wed Jul 4 14:33:22 2007 New Revision: 41 Log: version bump Modified: fddi-20070618-1-ptx3/configure.ac Modified: fddi-20070618-1-ptx3/configure.ac ============================================================================== --- fddi-20070618-1-ptx3/configure.ac (original) +++ fddi-20070618-1-ptx3/configure.ac Wed Jul 4 14:33:22 2007 @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT([fddi], [0.0.1], [bugs at pengutronix.de]) +AC_INIT([fddi], [20070618-1-ptx3], [bugs at pengutronix.de]) AC_CONFIG_HEADERS([include/fddi_config.h]) AC_CONFIG_SRCDIR([src/libfddi.c]) AC_CONFIG_MACRO_DIR([config/m4]) From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:44:05 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:44:05 +0200 Subject: [OSADL-svn-commits] r42 - in fddi-20070618-1-trunk/busconfig: . 3S misc Message-ID: <200710020944.l929i5t7019600@www.osadl.org> Author: robert Date: Tue Jul 10 20:55:10 2007 New Revision: 42 Log: added busconfig sniplets Added: fddi-20070618-1-trunk/busconfig/ fddi-20070618-1-trunk/busconfig/3S/ fddi-20070618-1-trunk/busconfig/3S/ModBusConfigExample.xml fddi-20070618-1-trunk/busconfig/3S/fddiconfig.xsd fddi-20070618-1-trunk/busconfig/misc/ fddi-20070618-1-trunk/busconfig/misc/pretty.xsl Added: fddi-20070618-1-trunk/busconfig/3S/ModBusConfigExample.xml ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/busconfig/3S/ModBusConfigExample.xml Tue Jul 10 20:55:10 2007 @@ -0,0 +1,62 @@ + + + + + + + 0 + ModbusMaster + + + 1 + ModbusSlave1 + 14 + 0 + 22 + 17 + 64 + 8 + 1 + 100 + false + 72 + 12 + 2 + 100 + true + + + + 2 + ModbusSlave2 + 4 + 11 + 20 + 4 + 1 + 50 + true + + + 1010 + + + + + ModbusSlave1 + + + + Motor Speed + uint32_t + 0x0 + + Motor Position + uint32_t + 0x3 + + + + + Added: fddi-20070618-1-trunk/busconfig/3S/fddiconfig.xsd ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/busconfig/3S/fddiconfig.xsd Tue Jul 10 20:55:10 2007 @@ -0,0 +1,27 @@ + + + + + + Root device of a fddi configuration + + + + + + + + + + + + + + + + + + + + + Added: fddi-20070618-1-trunk/busconfig/misc/pretty.xsl ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/busconfig/misc/pretty.xsl Tue Jul 10 20:55:10 2007 @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:44:09 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:44:09 +0200 Subject: [OSADL-svn-commits] r43 - fddi-20070618-1-trunk Message-ID: <200710020944.l929i9V3019623@www.osadl.org> Author: robert Date: Tue Jul 10 20:55:38 2007 New Revision: 43 Log: Modified: fddi-20070618-1-trunk/GNUmakefile.am Modified: fddi-20070618-1-trunk/GNUmakefile.am ============================================================================== --- fddi-20070618-1-trunk/GNUmakefile.am (original) +++ fddi-20070618-1-trunk/GNUmakefile.am Tue Jul 10 20:55:38 2007 @@ -4,6 +4,7 @@ EXTRA_DIST = \ autogen.sh \ + busconfig \ config/m4/.secret-world-domination-project \ libltdl/COPYING.LIB \ libltdl/Makefile.am \ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:44:11 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:44:11 +0200 Subject: [OSADL-svn-commits] r44 - fddi-20070618-1-trunk/doc Message-ID: <200710020944.l929iB8M019646@www.osadl.org> Author: robert Date: Tue Jul 10 20:55:48 2007 New Revision: 44 Log: Added: fddi-20070618-1-trunk/doc/fddi_modbus_config_3s-20070710-7.odt (contents, props changed) fddi-20070618-1-trunk/doc/fddi_proposal_3s-20070618-1.odt - copied unchanged from r41, /fddi-20070618-1-trunk/doc/Fieldbus-Device-Driver-Interface.odt Removed: fddi-20070618-1-trunk/doc/Fieldbus-Device-Driver-Interface.odt Added: fddi-20070618-1-trunk/doc/fddi_modbus_config_3s-20070710-7.odt ============================================================================== Binary file. No diff available. From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:44:14 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:44:14 +0200 Subject: [OSADL-svn-commits] r45 - fddi-20070618-1-trunk/busconfig/Pengutronix Message-ID: <200710020944.l929iENC019658@www.osadl.org> Author: robert Date: Tue Jul 10 22:17:46 2007 New Revision: 45 Log: added openio example Added: fddi-20070618-1-trunk/busconfig/Pengutronix/ fddi-20070618-1-trunk/busconfig/Pengutronix/modbus-example.xml Added: fddi-20070618-1-trunk/busconfig/Pengutronix/modbus-example.xml ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/busconfig/Pengutronix/modbus-example.xml Tue Jul 10 22:17:46 2007 @@ -0,0 +1,94 @@ + + + + + + + OSADL Modbus Demo System + + + + Controller PC + + + + Ethernet + + + + + + + + + + + master + + + + + + + + Wago IO Box + + + + Ethernet + + + + + + + + + + + slave + + + + 1 + + + Signal Noun Red Light + bool_t + 0 + 0 + + + + Signal Noun Yellow Light + bool_t + 0 + 1 + + + + Signal Noun Green Light + bool_t + 0 + 2 + + + + + + + + + + + + + + + + + + + + + From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:44:17 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:44:17 +0200 Subject: [OSADL-svn-commits] r46 - fddi-20070618-1-trunk/busconfig/3S Message-ID: <200710020944.l929iHxE019671@www.osadl.org> Author: robert Date: Wed Jul 11 09:44:41 2007 New Revision: 46 Log: removed ptx sniplet from 3s config Modified: fddi-20070618-1-trunk/busconfig/3S/ModBusConfigExample.xml Modified: fddi-20070618-1-trunk/busconfig/3S/ModBusConfigExample.xml ============================================================================== --- fddi-20070618-1-trunk/busconfig/3S/ModBusConfigExample.xml (original) +++ fddi-20070618-1-trunk/busconfig/3S/ModBusConfigExample.xml Wed Jul 11 09:44:41 2007 @@ -42,21 +42,3 @@ 1010 - - - ModbusSlave1 - - - - Motor Speed - uint32_t - 0x0 - - Motor Position - uint32_t - 0x3 - - - - - From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:44:19 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:44:19 +0200 Subject: [OSADL-svn-commits] r47 - in fddi-20070618-1-trunk: . src tests Message-ID: <200710020944.l929iJrj019684@www.osadl.org> Author: robert Date: Wed Jul 11 09:50:37 2007 New Revision: 47 Log: added skeleton for libmodbus Added: fddi-20070618-1-trunk/src/libfddi_libmodbus.c fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c Modified: fddi-20070618-1-trunk/configure.ac fddi-20070618-1-trunk/src/GNUmakefile.am fddi-20070618-1-trunk/tests/GNUmakefile.am Modified: fddi-20070618-1-trunk/configure.ac ============================================================================== --- fddi-20070618-1-trunk/configure.ac (original) +++ fddi-20070618-1-trunk/configure.ac Wed Jul 11 09:50:37 2007 @@ -117,11 +117,12 @@ AC_MSG_CHECKING([whether to enable debugging]) AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=yes@:>@]), - [case "$enableval" in - y | yes) CONFIG_DEBUG=yes ;; - *) CONFIG_DEBUG=no ;; + [case "$enableval" in + y | yes) CONFIG_DEBUG=yes ;; + *) CONFIG_DEBUG=no ;; esac], - [CONFIG_DEBUG=yes]) + [CONFIG_DEBUG=yes] +) AC_MSG_RESULT([${CONFIG_DEBUG}]) if test "${CONFIG_DEBUG}" = "yes"; then CFLAGS="${CFLAGS} -Werror -Wsign-compare -Wfloat-equal -Wformat-security -g -O1" @@ -130,6 +131,54 @@ CFLAGS="${CFLAGS} -O2" fi +# +# XML parsers +# +AC_MSG_CHECKING([for xml parser]) +AC_ARG_WITH(xmlparser, + AS_HELP_STRING([--with-xmlparser], [select used xml parser; you can chose from expat, + libxml2 or auto. @<:@default=libxml2@:>@]), + [case "$withval" in + expat) CONFIG_XMLPARSER=expat ;; + libxml2) CONFIG_XMLPARSER=libxml2 ;; + n | no) CONFIG_XMLPARSER=no ;; + auto | *) CONFIG_XMLPARSER=auto ;; + esac], + [CONFIG_XMLPARSER=auto] +) +if test "${CONFIG_XMLPARSER}" = "auto"; then + AC_MSG_WARN([echo "FIXME - auto test for xml parser not written yet"]) +fi +AM_CONDITIONAL(XMLPARSER_EXPAT, test "${CONFIG_XMLPARSER}" = "expat") +AM_CONDITIONAL(XMLPARSER_LIBXML2, test "${CONFIG_XMLPARSER}" = "libxml2") +AC_MSG_RESULT([${CONFIG_XMLPARSER}]) + + +# +# Backends +# +AC_MSG_CHECKING([whether to enable libmodbus backend]) +AC_ARG_ENABLE(backend-libmodbus, + AS_HELP_STRING([--enable-backend-libmodbus], [enable libmodbus backend @<:@default=no@:>@]), + [case "$enableval" in + y | yes) CONFIG_BACKEND_LIBMODBUS=yes ;; + *) CONFIG_BACKEND_LIBMODBUS=no ;; + esac], + [CONFIG_BACKEND_LIBMODBUS=no] +) +AM_CONDITIONAL(BACKEND_LIBMODBUS, test "${CONFIG_BACKEND_LIBMODBUS}" = "yes") +AC_MSG_RESULT([${CONFIG_BACKEND_LIBMODBUS}]) + +if test "${CONFIG_BACKEND_LIBMODBUS}" = "yes"; then + AC_MSG_CHECKING([whether libmodbus backend finds an xml parser]) + if test "${CONFIG_XMLPARSER}" != "libxml2"; then + AC_MSG_RESULT([no]) + AC_MSG_ERROR([libmodbus backend needs libxml2, specify with --with-xmlparser]) + else + AC_MSG_RESULT([yes]) + fi +fi + AC_CONFIG_FILES([ GNUmakefile Modified: fddi-20070618-1-trunk/src/GNUmakefile.am ============================================================================== --- fddi-20070618-1-trunk/src/GNUmakefile.am (original) +++ fddi-20070618-1-trunk/src/GNUmakefile.am Wed Jul 11 09:50:37 2007 @@ -1,10 +1,21 @@ -lib_LTLIBRARIES = libfddi.la +BACKEND_LIBS = +if BACKEND_LIBMODBUS +BACKEND_LIBS += libfddi_libmodbus.la +endif + +lib_LTLIBRARIES = \ + libfddi.la \ + $(BACKEND_LIBS) AM_CPPFLAGS = \ -I$(top_srcdir)/include \ -I$(top_builddir)/include \ $(INCLTDL) +# +# libfddi +# + libfddi_la_SOURCES = \ libfddi.c @@ -16,5 +27,19 @@ libfddi_la_LIBADD = \ $(LIBLTDL) +# +# libfddi_modbusmaster +# + +libfddi_libmodbus_la_SOURCES = \ + libfddi_libmodbus.c + +libfddi_libmodbus_la_LIBADD = \ + $(top_builddir)/src/libfddi.la + MAINTAINERCLEANFILES = \ GNUmakefile.in + + + + Added: fddi-20070618-1-trunk/src/libfddi_libmodbus.c ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/src/libfddi_libmodbus.c Wed Jul 11 09:50:37 2007 @@ -0,0 +1,51 @@ +/* + * fddi backend for libmodbus + */ + +#include +#include + +int readconfig(fddi_iface_t *iface, const char *configfile) +{ + return 0; +} + +int setstate(fddi_iface_t *iface, fddi_state_enum_t state) +{ + int retval = -1; + + switch(state) { + case STATE_UNCONFIGURED: + case STATE_MISSING: + case STATE_CONFIG_ERROR: + case STATE_PREOPERATIONAL: + case STATE_OPERATIONAL: + case STATE_OPERATION_ERROR: + retval = 0; + break; + default: + break; + } + + return retval; +} + +int cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd) +{ + int retval = -1; + + switch (cmd) { + case CMD_START: + case CMD_STOP: + case CMD_RESET: + case CMD_IDENTIFY: + case CMD_QUITERR: + retval = 0; + break; + default: + break; + } + + return retval; +} + Modified: fddi-20070618-1-trunk/tests/GNUmakefile.am ============================================================================== --- fddi-20070618-1-trunk/tests/GNUmakefile.am (original) +++ fddi-20070618-1-trunk/tests/GNUmakefile.am Wed Jul 11 09:50:37 2007 @@ -1,8 +1,6 @@ -TESTS = \ - test_examplebus1 \ +BACKEND_EXAMPLEBUS_TESTS = \ test_fddi_examplebus1 \ test_fddi_examplebus_attach_backend \ - test_fddi_versionstr \ test_fddi_examplebus_readconfig \ test_fddi_examplebus_cmd_start \ test_fddi_examplebus_cmd_stop \ @@ -16,26 +14,25 @@ test_fddi_examplebus_setstate_preoperational \ test_fddi_examplebus_setstate_unconfigured +if BACKEND_LIBMODBUS +BACKEND_LIBMODBUS_TESTS = \ + test_fddi_libmodbus1 +endif + +TESTS = \ + test_examplebus1 \ + test_fddi_versionstr \ + $(BACKEND_EXAMPLEBUS_TESTS) \ + $(BACKEND_LIBMODBUS_TESTS) + TESTS_ENVIRONMENT = \ LD_LIBRARY_PATH=$(top_builddir)/tests/.libs noinst_PROGRAMS = \ test_examplebus1 \ - test_fddi_examplebus1 \ - test_fddi_examplebus_attach_backend \ test_fddi_versionstr \ - 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_configerror \ - test_fddi_examplebus_setstate_missing \ - test_fddi_examplebus_setstate_operational \ - test_fddi_examplebus_setstate_operation_error \ - test_fddi_examplebus_setstate_preoperational \ - test_fddi_examplebus_setstate_unconfigured + $(BACKEND_EXAMPLEBUS_TESTS) + $(BACKEND_LIBMODBUS_TESTS) lib_LTLIBRARIES = \ libexamplebus.la \ @@ -60,7 +57,7 @@ -module # -# tests +# examplebus backend # test_examplebus1_SOURCES = \ @@ -159,9 +156,15 @@ test_fddi_examplebus_setstate_unconfigured_LDADD = \ $(top_builddir)/src/libfddi.la -#fddi_la_LDFLAGS = \ -# -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -# -no-undefined # win32_dll stuff only +# +# libmodbus backend +# + +test_fddi_libmodbus1_SOURCES = \ + test_fddi_libmodbus1.c + +test_fddi_libmodbus1_LDADD = \ + $(top_builddir)/src/libfddi_libmodbus.la EXTRA_DIST = \ examplebus.h Added: fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c Wed Jul 11 09:50:37 2007 @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:44:22 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:44:22 +0200 Subject: [OSADL-svn-commits] r48 - in fddi-20070618-1-trunk: . include/osadl src tests Message-ID: <200710020944.l929iM2F019711@www.osadl.org> Author: robert Date: Wed Jul 11 16:28:44 2007 New Revision: 48 Log: refacture readconfig -> configure Modified: fddi-20070618-1-trunk/TODO 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/src/libfddi_libmodbus.c fddi-20070618-1-trunk/tests/GNUmakefile.am fddi-20070618-1-trunk/tests/libfddi_examplebus.c fddi-20070618-1-trunk/tests/test_fddi_examplebus1.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_readconfig.c Modified: fddi-20070618-1-trunk/TODO ============================================================================== --- fddi-20070618-1-trunk/TODO (original) +++ fddi-20070618-1-trunk/TODO Wed Jul 11 16:28:44 2007 @@ -0,0 +1,8 @@ +TODO +---- + +[ ] invent performant data transport model with persistence + + + + Modified: fddi-20070618-1-trunk/configure.ac ============================================================================== --- fddi-20070618-1-trunk/configure.ac (original) +++ fddi-20070618-1-trunk/configure.ac Wed Jul 11 16:28:44 2007 @@ -170,6 +170,17 @@ AC_MSG_RESULT([${CONFIG_BACKEND_LIBMODBUS}]) if test "${CONFIG_BACKEND_LIBMODBUS}" = "yes"; then + + REQUIRES_LIBMODBUS="libmodbus >= 1.0.3" + AC_SUBST(REQUIRES_LIBMODBUS) + PKG_CHECK_MODULES([libmodbus], + [${REQUIRES_LIBMODBUS}], + [], + [AC_MSG_ERROR([${REQUIRES_LIBMODBUS} not found by pkg-config on your system])] + ) + AC_SUBST(libmodbus_CFLAGS) + AC_SUBST(libmodbus_LIBS) + AC_MSG_CHECKING([whether libmodbus backend finds an xml parser]) if test "${CONFIG_XMLPARSER}" != "libxml2"; then AC_MSG_RESULT([no]) @@ -177,6 +188,7 @@ else AC_MSG_RESULT([yes]) fi + fi 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 Wed Jul 11 16:28:44 2007 @@ -94,7 +94,7 @@ }; struct fddi_iface_backend_ops { - int (*readconfig) (fddi_iface_t *iface, const char *configfile); + int (*configure) (fddi_iface_t *iface, const char *configfile, void *data); int (*setstate) (fddi_iface_t *iface, fddi_state_enum_t state); int (*cmd) (fddi_iface_t *iface, fddi_cmd_enum_t cmd); }; @@ -119,7 +119,7 @@ /* 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_configure(fddi_iface_t *iface, const char *configfile, void *data); extern int fddi_iface_setstate(fddi_iface_t *iface, fddi_state_enum_t state); extern int fddi_iface_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd); extern int fddi_iface_getname(fddi_iface_t *iface, char *name, size_t len); Modified: fddi-20070618-1-trunk/src/GNUmakefile.am ============================================================================== --- fddi-20070618-1-trunk/src/GNUmakefile.am (original) +++ fddi-20070618-1-trunk/src/GNUmakefile.am Wed Jul 11 16:28:44 2007 @@ -34,8 +34,12 @@ libfddi_libmodbus_la_SOURCES = \ libfddi_libmodbus.c +libfddi_libmodbus_la_CPPFLAGS = \ + $(libmodbus_CFLAGS) + libfddi_libmodbus_la_LIBADD = \ - $(top_builddir)/src/libfddi.la + $(top_builddir)/src/libfddi.la \ + $(libmodbus_LIBS) 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 Wed Jul 11 16:28:44 2007 @@ -96,7 +96,7 @@ lt_dlerror(); /* register backend functions */ - iface->backend.readconfig = lt_dlsym(iface->backend_lib, "readconfig"); + iface->backend.configure = lt_dlsym(iface->backend_lib, "configure"); if ((error_string = lt_dlerror())) { pthread_mutex_unlock(<_dl_mutex); goto iface_init_err; @@ -142,15 +142,15 @@ return 0; } -int fddi_iface_readconfig(fddi_iface_t *iface, const char *configfile) +int fddi_iface_configure(fddi_iface_t *iface, const char *configfile, void *data) { if ((!iface) || (!configfile)) return EINVAL; - if (!iface->backend.readconfig) + if (!iface->backend.configure) return ENOSYS; - return iface->backend.readconfig(iface, configfile); + return iface->backend.configure(iface, configfile, data); } int fddi_iface_setstate(fddi_iface_t *iface, fddi_state_enum_t state) Modified: fddi-20070618-1-trunk/src/libfddi_libmodbus.c ============================================================================== --- fddi-20070618-1-trunk/src/libfddi_libmodbus.c (original) +++ fddi-20070618-1-trunk/src/libfddi_libmodbus.c Wed Jul 11 16:28:44 2007 @@ -5,8 +5,12 @@ #include #include -int readconfig(fddi_iface_t *iface, const char *configfile) +int configure(fddi_iface_t *iface, const char *configfile, void *data) { + + + + return 0; } Modified: fddi-20070618-1-trunk/tests/GNUmakefile.am ============================================================================== --- fddi-20070618-1-trunk/tests/GNUmakefile.am (original) +++ fddi-20070618-1-trunk/tests/GNUmakefile.am Wed Jul 11 16:28:44 2007 @@ -1,7 +1,7 @@ BACKEND_EXAMPLEBUS_TESTS = \ test_fddi_examplebus1 \ test_fddi_examplebus_attach_backend \ - test_fddi_examplebus_readconfig \ + test_fddi_examplebus_configure \ test_fddi_examplebus_cmd_start \ test_fddi_examplebus_cmd_stop \ test_fddi_examplebus_cmd_quiterr \ @@ -84,10 +84,10 @@ test_fddi_versionstr_LDADD = \ $(top_builddir)/src/libfddi.la -test_fddi_examplebus_readconfig_SOURCES = \ - test_fddi_examplebus_readconfig.c +test_fddi_examplebus_configure_SOURCES = \ + test_fddi_examplebus_configure.c -test_fddi_examplebus_readconfig_LDADD = \ +test_fddi_examplebus_configure_LDADD = \ $(top_builddir)/src/libfddi.la test_fddi_examplebus_cmd_start_SOURCES = \ Modified: fddi-20070618-1-trunk/tests/libfddi_examplebus.c ============================================================================== --- fddi-20070618-1-trunk/tests/libfddi_examplebus.c (original) +++ fddi-20070618-1-trunk/tests/libfddi_examplebus.c Wed Jul 11 16:28:44 2007 @@ -5,7 +5,7 @@ #include #include -int readconfig(fddi_iface_t *iface, const char *configfile) +int configure(fddi_iface_t *iface, const char *configfile, void *data) { return 0; } Modified: fddi-20070618-1-trunk/tests/test_fddi_examplebus1.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_examplebus1.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus1.c Wed Jul 11 16:28:44 2007 @@ -38,7 +38,7 @@ fddi_iface_init(&exb0_iface, &exb0_attr); /* some things you can do with ifaces */ - fddi_iface_readconfig(&exb0_iface, "config.xml"); + fddi_iface_configure(&exb0_iface, "config.xml", NULL); fddi_iface_setstate(&exb0_iface, STATE_UNCONFIGURED); /* add blocking/nonblocking */ fddi_iface_cmd(&exb0_iface, CMD_START); /* propagates to devices behind iface */ Modified: fddi-20070618-1-trunk/tests/test_fddi_examplebus_readconfig.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_examplebus_readconfig.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_readconfig.c Wed Jul 11 16:28:44 2007 @@ -21,9 +21,9 @@ return ret; } - ret = fddi_iface_readconfig(&exb0_iface, "test_fddi_examplebus_readconfig.xml"); + ret = fddi_iface_configure(&exb0_iface, "test_fddi_examplebus_configure.xml", NULL); if (ret) { - fprintf(stderr, "fddi_iface_readconfig() failed\n"); + fprintf(stderr, "fddi_iface_configure() failed\n"); return ret; } From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:44:26 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:44:26 +0200 Subject: [OSADL-svn-commits] r49 - fddi-20070618-1-trunk/tests Message-ID: <200710020944.l929iQIS019741@www.osadl.org> Author: robert Date: Wed Jul 11 16:29:30 2007 New Revision: 49 Log: refacture readconfig -> configure Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_configure.c - copied unchanged from r48, /fddi-20070618-1-trunk/tests/test_fddi_examplebus_readconfig.c Removed: fddi-20070618-1-trunk/tests/test_fddi_examplebus_readconfig.c From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:44:30 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:44:30 +0200 Subject: [OSADL-svn-commits] r50 - in fddi-20070618-1-trunk: src tests Message-ID: <200710020944.l929iUYt019760@www.osadl.org> Author: robert Date: Wed Jul 11 16:45:18 2007 New Revision: 50 Log: add config call Modified: fddi-20070618-1-trunk/src/libfddi_libmodbus.c fddi-20070618-1-trunk/tests/GNUmakefile.am fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c Modified: fddi-20070618-1-trunk/src/libfddi_libmodbus.c ============================================================================== --- fddi-20070618-1-trunk/src/libfddi_libmodbus.c (original) +++ fddi-20070618-1-trunk/src/libfddi_libmodbus.c Wed Jul 11 16:45:18 2007 @@ -7,9 +7,7 @@ int configure(fddi_iface_t *iface, const char *configfile, void *data) { - - - + printf("parsing configfile: %s\n", configfile); return 0; } Modified: fddi-20070618-1-trunk/tests/GNUmakefile.am ============================================================================== --- fddi-20070618-1-trunk/tests/GNUmakefile.am (original) +++ fddi-20070618-1-trunk/tests/GNUmakefile.am Wed Jul 11 16:45:18 2007 @@ -31,7 +31,7 @@ noinst_PROGRAMS = \ test_examplebus1 \ test_fddi_versionstr \ - $(BACKEND_EXAMPLEBUS_TESTS) + $(BACKEND_EXAMPLEBUS_TESTS) \ $(BACKEND_LIBMODBUS_TESTS) lib_LTLIBRARIES = \ @@ -166,9 +166,18 @@ test_fddi_libmodbus1_LDADD = \ $(top_builddir)/src/libfddi_libmodbus.la +test_fddi_libmodbus1_DEPENDENCIES = \ + test_fddi_libmodbus1.xml + +test_fddi_libmodbus1.xml: + cp $(top_srcdir)/busconfig/Pengutronix/modbus-example.xml test_fddi_libmodbus1.xml + EXTRA_DIST = \ examplebus.h MAINTAINERCLEANFILES = \ GNUmakefile.in +CLEANFILES = \ + test_fddi_libmodbus1.xml + Modified: fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c Wed Jul 11 16:45:18 2007 @@ -1,4 +1,35 @@ +#include +#include + +#include + int main(void) { - return 0; + fddi_iface_attr_t modbus0_attr; + fddi_iface_t modbus0_iface; + + int ret; + + /* instanciate io_interface */ + fddi_iface_attr_init(&modbus0_attr); + fddi_iface_attr_setclass(&modbus0_attr, "libfddi_libmodbus.so"); + fddi_iface_attr_setdevice(&modbus0_attr, "demosystem.controller.modbus0"); + + ret = fddi_iface_init(&modbus0_iface, &modbus0_attr); + if (ret) { + fprintf(stderr, "fddi_iface_init() failed\n"); + return ret; + } + + ret = fddi_iface_configure(&modbus0_iface,"test_fddi_libmodbus1.xml", NULL); + if (ret) { + fprintf(stderr, "fddi_iface_configure() failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&modbus0_iface); + + exit(0); } + From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:44:38 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:44:38 +0200 Subject: [OSADL-svn-commits] r51 - in fddi-20070618-1-trunk: include/osadl src tests Message-ID: <200710020944.l929icQQ019794@www.osadl.org> Author: robert Date: Wed Jul 11 17:40:47 2007 New Revision: 51 Log: more modbus example stuff Modified: fddi-20070618-1-trunk/include/osadl/fddi.h fddi-20070618-1-trunk/src/libfddi.c fddi-20070618-1-trunk/src/libfddi_libmodbus.c fddi-20070618-1-trunk/tests/GNUmakefile.am fddi-20070618-1-trunk/tests/libfddi_examplebus.c 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 Wed Jul 11 17:40:47 2007 @@ -78,9 +78,29 @@ }; +typedef enum { + + BOOL, + +} fddi_pv_type_enum_t; + struct fddi_pv { + + /* FIXME: maybe put into generic list implementation */ struct fddi_pv *next; struct fddi_pv *previous; + + char *id_prefix; + int id_index; + char *id_postfix; + char *id; + + fddi_param_t *param_list_head; + fddi_param_t *name; + fddi_pv_type_enum_t type; + unsigned int offset; + unsigned int bit; + }; struct fddi_tpu { @@ -89,7 +109,7 @@ unsigned long flags; struct fddi_tpu *next; struct fddi_tpu *previous; - fddi_pv_t *pv_list; + fddi_pv_t *pv_list_head; char *payload; }; Modified: fddi-20070618-1-trunk/src/libfddi.c ============================================================================== --- fddi-20070618-1-trunk/src/libfddi.c (original) +++ fddi-20070618-1-trunk/src/libfddi.c Wed Jul 11 17:40:47 2007 @@ -59,7 +59,11 @@ if (!attr) return EINVAL; - attr->fddi_device_name = fddi_device_name; + attr->fddi_device_name = malloc(strlen(fddi_device_name)); + if (!attr->fddi_device_name) + return ENOMEM; + + strcpy(attr->fddi_device_name, fddi_device_name); return 0; } @@ -77,6 +81,7 @@ /* initialize instance variables */ memset(iface, 0, sizeof(fddi_iface_t)); + iface->name = attr->fddi_device_name; /* attach to backend library */ @@ -96,19 +101,19 @@ lt_dlerror(); /* register backend functions */ - iface->backend.configure = lt_dlsym(iface->backend_lib, "configure"); + iface->backend.configure = lt_dlsym(iface->backend_lib, "fddi_backend_configure"); if ((error_string = lt_dlerror())) { pthread_mutex_unlock(<_dl_mutex); goto iface_init_err; } - iface->backend.setstate = lt_dlsym(iface->backend_lib, "setstate"); + iface->backend.setstate = lt_dlsym(iface->backend_lib, "fddi_backend_setstate"); if ((error_string = lt_dlerror())) { pthread_mutex_unlock(<_dl_mutex); goto iface_init_err; } - iface->backend.cmd = lt_dlsym(iface->backend_lib, "cmd"); + iface->backend.cmd = lt_dlsym(iface->backend_lib, "fddi_backend_cmd"); if ((error_string = lt_dlerror())) { pthread_mutex_unlock(<_dl_mutex); goto iface_init_err; @@ -453,7 +458,7 @@ if ((!tpu) || (!pv)) return EINVAL; - *pv = tpu->pv_list; + *pv = tpu->pv_list_head; return 0; } Modified: fddi-20070618-1-trunk/src/libfddi_libmodbus.c ============================================================================== --- fddi-20070618-1-trunk/src/libfddi_libmodbus.c (original) +++ fddi-20070618-1-trunk/src/libfddi_libmodbus.c Wed Jul 11 17:40:47 2007 @@ -2,17 +2,91 @@ * fddi backend for libmodbus */ +#include #include +#include #include -int configure(fddi_iface_t *iface, const char *configfile, void *data) +int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data) { + fddi_tpu_t *tpu; + fddi_pv_t *pv1, *pv2, *pv3; + printf("parsing configfile: %s\n", configfile); + printf("for interface: %s\n", iface->name); + + /* + * FIXME: add xml parser here, we configure this hard + * for a first test + */ + + tpu = calloc(1, sizeof(fddi_tpu_t)); + if (!tpu) + goto out; + + pv1 = calloc(1, sizeof(fddi_pv_t)); + if (!tpu) + goto pv1; + + pv2 = calloc(1, sizeof(fddi_pv_t)); + if (!tpu) + goto pv2; + + pv3 = calloc(1, sizeof(fddi_pv_t)); + if (!tpu) + goto pv3; + + iface->tpulist_head = tpu; + tpu->pv_list_head = pv1; + + // pv1->id_prefix = + // pv1->id_index = + // pv1->id_postfix = + // pv1->id = + // pv1->param_list_head = NULL; + // pv1->name = + pv1->type = BOOL; + pv1->offset = 0; + pv1->bit = 0; + pv1->previous = NULL; + pv1->next = pv2; + + // pv2->id_prefix = + // pv2->id_index = + // pv2->id_postfix = + // pv2->id = + // pv2->param_list_head = NULL; + // pv2->name = + pv2->type = BOOL; + pv2->offset = 0; + pv2->bit = 1; + pv2->previous = pv1; + pv2->next = pv3; + + // pv3->id_prefix = + // pv3->id_index = + // pv3->id_postfix = + // pv3->id = + // pv3->param_list_head = NULL; + // pv3->name = + pv3->type = BOOL; + pv3->offset = 0; + pv3->bit = 2; + pv3->previous = pv2; + pv3->next = NULL; return 0; +pv3: + free(pv2); +pv2: + free(pv1); +pv1: + free(tpu); +out: + return ENOMEM; } -int setstate(fddi_iface_t *iface, fddi_state_enum_t state) +int fddi_backend_setstate(fddi_iface_t *iface, fddi_state_enum_t state) { int retval = -1; @@ -32,7 +106,7 @@ return retval; } -int cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd) +int fddi_backend_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd) { int retval = -1; Modified: fddi-20070618-1-trunk/tests/GNUmakefile.am ============================================================================== --- fddi-20070618-1-trunk/tests/GNUmakefile.am (original) +++ fddi-20070618-1-trunk/tests/GNUmakefile.am Wed Jul 11 17:40:47 2007 @@ -1,5 +1,4 @@ BACKEND_EXAMPLEBUS_TESTS = \ - test_fddi_examplebus1 \ test_fddi_examplebus_attach_backend \ test_fddi_examplebus_configure \ test_fddi_examplebus_cmd_start \ @@ -14,6 +13,8 @@ test_fddi_examplebus_setstate_preoperational \ test_fddi_examplebus_setstate_unconfigured +# test_fddi_examplebus1 + if BACKEND_LIBMODBUS BACKEND_LIBMODBUS_TESTS = \ test_fddi_libmodbus1 Modified: fddi-20070618-1-trunk/tests/libfddi_examplebus.c ============================================================================== --- fddi-20070618-1-trunk/tests/libfddi_examplebus.c (original) +++ fddi-20070618-1-trunk/tests/libfddi_examplebus.c Wed Jul 11 17:40:47 2007 @@ -5,12 +5,12 @@ #include #include -int configure(fddi_iface_t *iface, const char *configfile, void *data) +int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data) { return 0; } -int setstate(fddi_iface_t *iface, fddi_state_enum_t state) +int fddi_backend_setstate(fddi_iface_t *iface, fddi_state_enum_t state) { int retval = -1; @@ -30,7 +30,7 @@ return retval; } -int cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd) +int fddi_backend_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd) { int retval = -1; From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:44:41 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:44:41 +0200 Subject: [OSADL-svn-commits] r52 - in fddi-20070618-1-trunk: include/osadl src tests Message-ID: <200710020944.l929ifxt019827@www.osadl.org> Author: robert Date: Wed Jul 11 21:01:13 2007 New Revision: 52 Log: more modbus stuff Modified: fddi-20070618-1-trunk/include/osadl/fddi.h fddi-20070618-1-trunk/src/libfddi.c fddi-20070618-1-trunk/src/libfddi_libmodbus.c fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c 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 Wed Jul 11 21:01:13 2007 @@ -22,6 +22,8 @@ #ifndef OSADL_FDDI_H #define OSADL_FDDI_H +#include + typedef enum { STATE_UNCONFIGURED, /* the device is not configured */ @@ -103,32 +105,57 @@ }; +typedef enum { + + IN, + OUT, + INOUT, + +} fddi_tpu_direction_enum_t; + struct fddi_tpu { - char *name; - int id; - unsigned long flags; + + /* FIXME: maybe put into generic list implementation */ struct fddi_tpu *next; struct fddi_tpu *previous; + + char *id_prefix; + int id_index; + char *id_postfix; + char *id; + + uint64_t cycletime; /* ns */ + fddi_tpu_direction_enum_t direction; fddi_pv_t *pv_list_head; + unsigned long flags; char *payload; }; struct fddi_iface_backend_ops { + int (*configure) (fddi_iface_t *iface, const char *configfile, void *data); int (*setstate) (fddi_iface_t *iface, fddi_state_enum_t state); int (*cmd) (fddi_iface_t *iface, fddi_cmd_enum_t cmd); + }; struct fddi_iface { char *name; fddi_state_enum_t state; + fddi_device_t *devlist_head; + unsigned int nodev; + fddi_tpu_t *tpulist_head; + unsigned int notpus; + unsigned int nopvs; void *backend_lib; fddi_iface_backend_ops_t backend; + /* FIXME: add private data for derived backends */ + }; /* fddi_iface_attr_t */ @@ -151,6 +178,11 @@ extern int fddi_iface_gettpulist(fddi_iface_t *iface, fddi_tpu_t **tpu); extern int fddi_iface_getversionstr(fddi_iface_t *iface, const char **version); extern int fddi_iface_getversion(fddi_iface_t *iface, int *version); +/* + * TODO: split public/private + * TODO: add_tpu(), with counts + * TODO: add_pv(), with counts + */ /* fddi_device_t */ extern int fddi_dev_getnext(fddi_device_t **dev); Modified: fddi-20070618-1-trunk/src/libfddi.c ============================================================================== --- fddi-20070618-1-trunk/src/libfddi.c (original) +++ fddi-20070618-1-trunk/src/libfddi.c Wed Jul 11 21:01:13 2007 @@ -409,22 +409,24 @@ return 0; } +/* FIXME: change into ID scheme */ int fddi_tpu_getname(fddi_tpu_t *tpu, char **name) { if ((!tpu) || (!name)) return EINVAL; - *name = tpu->name; + *name = tpu->id; return 0; } +/* FIXME: change into ID scheme */ int fddi_tpu_getid(fddi_tpu_t *tpu, int *id) { if ((!tpu) || (!id)) return EINVAL; - *id = tpu->id; - return 0; +// *id = tpu->id; + return EINVAL; } int fddi_tpu_gettimestamp(fddi_tpu_t *tpu, int *timestamp) /* FIXME tv */ Modified: fddi-20070618-1-trunk/src/libfddi_libmodbus.c ============================================================================== --- fddi-20070618-1-trunk/src/libfddi_libmodbus.c (original) +++ fddi-20070618-1-trunk/src/libfddi_libmodbus.c Wed Jul 11 21:01:13 2007 @@ -7,83 +7,75 @@ #include #include +static fddi_tpu_t tpu = { + .id_prefix = "dout", + .id_index = -1, + .id_postfix = "", + .id = "dout", + .direction = IN, + .cycletime = (10*1000*1000), +}; + +static fddi_pv_t pv1 = { + .id_prefix = "signal_red", + .id_index = -1, + .id_postfix = "", + .id = "signal_red", + .param_list_head = NULL, + .name = NULL, + .type = BOOL, + .offset = 0, + .bit = 0, +}; + +static fddi_pv_t pv2 = { + .id_prefix = "signal_yellow", + .id_index = -1, + .id_postfix = "", + .id = "signal_yellow", + .param_list_head = NULL, + .name = NULL, + .type = BOOL, + .offset = 0, + .bit = 1, +}; + +static fddi_pv_t pv3 = { + .id_prefix = "signal_green", + .id_index = -1, + .id_postfix = "", + .id = "signal_green", + .param_list_head = NULL, + .name = NULL, + .type = BOOL, + .offset = 0, + .bit = 1, +}; + +int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data); +int fddi_backend_setstate(fddi_iface_t *iface, fddi_state_enum_t state); +int fddi_backend_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd); + int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data) { - fddi_tpu_t *tpu; - fddi_pv_t *pv1, *pv2, *pv3; - printf("parsing configfile: %s\n", configfile); printf("for interface: %s\n", iface->name); - /* - * FIXME: add xml parser here, we configure this hard - * for a first test - */ - - tpu = calloc(1, sizeof(fddi_tpu_t)); - if (!tpu) - goto out; - - pv1 = calloc(1, sizeof(fddi_pv_t)); - if (!tpu) - goto pv1; - - pv2 = calloc(1, sizeof(fddi_pv_t)); - if (!tpu) - goto pv2; - - pv3 = calloc(1, sizeof(fddi_pv_t)); - if (!tpu) - goto pv3; - - iface->tpulist_head = tpu; - tpu->pv_list_head = pv1; - - // pv1->id_prefix = - // pv1->id_index = - // pv1->id_postfix = - // pv1->id = - // pv1->param_list_head = NULL; - // pv1->name = - pv1->type = BOOL; - pv1->offset = 0; - pv1->bit = 0; - pv1->previous = NULL; - pv1->next = pv2; - - // pv2->id_prefix = - // pv2->id_index = - // pv2->id_postfix = - // pv2->id = - // pv2->param_list_head = NULL; - // pv2->name = - pv2->type = BOOL; - pv2->offset = 0; - pv2->bit = 1; - pv2->previous = pv1; - pv2->next = pv3; - - // pv3->id_prefix = - // pv3->id_index = - // pv3->id_postfix = - // pv3->id = - // pv3->param_list_head = NULL; - // pv3->name = - pv3->type = BOOL; - pv3->offset = 0; - pv3->bit = 2; - pv3->previous = pv2; - pv3->next = NULL; + /* FIXME: everything's hardcoded for now, we add an xml parser later */ + + iface->tpulist_head = &tpu; + tpu.pv_list_head = &pv1; + + pv1.next = &pv2; + pv2.previous = &pv1; + pv2.next = &pv3; + pv3.previous = &pv2; + + /* FIXME: setup thread here which handles the cycle */ + + fddi_backend_setstate(iface, STATE_PREOPERATIONAL); return 0; -pv3: - free(pv2); -pv2: - free(pv1); -pv1: - free(tpu); -out: - return ENOMEM; } int fddi_backend_setstate(fddi_iface_t *iface, fddi_state_enum_t state) @@ -97,6 +89,7 @@ case STATE_PREOPERATIONAL: case STATE_OPERATIONAL: case STATE_OPERATION_ERROR: + iface->state = state; retval = 0; break; default: Modified: fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c Wed Jul 11 21:01:13 2007 @@ -3,6 +3,9 @@ #include +static int endme; +static int countdown = 500; + int main(void) { fddi_iface_attr_t modbus0_attr; @@ -10,6 +13,8 @@ int ret; + /* FIXME: we have to agree on a bus start workflow! */ + /* instanciate io_interface */ fddi_iface_attr_init(&modbus0_attr); fddi_iface_attr_setclass(&modbus0_attr, "libfddi_libmodbus.so"); @@ -21,12 +26,27 @@ return ret; } - ret = fddi_iface_configure(&modbus0_iface,"test_fddi_libmodbus1.xml", NULL); + ret = fddi_iface_configure(&modbus0_iface, "test_fddi_libmodbus1.xml", NULL); if (ret) { fprintf(stderr, "fddi_iface_configure() failed\n"); return ret; } + /* TODO: attach callbacks to TPUs here */ + + /* everything is configured, now we can start */ + ret = fddi_iface_cmd(&modbus0_iface, CMD_START); + if (ret) { + fprintf(stderr, "fddi_iface_cmd() failed\n"); + return ret; + } + + while (!endme) { + countdown--; + if (countdown == 0) + endme = 1; + } + /* destruct io_interface */ fddi_iface_destroy(&modbus0_iface); From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:44:49 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:44:49 +0200 Subject: [OSADL-svn-commits] r53 - in fddi-20070618-1-trunk: doc tests Message-ID: <200710020944.l929inUO019862@www.osadl.org> Author: robert Date: Wed Jul 11 21:02:15 2007 New Revision: 53 Log: Added: fddi-20070618-1-trunk/doc/header.txt fddi-20070618-1-trunk/tests/test_fddi_examplebus_tpu_usecase.c Added: fddi-20070618-1-trunk/doc/header.txt ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/doc/header.txt Wed Jul 11 21:02:15 2007 @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ Added: fddi-20070618-1-trunk/tests/test_fddi_examplebus_tpu_usecase.c ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_tpu_usecase.c Wed Jul 11 21:02:15 2007 @@ -0,0 +1,150 @@ +#include +#include + +#include + +int main(void) +{ + fddi_iface_attr_t exb0_attr; + fddi_iface_t exb0_iface; + fddi_tpu_t *tpu; + + 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_configure(&exb0_iface, "config.xml", NULL); + if (ret) { + fprintf(stderr, "fddi_iface_configure() failed\n"); + fddi_iface_destroy(&exb0_iface); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + +/* FIXME pseudocode */ + +int main1(void) +{ + int endme; + pv_engine_t engine; + pv_engine_attr_t engine_attr; + pv_group_t group; + int ret; + + struct pv { + pv_uint32_t voltage; + pv_uint32_t speed; + pv_uint32_t x; + pv_bool_t end_switch_left; + pv_bool_t end_switch_right; + } + + /* instanciate a pv_engine */ + ret = pv_engine_init(&engine, &engine_attr); + if (ret) { + fprintf(stderr, "pv_init() failed\n"); + exit(EXIT_FAILURE); + } + + /* + * now register a pv_group (lockable set of pvs) + * let's take for example a linear drive + */ + + ret = pv_group_init(&group); + if (ret) { + fprintf(stderr, "pv_group_init() failed\n"); + pv_engine_destroy(&engine); + exit(EXIT_FAILURE); + } + + ret = 0; + ret += pv_group_register_uint32(&group, "voltage", &pv.voltage, O_RDWR); + ret += pv_group_register_uint32(&group, "current_speed", &pv.current_speed, O_RDONLY); + ret += pv_group_register_uint32(&group, "current_x", &pv.current_x, O_RDONLY); + ret += pv_group_register_bool(&group, "end_switch_left", &pv.end_switch_left, O_RDONLY); + ret += pv_group_register_bool(&group, "end_switch_right", &pv.end_switch_right, O_RDONLY); + + if (ret != 0) { + fprintf(stderr, "error registering process variables\n"); + pv_group_destroy(&group); + pv_engine_destroy(&engine); + exit(EXIT_FAILURE); + } + + /* example for "active / locking" scenario */ + + while (!endme) { + + /* + * "lock" the pv_group while updating the pvs; note that the + * pv_group contains a list of all affected TPUs, and locking + * means that we "allocate" a tpu (usecount+=1) while accessing it + */ + pv_group_lock(&group, timeout); + + /* starting from here, we have our exclusive sets of TPU buffers */ + + /* yes, printf is not realtime, just for demonstration */ + printf("current speed: \n", pv_uint32_get(&pv.current_speed)); + printf("current x: \n", pv_uint32_get(&pv.current_x)); + printf("end_switch_left: \n", pv_bool_get(&pv.end_switch_left)); + printf("end_switch_right: \n", pv_bool_get(&pv.end_switch_right)); + + /* now calculate the outputs */ + pv_uint32_set(&pv.voltage, 12345); + + /* + * update outputs + */ + pv_group_unlock(&group); + + sleep_until_next_period(); + + } + + /* example for "blocking" scenario, for group */ + + while (!endme) { + /* sleep until one of the TPUs in the group updates */ + pv_group_lock_on_group_change(&group, timeout); + /* do something with the pvs, or find out which pvs have changed */ + pv_group_unlock(&group); + } + + /* example for "blocking" scenario, for pv */ + + while (!endme) { + pv_group_lock_on_pv_change(&group, &pv.current.speed, timeout); + /* ... */ + pv_group_unlock(&group); + } + + /* example for "callback" scenario */ + pv_group_callback_on_group_change(&group, function); + pv_group_callback_on_pv_change(&group, &pv.current.speed, function); + + while (!endme) + sleep(1); + + /* destruct */ + pv_set_destroy(&set); + pv_engine_destroy(&engine); + + return 0; +} + From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:44:57 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:44:57 +0200 Subject: [OSADL-svn-commits] r54 - fddi-20070618-1-trunk/include/osadl Message-ID: <200710020944.l929ivZn019884@www.osadl.org> Author: robert Date: Thu Jul 12 09:28:05 2007 New Revision: 54 Log: split header files Added: fddi-20070618-1-trunk/include/osadl/fddi_device.h fddi-20070618-1-trunk/include/osadl/fddi_iface.h fddi-20070618-1-trunk/include/osadl/fddi_param.h fddi-20070618-1-trunk/include/osadl/fddi_pv.h fddi-20070618-1-trunk/include/osadl/fddi_tpu.h fddi-20070618-1-trunk/include/osadl/fddi_types.h Modified: fddi-20070618-1-trunk/include/osadl/fddi.h 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 Thu Jul 12 09:28:05 2007 @@ -24,198 +24,10 @@ #include -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; - -}; - -typedef enum { - - BOOL, - -} fddi_pv_type_enum_t; - -struct fddi_pv { - - /* FIXME: maybe put into generic list implementation */ - struct fddi_pv *next; - struct fddi_pv *previous; - - char *id_prefix; - int id_index; - char *id_postfix; - char *id; - - fddi_param_t *param_list_head; - fddi_param_t *name; - fddi_pv_type_enum_t type; - unsigned int offset; - unsigned int bit; - -}; - -typedef enum { - - IN, - OUT, - INOUT, - -} fddi_tpu_direction_enum_t; - -struct fddi_tpu { - - /* FIXME: maybe put into generic list implementation */ - struct fddi_tpu *next; - struct fddi_tpu *previous; - - char *id_prefix; - int id_index; - char *id_postfix; - char *id; - - uint64_t cycletime; /* ns */ - fddi_tpu_direction_enum_t direction; - fddi_pv_t *pv_list_head; - unsigned long flags; - char *payload; -}; - -struct fddi_iface_backend_ops { - - int (*configure) (fddi_iface_t *iface, const char *configfile, void *data); - int (*setstate) (fddi_iface_t *iface, fddi_state_enum_t state); - int (*cmd) (fddi_iface_t *iface, fddi_cmd_enum_t cmd); - -}; - -struct fddi_iface { - - char *name; - fddi_state_enum_t state; - - fddi_device_t *devlist_head; - unsigned int nodev; - - fddi_tpu_t *tpulist_head; - unsigned int notpus; - unsigned int nopvs; - - void *backend_lib; - fddi_iface_backend_ops_t backend; - - /* FIXME: add private data for derived backends */ - -}; - -/* 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_configure(fddi_iface_t *iface, const char *configfile, void *data); -extern int fddi_iface_setstate(fddi_iface_t *iface, fddi_state_enum_t state); -extern int fddi_iface_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd); -extern int fddi_iface_getname(fddi_iface_t *iface, char *name, size_t len); -extern int fddi_iface_setname(fddi_iface_t *iface, char *name); -extern int fddi_iface_getnodev(fddi_iface_t *iface); -extern int fddi_iface_getnotpus(fddi_iface_t *iface); -extern int fddi_iface_getnopvs(fddi_iface_t *iface); -extern int fddi_iface_getdevlist(fddi_iface_t *iface, fddi_device_t **dev); -extern int fddi_iface_gettpulist(fddi_iface_t *iface, fddi_tpu_t **tpu); -extern int fddi_iface_getversionstr(fddi_iface_t *iface, const char **version); -extern int fddi_iface_getversion(fddi_iface_t *iface, int *version); -/* - * TODO: split public/private - * TODO: add_tpu(), with counts - * TODO: add_pv(), with counts - */ - -/* 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); +#include +#include +#include +#include +#include #endif Added: fddi-20070618-1-trunk/include/osadl/fddi_device.h ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/include/osadl/fddi_device.h Thu Jul 12 09:28:05 2007 @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_DEVICE_H +#define OSADL_FDDI_DEVICE_H + +#include + +struct fddi_device { + + char *name; + fddi_state_enum_t state; + struct fddi_device *next; + struct fddi_device *previous; + fddi_param_t *param_list; + +}; + +/* fddi_device_t */ +extern int fddi_dev_getnext(fddi_device_t **dev); +extern int fddi_dev_getname(fddi_device_t *dev, char **name); +extern int fddi_dev_getstate(fddi_device_t *dev, fddi_state_enum_t *state); +extern int fddi_dev_getstatestr(fddi_device_t *dev, char **state); +extern int fddi_dev_getphysid(fddi_device_t *dev, int *id); +extern int fddi_dev_getlogicalid(fddi_device_t *dev, int *id); +extern int fddi_dev_getparamlist(fddi_device_t *dev, fddi_param_t **param); +extern int fddi_dev_getnotpus(fddi_device_t *dev); +extern int fddi_dev_read_async(fddi_device_t *dev /* FIXME */); +extern int fddi_dev_write_async(fddi_device_t *dev /* FIXME */); + +#endif + Added: fddi-20070618-1-trunk/include/osadl/fddi_iface.h ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/include/osadl/fddi_iface.h Thu Jul 12 09:28:05 2007 @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_IFACE_H +#define OSADL_FDDI_IFACE_H + +struct fddi_iface_attr { + + char *fddi_class_name; + char *fddi_device_name; + +}; + +struct fddi_iface_backend_ops { + + int (*configure) (fddi_iface_t *iface, const char *configfile, void *data); + int (*setstate) (fddi_iface_t *iface, fddi_state_enum_t state); + int (*cmd) (fddi_iface_t *iface, fddi_cmd_enum_t cmd); + +}; + +struct fddi_iface { + + char *name; + fddi_state_enum_t state; + + fddi_device_t *devlist_head; + unsigned int nodev; + + fddi_tpu_t *tpulist_head; + unsigned int notpus; + unsigned int nopvs; + + void *backend_lib; + fddi_iface_backend_ops_t backend; + + /* FIXME: add private data for derived backends */ + +}; + +/* 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_configure(fddi_iface_t *iface, const char *configfile, void *data); +extern int fddi_iface_setstate(fddi_iface_t *iface, fddi_state_enum_t state); +extern int fddi_iface_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd); +extern int fddi_iface_getname(fddi_iface_t *iface, char *name, size_t len); +extern int fddi_iface_setname(fddi_iface_t *iface, char *name); +extern int fddi_iface_getnodev(fddi_iface_t *iface); +extern int fddi_iface_getnotpus(fddi_iface_t *iface); +extern int fddi_iface_getnopvs(fddi_iface_t *iface); +extern int fddi_iface_getdevlist(fddi_iface_t *iface, fddi_device_t **dev); +extern int fddi_iface_gettpulist(fddi_iface_t *iface, fddi_tpu_t **tpu); +extern int fddi_iface_getversionstr(fddi_iface_t *iface, const char **version); +extern int fddi_iface_getversion(fddi_iface_t *iface, int *version); +/* + * TODO: split public/private + * TODO: add_tpu(), with counts + * TODO: add_pv(), with counts + */ + +#endif + Added: fddi-20070618-1-trunk/include/osadl/fddi_param.h ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/include/osadl/fddi_param.h Thu Jul 12 09:28:05 2007 @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_PARAM_H +#define OSADL_FDDI_PARAM_H + +struct fddi_param { + + char *key; + char *val; + unsigned long flags; + struct fddi_param *next; + struct fddi_param *previous; + +}; + +/* fddi_param_t */ +extern int fddi_param_getnext(fddi_param_t **param); +extern int fddi_param_getkey(fddi_param_t *param, char **val); +extern int fddi_param_getval(fddi_param_t *param, char **val); +extern int fddi_param_getflags(fddi_param_t *param, unsigned long *flags); /* FIXME */ +extern int fddi_param_getnotpus(fddi_param_t *param, int *notpus); + +#endif + Added: fddi-20070618-1-trunk/include/osadl/fddi_pv.h ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/include/osadl/fddi_pv.h Thu Jul 12 09:28:05 2007 @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_PV_H +#define OSADL_FDDI_PV_H + +struct fddi_pv { + + /* FIXME: maybe put into generic list implementation */ + struct fddi_pv *next; + struct fddi_pv *previous; + + char *id_prefix; + int id_index; + char *id_postfix; + char *id; + + fddi_param_t *param_list_head; + fddi_param_t *name; + fddi_pv_type_enum_t type; + unsigned int offset; + unsigned int bit; + +}; + +/* 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_tpu.h ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/include/osadl/fddi_tpu.h Thu Jul 12 09:28:05 2007 @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_TPU_H +#define OSADL_FDDI_TPU_H + +typedef enum { + + IN, + OUT, + INOUT, + +} fddi_tpu_direction_enum_t; + +struct fddi_tpu { + + /* FIXME: maybe put into generic list implementation */ + struct fddi_tpu *next; + struct fddi_tpu *previous; + + char *id_prefix; + int id_index; + char *id_postfix; + char *id; + + uint64_t cycletime; /* ns */ + fddi_tpu_direction_enum_t direction; + fddi_pv_t *pv_list_head; + unsigned long flags; + char *payload; +}; + +/* 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); + +#endif Added: fddi-20070618-1-trunk/include/osadl/fddi_types.h ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/include/osadl/fddi_types.h Thu Jul 12 09:28:05 2007 @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_TYPES_H +#define OSADL_FDDI_TYPES_H + +typedef enum fddi_state_enum fddi_state_enum_t; +typedef enum fddi_cmd_enum fddi_cmd_enum_t; + +enum fddi_state_enum { + + STATE_UNCONFIGURED, /* the device is not configured */ + STATE_MISSING, /* the configuration of the device failed, because it is missing */ + STATE_CONFIG_ERROR, /* the configuration of the device failed, because of wrong config data */ + STATE_PREOPERATIONAL, /* the device is configured, but not working */ + STATE_OPERATIONAL, /* the device is working */ + STATE_OPERATION_ERROR /* the device encountered an error, while it is working */ + +}; + +enum fddi_cmd_enum { + + CMD_START, /* start the device */ + CMD_STOP, /* stop the device */ + CMD_RESET, /* reset the device */ + CMD_IDENTIFY, /* let the device do something to identify itself (like blinking with a LED) */ + CMD_QUITERR /* quit an error of the device, to return to normal operation */ + +}; + +typedef enum { + + BOOL, + +} fddi_pv_type_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; + +#endif + From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:45:01 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:45:01 +0200 Subject: [OSADL-svn-commits] r55 - in fddi-20070618-1-trunk/include/osadl: . attic Message-ID: <200710020945.l929j1ZZ019932@www.osadl.org> Author: robert Date: Thu Jul 12 09:29:51 2007 New Revision: 55 Log: Added: fddi-20070618-1-trunk/include/osadl/attic/ fddi-20070618-1-trunk/include/osadl/attic/fddi_hess.h - copied unchanged from r41, /fddi-20070618-1-trunk/include/osadl/fddi_hess.h Removed: fddi-20070618-1-trunk/include/osadl/fddi_hess.h From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:45:04 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:45:04 +0200 Subject: [OSADL-svn-commits] r56 - in fddi-20070618-1-trunk: . busconfig/Pengutronix include/osadl src tests Message-ID: <200710020945.l929j4Ut020059@www.osadl.org> Author: robert Date: Thu Jul 12 16:23:24 2007 New Revision: 56 Log: split header files and refactoring Added: fddi-20070618-1-trunk/include/osadl/fddi_id.h Modified: fddi-20070618-1-trunk/TODO fddi-20070618-1-trunk/busconfig/Pengutronix/modbus-example.xml fddi-20070618-1-trunk/include/osadl/fddi_device.h fddi-20070618-1-trunk/include/osadl/fddi_iface.h fddi-20070618-1-trunk/include/osadl/fddi_param.h fddi-20070618-1-trunk/include/osadl/fddi_pv.h fddi-20070618-1-trunk/include/osadl/fddi_tpu.h fddi-20070618-1-trunk/include/osadl/fddi_types.h fddi-20070618-1-trunk/src/libfddi.c fddi-20070618-1-trunk/src/libfddi_libmodbus.c fddi-20070618-1-trunk/tests/test_fddi_examplebus1.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_attach_backend.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_identify.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_quiterr.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_reset.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_start.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_stop.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_configure.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_configerror.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_missing.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_operation_error.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_operational.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_preoperational.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_unconfigured.c fddi-20070618-1-trunk/tests/test_fddi_examplebus_tpu_usecase.c fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c fddi-20070618-1-trunk/tests/test_fddi_versionstr.c Modified: fddi-20070618-1-trunk/TODO ============================================================================== --- fddi-20070618-1-trunk/TODO (original) +++ fddi-20070618-1-trunk/TODO Thu Jul 12 16:23:24 2007 @@ -3,6 +3,3 @@ [ ] invent performant data transport model with persistence - - - Modified: fddi-20070618-1-trunk/busconfig/Pengutronix/modbus-example.xml ============================================================================== --- fddi-20070618-1-trunk/busconfig/Pengutronix/modbus-example.xml (original) +++ fddi-20070618-1-trunk/busconfig/Pengutronix/modbus-example.xml Thu Jul 12 16:23:24 2007 @@ -10,7 +10,7 @@ Controller PC - + Ethernet @@ -22,6 +22,7 @@ + master @@ -33,7 +34,7 @@ Wago IO Box - + Ethernet @@ -45,6 +46,7 @@ + slave Modified: fddi-20070618-1-trunk/include/osadl/fddi_device.h ============================================================================== --- fddi-20070618-1-trunk/include/osadl/fddi_device.h (original) +++ fddi-20070618-1-trunk/include/osadl/fddi_device.h Thu Jul 12 16:23:24 2007 @@ -23,15 +23,22 @@ #define OSADL_FDDI_DEVICE_H #include +#include struct fddi_device { - char *name; + /* public */ + fddi_id_t id; fddi_state_enum_t state; + + /* private */ struct fddi_device *next; struct fddi_device *previous; + fddi_param_t *param_list; + void *priv; + }; /* fddi_device_t */ Added: fddi-20070618-1-trunk/include/osadl/fddi_id.h ============================================================================== --- (empty file) +++ fddi-20070618-1-trunk/include/osadl/fddi_id.h Thu Jul 12 16:23:24 2007 @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_ID_H +#define OSADL_FDDI_ID_H + +#include + +struct fddi_id { + + /* public */ + + /* private */ + char *prefix; + int index; + char *postfix; + + char *id_as_string; + size_t id_as_str_len; + + void *priv; +}; + +extern int fddi_id_init(fddi_id_t *fddi_id, const char *prefix, int index, const char *postfix); +extern int fddi_id_getid(fddi_id_t *fddi_id, char *id_string, size_t len); +extern int fddi_id_destroy(fddi_id_t *fddi_id); + +#endif + Modified: fddi-20070618-1-trunk/include/osadl/fddi_iface.h ============================================================================== --- fddi-20070618-1-trunk/include/osadl/fddi_iface.h (original) +++ fddi-20070618-1-trunk/include/osadl/fddi_iface.h Thu Jul 12 16:23:24 2007 @@ -24,8 +24,11 @@ struct fddi_iface_attr { - char *fddi_class_name; - char *fddi_device_name; + /* public */ + char *path; + fddi_id_t id; + + char *fddi_class_name; /* FIXME */ }; @@ -39,27 +42,29 @@ struct fddi_iface { - char *name; + /* public */ + fddi_id_t id; fddi_state_enum_t state; + /* private */ fddi_device_t *devlist_head; unsigned int nodev; fddi_tpu_t *tpulist_head; unsigned int notpus; + unsigned int nopvs; void *backend_lib; fddi_iface_backend_ops_t backend; - /* FIXME: add private data for derived backends */ - + void *priv; }; /* fddi_iface_attr_t */ extern int fddi_iface_attr_init(fddi_iface_attr_t *attr); extern int fddi_iface_attr_setclass(fddi_iface_attr_t *attr, char *fddi_class_name); -extern int fddi_iface_attr_setdevice(fddi_iface_attr_t *attr, char *device_name); +extern int fddi_iface_attr_setid(fddi_iface_attr_t *attr, const char *path, fddi_id_t device_id); /* fddi_iface_t */ extern int fddi_iface_init(fddi_iface_t *iface, fddi_iface_attr_t *attr); @@ -67,8 +72,8 @@ extern int fddi_iface_configure(fddi_iface_t *iface, const char *configfile, void *data); extern int fddi_iface_setstate(fddi_iface_t *iface, fddi_state_enum_t state); extern int fddi_iface_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd); -extern int fddi_iface_getname(fddi_iface_t *iface, char *name, size_t len); -extern int fddi_iface_setname(fddi_iface_t *iface, char *name); +extern int fddi_iface_getid(fddi_iface_t *iface, fddi_id_t *id); +extern int fddi_iface_setid(fddi_iface_t *iface, fddi_id_t id); extern int fddi_iface_getnodev(fddi_iface_t *iface); extern int fddi_iface_getnotpus(fddi_iface_t *iface); extern int fddi_iface_getnopvs(fddi_iface_t *iface); Modified: fddi-20070618-1-trunk/include/osadl/fddi_param.h ============================================================================== --- fddi-20070618-1-trunk/include/osadl/fddi_param.h (original) +++ fddi-20070618-1-trunk/include/osadl/fddi_param.h Thu Jul 12 16:23:24 2007 @@ -24,12 +24,17 @@ struct fddi_param { + /* public */ char *key; char *val; unsigned long flags; + + /* private */ struct fddi_param *next; struct fddi_param *previous; + void *priv; + }; /* fddi_param_t */ Modified: fddi-20070618-1-trunk/include/osadl/fddi_pv.h ============================================================================== --- fddi-20070618-1-trunk/include/osadl/fddi_pv.h (original) +++ fddi-20070618-1-trunk/include/osadl/fddi_pv.h Thu Jul 12 16:23:24 2007 @@ -24,21 +24,19 @@ struct fddi_pv { - /* FIXME: maybe put into generic list implementation */ + /* public */ + fddi_id_t id; + fddi_param_t *name; + fddi_pv_type_enum_t type; + + /* private */ struct fddi_pv *next; struct fddi_pv *previous; - - char *id_prefix; - int id_index; - char *id_postfix; - char *id; - fddi_param_t *param_list_head; - fddi_param_t *name; - fddi_pv_type_enum_t type; unsigned int offset; unsigned int bit; + void *priv; }; /* fddi_pv_t */ Modified: fddi-20070618-1-trunk/include/osadl/fddi_tpu.h ============================================================================== --- fddi-20070618-1-trunk/include/osadl/fddi_tpu.h (original) +++ fddi-20070618-1-trunk/include/osadl/fddi_tpu.h Thu Jul 12 16:23:24 2007 @@ -32,26 +32,25 @@ struct fddi_tpu { - /* FIXME: maybe put into generic list implementation */ - struct fddi_tpu *next; - struct fddi_tpu *previous; - - char *id_prefix; - int id_index; - char *id_postfix; - char *id; - - uint64_t cycletime; /* ns */ + /* public */ + fddi_id_t id; + uint64_t cycletime; /* ns */ fddi_tpu_direction_enum_t direction; + + /* private */ + struct fddi_tpu *next; /* TODO: generic list */ + struct fddi_tpu *previous; fddi_pv_t *pv_list_head; unsigned long flags; char *payload; + + void *priv; + }; /* 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_getid(fddi_tpu_t *tpu, fddi_id_t *id); extern int fddi_tpu_gettimestamp(fddi_tpu_t *tpu, int *timestamp); /* FIXME tv */ extern int fddi_tpu_getflags(fddi_tpu_t *tpu, unsigned long *flags); extern int fddi_tpu_setcallback(fddi_tpu_t *tpu, int(*tpu_callback)(fddi_tpu_t *tpu)); Modified: fddi-20070618-1-trunk/include/osadl/fddi_types.h ============================================================================== --- fddi-20070618-1-trunk/include/osadl/fddi_types.h (original) +++ fddi-20070618-1-trunk/include/osadl/fddi_types.h Thu Jul 12 16:23:24 2007 @@ -52,6 +52,7 @@ } fddi_pv_type_enum_t; +typedef struct fddi_id fddi_id_t; typedef struct fddi_param fddi_param_t; typedef struct fddi_device fddi_device_t; typedef struct fddi_iface_attr fddi_iface_attr_t; Modified: fddi-20070618-1-trunk/src/libfddi.c ============================================================================== --- fddi-20070618-1-trunk/src/libfddi.c (original) +++ fddi-20070618-1-trunk/src/libfddi.c Thu Jul 12 16:23:24 2007 @@ -44,28 +44,28 @@ return 0; } -int fddi_iface_attr_setclass(fddi_iface_attr_t *attr, char *fddi_class_name) +int fddi_iface_attr_setclass(fddi_iface_attr_t *attr, char *class) { - if ((!attr) || (!fddi_class_name)) + if ((!attr) || (!class)) return EINVAL; - attr->fddi_class_name = fddi_class_name; + attr->fddi_class_name = strdup(class); + /* FIXME: where to free() this memory? */ return 0; } -int fddi_iface_attr_setdevice(fddi_iface_attr_t *attr, char *fddi_device_name) +int fddi_iface_attr_setid(fddi_iface_attr_t *attr, const char *path, fddi_id_t id) { if (!attr) return EINVAL; - attr->fddi_device_name = malloc(strlen(fddi_device_name)); - if (!attr->fddi_device_name) - return ENOMEM; + if (path) + attr->path = strdup(path); - strcpy(attr->fddi_device_name, fddi_device_name); + memcpy(&attr->id, &id, sizeof(fddi_id_t)); - return 0; + return EINVAL; } /* fddi_iface_t */ @@ -76,12 +76,12 @@ if ((!iface) || (!attr)) return EINVAL; - if ((attr->fddi_class_name == NULL) || (attr->fddi_device_name == NULL)) + if (attr->fddi_class_name == NULL) return EINVAL; /* initialize instance variables */ memset(iface, 0, sizeof(fddi_iface_t)); - iface->name = attr->fddi_device_name; + memcpy(&iface->id, &attr->id, sizeof(fddi_id_t)); /* attach to backend library */ @@ -137,9 +137,6 @@ if (!iface) return EINVAL; - if (iface->name != NULL) - free(iface->name); - pthread_mutex_lock(<_dl_mutex); lt_dlclose(iface->backend_lib); pthread_mutex_unlock(<_dl_mutex); @@ -180,29 +177,22 @@ return iface->backend.cmd(iface, cmd); } -int fddi_iface_getname(fddi_iface_t *iface, char *name, size_t len) +int fddi_iface_getid(fddi_iface_t *iface, fddi_id_t *id) { - if ((!iface) || (!name)) + if ((!iface) || (!id)) return EINVAL; - strncpy(name, iface->name, len); + memcpy(id, &iface->id, sizeof(fddi_id_t)); return 0; } -int fddi_iface_setname(fddi_iface_t *iface, char *name) +int fddi_iface_setid(fddi_iface_t *iface, fddi_id_t id) { - if ((!iface) || (!name)) + if (!iface) return EINVAL; - if (iface->name != NULL) - free(iface->name); - - iface->name = malloc(strlen(name)+1); - if (!iface->name) - return ENOMEM; - - strncpy(iface->name, name, strlen(name)+1); + memcpy(&iface->id, &id, sizeof(fddi_id_t)); return 0; } @@ -276,12 +266,13 @@ return 0; } -int fddi_dev_getname(fddi_device_t *dev, char **name) +int fddi_dev_getid(fddi_device_t *dev, fddi_id_t *id) { - if ((!dev) || (!name)) + if ((!dev) || (!id)) return EINVAL; - *name = dev->name; + memcpy(id, &dev->id, sizeof(fddi_id_t)); + return 0; } @@ -409,24 +400,14 @@ return 0; } -/* FIXME: change into ID scheme */ -int fddi_tpu_getname(fddi_tpu_t *tpu, char **name) +int fddi_tpu_getid(fddi_tpu_t *tpu, fddi_id_t *id) { - if ((!tpu) || (!name)) + if ((!tpu) || (!id)) return EINVAL; - *name = tpu->id; - return 0; -} + memcpy(id, &tpu->id, sizeof(fddi_id_t)); -/* FIXME: change into ID scheme */ -int fddi_tpu_getid(fddi_tpu_t *tpu, int *id) -{ - if ((!tpu) || (!id)) - return EINVAL; - -// *id = tpu->id; - return EINVAL; + return 0; } int fddi_tpu_gettimestamp(fddi_tpu_t *tpu, int *timestamp) /* FIXME tv */ @@ -489,12 +470,88 @@ return 0; } -int fddi_pv_getname(fddi_pv_t *pv, char **name) +int fddi_pv_getid(fddi_pv_t *pv, fddi_id_t *id) { - if ((!pv) || (!name)) + if ((!pv) || (!id)) return EINVAL; - *name = NULL; + memcpy(id, &pv->id, sizeof(fddi_id_t)); + + return 0; +} + +/* fddi_id_t */ + +int fddi_id_init(fddi_id_t *fddi_id, const char *prefix, int index, const char *postfix) +{ + int prefix_len; + int index_len; + int postfix_len; + char index_as_string[30]; /* FIXME: find out max strlen of printf(int) */ + + memset(fddi_id, 0, sizeof(fddi_id_t)); + + /* FIXME: is it allowed to have things without index? */ + snprintf(index_as_string, 30, "%i", index); + index_len = strlen(index_as_string); + + if (prefix) { + prefix_len = strlen(prefix); + fddi_id->prefix = strdup(prefix); + if (!fddi_id->prefix) + goto prefix_err; + } else + prefix_len = 0; + + if (postfix) { + postfix_len = strlen(postfix); + fddi_id->postfix = strdup(postfix); + if (!fddi_id->postfix) + goto postfix_err; + } else + postfix_len = 0; + + + fddi_id->id_as_str_len = prefix_len + index_len + postfix_len; + + fddi_id->id_as_string = malloc(fddi_id->id_as_str_len + 1); + if (!fddi_id->id_as_string) + goto id_as_str_err; + + sprintf(fddi_id->id_as_string, "%s%s%s", + fddi_id->prefix ? fddi_id->prefix : "", + index_as_string ? index_as_string : "", + fddi_id->postfix ? fddi_id->postfix: ""); + + return 0; + +id_as_str_err: + fddi_id->id_as_str_len = 0; + free(fddi_id->postfix); + fddi_id->postfix = NULL; +postfix_err: + free(fddi_id->prefix); + fddi_id->prefix = NULL; +prefix_err: + return ENOMEM; +} + +int fddi_id_getid(fddi_id_t *fddi_id, char *id_string, size_t len) +{ + if (len < fddi_id->id_as_str_len) + return EINVAL; /* FIXME */ + + strcpy(id_string, fddi_id->id_as_string); + + return 0; +} + +int fddi_id_destroy(fddi_id_t *fddi_id) +{ + free(fddi_id->prefix); + free(fddi_id->postfix); + free(fddi_id->id_as_string); + return 0; } Modified: fddi-20070618-1-trunk/src/libfddi_libmodbus.c ============================================================================== --- fddi-20070618-1-trunk/src/libfddi_libmodbus.c (original) +++ fddi-20070618-1-trunk/src/libfddi_libmodbus.c Thu Jul 12 16:23:24 2007 @@ -8,19 +8,21 @@ #include static fddi_tpu_t tpu = { - .id_prefix = "dout", - .id_index = -1, - .id_postfix = "", - .id = "dout", + .id = { + .prefix = "dout", + .index = -1, + .postfix = "", + }, .direction = IN, .cycletime = (10*1000*1000), }; static fddi_pv_t pv1 = { - .id_prefix = "signal_red", - .id_index = -1, - .id_postfix = "", - .id = "signal_red", + .id = { + .prefix = "signal_red", + .index = -1, + .postfix = "", + }, .param_list_head = NULL, .name = NULL, .type = BOOL, @@ -29,10 +31,11 @@ }; static fddi_pv_t pv2 = { - .id_prefix = "signal_yellow", - .id_index = -1, - .id_postfix = "", - .id = "signal_yellow", + .id = { + .prefix = "signal_yellow", + .index = -1, + .postfix = "", + }, .param_list_head = NULL, .name = NULL, .type = BOOL, @@ -41,10 +44,11 @@ }; static fddi_pv_t pv3 = { - .id_prefix = "signal_green", - .id_index = -1, - .id_postfix = "", - .id = "signal_green", + .id = { + .prefix = "signal_green", + .index = -1, + .postfix = "", + }, .param_list_head = NULL, .name = NULL, .type = BOOL, @@ -59,7 +63,7 @@ int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data) { printf("parsing configfile: %s\n", configfile); - printf("for interface: %s\n", iface->name); + printf("for interface: %s\n", iface->id.id_as_string); /* FIXME private */ /* FIXME: everything's hardcoded for now, we add an xml parser later */ Modified: fddi-20070618-1-trunk/tests/test_fddi_examplebus1.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_examplebus1.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus1.c Thu Jul 12 16:23:24 2007 @@ -22,6 +22,10 @@ fddi_iface_attr_t exb0_attr; fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; fddi_tpu_t *tpu; fddi_pv_t *pv; /* FIXME: pv_t ? */ @@ -33,7 +37,7 @@ /* 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_attr_setid(&exb0_attr, NULL, exb0_id); fddi_iface_init(&exb0_iface, &exb0_attr); Modified: fddi-20070618-1-trunk/tests/test_fddi_examplebus_attach_backend.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_examplebus_attach_backend.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_attach_backend.c Thu Jul 12 16:23:24 2007 @@ -8,13 +8,17 @@ { fddi_iface_attr_t exb0_attr; fddi_iface_t exb0_iface; + fddi_id_t exb0id = { + .prefix="exb", + .index=0, + }; int ret; /* instanciate io_interface */ fddi_iface_attr_init(&exb0_attr); fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); - fddi_iface_attr_setdevice(&exb0_attr, "exb0"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0id); ret = fddi_iface_init(&exb0_iface, &exb0_attr); if (ret) Modified: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_identify.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_identify.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_identify.c Thu Jul 12 16:23:24 2007 @@ -7,13 +7,17 @@ { fddi_iface_attr_t exb0_attr; fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; int ret; /* instanciate io_interface */ fddi_iface_attr_init(&exb0_attr); fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); - fddi_iface_attr_setdevice(&exb0_attr, "exb0"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); ret = fddi_iface_init(&exb0_iface, &exb0_attr); if (ret) { Modified: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_quiterr.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_quiterr.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_quiterr.c Thu Jul 12 16:23:24 2007 @@ -7,13 +7,17 @@ { fddi_iface_attr_t exb0_attr; fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; int ret; /* instanciate io_interface */ fddi_iface_attr_init(&exb0_attr); fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); - fddi_iface_attr_setdevice(&exb0_attr, "exb0"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); ret = fddi_iface_init(&exb0_iface, &exb0_attr); if (ret) { Modified: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_reset.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_reset.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_reset.c Thu Jul 12 16:23:24 2007 @@ -7,13 +7,17 @@ { fddi_iface_attr_t exb0_attr; fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; int ret; /* instanciate io_interface */ fddi_iface_attr_init(&exb0_attr); fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); - fddi_iface_attr_setdevice(&exb0_attr, "exb0"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); ret = fddi_iface_init(&exb0_iface, &exb0_attr); if (ret) { Modified: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_start.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_start.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_start.c Thu Jul 12 16:23:24 2007 @@ -7,13 +7,17 @@ { fddi_iface_attr_t exb0_attr; fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; int ret; /* instanciate io_interface */ fddi_iface_attr_init(&exb0_attr); fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); - fddi_iface_attr_setdevice(&exb0_attr, "exb0"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); ret = fddi_iface_init(&exb0_iface, &exb0_attr); if (ret) { Modified: fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_stop.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_stop.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_cmd_stop.c Thu Jul 12 16:23:24 2007 @@ -7,13 +7,17 @@ { fddi_iface_attr_t exb0_attr; fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; int ret; /* instanciate io_interface */ fddi_iface_attr_init(&exb0_attr); fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); - fddi_iface_attr_setdevice(&exb0_attr, "exb0"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); ret = fddi_iface_init(&exb0_iface, &exb0_attr); if (ret) { Modified: fddi-20070618-1-trunk/tests/test_fddi_examplebus_configure.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_examplebus_configure.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_configure.c Thu Jul 12 16:23:24 2007 @@ -7,13 +7,17 @@ { fddi_iface_attr_t exb0_attr; fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; int ret; /* instanciate io_interface */ fddi_iface_attr_init(&exb0_attr); fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); - fddi_iface_attr_setdevice(&exb0_attr, "exb0"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); ret = fddi_iface_init(&exb0_iface, &exb0_attr); if (ret) { Modified: fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_configerror.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_configerror.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_configerror.c Thu Jul 12 16:23:24 2007 @@ -7,13 +7,17 @@ { fddi_iface_attr_t exb0_attr; fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; int ret; /* instanciate io_interface */ fddi_iface_attr_init(&exb0_attr); fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); - fddi_iface_attr_setdevice(&exb0_attr, "exb0"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); ret = fddi_iface_init(&exb0_iface, &exb0_attr); if (ret) { Modified: fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_missing.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_missing.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_missing.c Thu Jul 12 16:23:24 2007 @@ -7,13 +7,17 @@ { fddi_iface_attr_t exb0_attr; fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; int ret; /* instanciate io_interface */ fddi_iface_attr_init(&exb0_attr); fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); - fddi_iface_attr_setdevice(&exb0_attr, "exb0"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); ret = fddi_iface_init(&exb0_iface, &exb0_attr); if (ret) { Modified: fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_operation_error.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_operation_error.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_operation_error.c Thu Jul 12 16:23:24 2007 @@ -7,13 +7,17 @@ { fddi_iface_attr_t exb0_attr; fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; int ret; /* instanciate io_interface */ fddi_iface_attr_init(&exb0_attr); fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); - fddi_iface_attr_setdevice(&exb0_attr, "exb0"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); ret = fddi_iface_init(&exb0_iface, &exb0_attr); if (ret) { Modified: fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_operational.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_operational.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_operational.c Thu Jul 12 16:23:24 2007 @@ -7,13 +7,17 @@ { fddi_iface_attr_t exb0_attr; fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; int ret; /* instanciate io_interface */ fddi_iface_attr_init(&exb0_attr); fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); - fddi_iface_attr_setdevice(&exb0_attr, "exb0"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); ret = fddi_iface_init(&exb0_iface, &exb0_attr); if (ret) { Modified: fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_preoperational.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_preoperational.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_preoperational.c Thu Jul 12 16:23:24 2007 @@ -7,13 +7,17 @@ { fddi_iface_attr_t exb0_attr; fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; int ret; /* instanciate io_interface */ fddi_iface_attr_init(&exb0_attr); fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); - fddi_iface_attr_setdevice(&exb0_attr, "exb0"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); ret = fddi_iface_init(&exb0_iface, &exb0_attr); if (ret) { Modified: fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_unconfigured.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_unconfigured.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_setstate_unconfigured.c Thu Jul 12 16:23:24 2007 @@ -7,13 +7,17 @@ { fddi_iface_attr_t exb0_attr; fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; int ret; /* instanciate io_interface */ fddi_iface_attr_init(&exb0_attr); fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); - fddi_iface_attr_setdevice(&exb0_attr, "exb0"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); ret = fddi_iface_init(&exb0_iface, &exb0_attr); if (ret) { Modified: fddi-20070618-1-trunk/tests/test_fddi_examplebus_tpu_usecase.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_examplebus_tpu_usecase.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_examplebus_tpu_usecase.c Thu Jul 12 16:23:24 2007 @@ -8,13 +8,17 @@ fddi_iface_attr_t exb0_attr; fddi_iface_t exb0_iface; fddi_tpu_t *tpu; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; int ret; /* instanciate io_interface */ fddi_iface_attr_init(&exb0_attr); fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); - fddi_iface_attr_setdevice(&exb0_attr, "exb0"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); ret = fddi_iface_init(&exb0_iface, &exb0_attr); if (ret) { Modified: fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c Thu Jul 12 16:23:24 2007 @@ -6,19 +6,22 @@ static int endme; static int countdown = 500; +/* FIXME: we have to agree on a bus start workflow! */ + int main(void) { fddi_iface_attr_t modbus0_attr; fddi_iface_t modbus0_iface; + fddi_id_t modbus0_id; int ret; - /* FIXME: we have to agree on a bus start workflow! */ + fddi_id_init(&modbus0_id, "modbus", 0, NULL); /* instanciate io_interface */ fddi_iface_attr_init(&modbus0_attr); fddi_iface_attr_setclass(&modbus0_attr, "libfddi_libmodbus.so"); - fddi_iface_attr_setdevice(&modbus0_attr, "demosystem.controller.modbus0"); + fddi_iface_attr_setid(&modbus0_attr, "demosystem.controller", modbus0_id); ret = fddi_iface_init(&modbus0_iface, &modbus0_attr); if (ret) { Modified: fddi-20070618-1-trunk/tests/test_fddi_versionstr.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_versionstr.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_versionstr.c Thu Jul 12 16:23:24 2007 @@ -11,11 +11,15 @@ int ret; const char *version; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; /* instanciate io_interface */ fddi_iface_attr_init(&exb0_attr); fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); - fddi_iface_attr_setdevice(&exb0_attr, "exb0"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); ret = fddi_iface_init(&exb0_iface, &exb0_attr); if (ret) From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:45:14 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:45:14 +0200 Subject: [OSADL-svn-commits] r57 - in fddi-20070618-1-trunk: include/osadl src tests Message-ID: <200710020945.l929jEKB020292@www.osadl.org> Author: robert Date: Thu Jul 12 17:49:32 2007 New Revision: 57 Log: more modbus additions (not working yet) Modified: fddi-20070618-1-trunk/include/osadl/fddi_tpu.h fddi-20070618-1-trunk/src/libfddi.c fddi-20070618-1-trunk/src/libfddi_libmodbus.c fddi-20070618-1-trunk/tests/GNUmakefile.am fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c Modified: fddi-20070618-1-trunk/include/osadl/fddi_tpu.h ============================================================================== --- fddi-20070618-1-trunk/include/osadl/fddi_tpu.h (original) +++ fddi-20070618-1-trunk/include/osadl/fddi_tpu.h Thu Jul 12 17:49:32 2007 @@ -40,10 +40,14 @@ /* private */ struct fddi_tpu *next; /* TODO: generic list */ struct fddi_tpu *previous; + fddi_pv_t *pv_list_head; unsigned long flags; char *payload; + void *callback_arg; + int (*callback) (fddi_tpu_t *tpu, void *arg); + void *priv; }; @@ -53,9 +57,9 @@ extern int fddi_tpu_getid(fddi_tpu_t *tpu, fddi_id_t *id); extern int fddi_tpu_gettimestamp(fddi_tpu_t *tpu, int *timestamp); /* FIXME tv */ extern int fddi_tpu_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_setcallback(fddi_tpu_t *tpu, int(*tpu_callback)(fddi_tpu_t *tpu, void *arg), void *arg); extern int fddi_tpu_getpvlist(fddi_tpu_t *tpu, fddi_pv_t **pv); extern int fddi_tpu_getpayload(fddi_tpu_t *tpu, char **payload); -extern int fddi_tpu_send(fddi_tpu_t *tpu); +extern int fddi_tpu_transfer(fddi_tpu_t *tpu); #endif Modified: fddi-20070618-1-trunk/src/libfddi.c ============================================================================== --- fddi-20070618-1-trunk/src/libfddi.c (original) +++ fddi-20070618-1-trunk/src/libfddi.c Thu Jul 12 17:49:32 2007 @@ -428,12 +428,15 @@ return 0; } -int fddi_tpu_setcallback(fddi_tpu_t *tpu, int(*tpu_callback)(fddi_tpu_t *tpu)) +int fddi_tpu_setcallback(fddi_tpu_t *tpu, int(*tpu_callback)(fddi_tpu_t *tpu, void *arg), void *arg) { if ((!tpu) || (!tpu_callback)) return EINVAL; - return -1; /* FIXME: not implemented yet */ + tpu->callback = tpu_callback; + tpu->callback_arg = arg; + + return 0; } int fddi_tpu_getpvlist(fddi_tpu_t *tpu, fddi_pv_t **pv) @@ -454,9 +457,19 @@ return 0; } -int fddi_tpu_send(fddi_tpu_t *tpu) +int fddi_tpu_transfer(fddi_tpu_t *tpu) { - return -1; /* FIXME: not implemented yet */ + if ((tpu->direction == IN) || (tpu->direction == INOUT)) { + + + } + + if ((tpu->direction == OUT) || (tpu->direction == INOUT)) { + + + } + + return 0; } Modified: fddi-20070618-1-trunk/src/libfddi_libmodbus.c ============================================================================== --- fddi-20070618-1-trunk/src/libfddi_libmodbus.c (original) +++ fddi-20070618-1-trunk/src/libfddi_libmodbus.c Thu Jul 12 17:49:32 2007 @@ -3,8 +3,12 @@ */ #include +#include +#include #include #include +#include + #include static fddi_tpu_t tpu = { @@ -13,7 +17,7 @@ .index = -1, .postfix = "", }, - .direction = IN, + .direction = OUT, .cycletime = (10*1000*1000), }; @@ -56,12 +60,27 @@ .bit = 1, }; +/* modbus cycle timer */ + +static timer_t modbus_timer; +static struct sigevent modbus_timer_event; +static struct itimerspec modbus_timer_spec; + +void flagset_sig_handler(sigval_t sigval) +{ + return; +} + +/* fddi backend functions */ + int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data); int fddi_backend_setstate(fddi_iface_t *iface, fddi_state_enum_t state); int fddi_backend_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd); int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data) { + int ret; + printf("parsing configfile: %s\n", configfile); printf("for interface: %s\n", iface->id.id_as_string); /* FIXME private */ @@ -75,7 +94,19 @@ pv2.next = &pv3; pv3.previous = &pv2; - /* FIXME: setup thread here which handles the cycle */ + /* modbus has no hardware bus cycle, emulate one */ + + modbus_timer_event.sigev_notify = SIGEV_THREAD; + modbus_timer_event.sigev_notify_function = flagset_sig_handler; + modbus_timer_event.sigev_notify_attributes = NULL; + modbus_timer_event.sigev_value.sival_ptr = NULL; + + if ((ret = timer_create(CLOCK_REALTIME, &modbus_timer_event, &modbus_timer)) < 0 ) { + perror("timer create"); + return -1; + } + + /* we are ready now and go into preoperational state */ fddi_backend_setstate(iface, STATE_PREOPERATIONAL); @@ -108,8 +139,37 @@ int retval = -1; switch (cmd) { + case CMD_START: + + /* FIXME */ + modbus_timer_spec.it_value.tv_sec = 1; + modbus_timer_spec.it_value.tv_nsec = 0; + modbus_timer_spec.it_interval.tv_sec = 0; + modbus_timer_spec.it_interval.tv_nsec = 500*1000*1000; + + if ((retval = timer_settime(modbus_timer, 0, &modbus_timer_spec, NULL)) < 0 ) { + perror("timer settime"); + return -1; + } + + retval = 0; + break; + case CMD_STOP: + + modbus_timer_spec.it_value.tv_sec = 0; + modbus_timer_spec.it_value.tv_nsec = 0; + modbus_timer_spec.it_interval.tv_sec = 0; + modbus_timer_spec.it_interval.tv_nsec = 0; + + if ((retval = timer_settime(modbus_timer, 0, &modbus_timer_spec, NULL)) < 0 ) { + perror("timer settime"); + return -1; + } + + + case CMD_RESET: case CMD_IDENTIFY: case CMD_QUITERR: @@ -117,6 +177,7 @@ break; default: break; + } return retval; Modified: fddi-20070618-1-trunk/tests/GNUmakefile.am ============================================================================== --- fddi-20070618-1-trunk/tests/GNUmakefile.am (original) +++ fddi-20070618-1-trunk/tests/GNUmakefile.am Thu Jul 12 17:49:32 2007 @@ -165,6 +165,7 @@ test_fddi_libmodbus1.c test_fddi_libmodbus1_LDADD = \ + -lpthread -lrt \ $(top_builddir)/src/libfddi_libmodbus.la test_fddi_libmodbus1_DEPENDENCIES = \ Modified: fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c Thu Jul 12 17:49:32 2007 @@ -1,21 +1,54 @@ +#include #include #include +#include #include static int endme; -static int countdown = 500; + +void signalhandler(int sig) +{ + if (sig == SIGPIPE) + return; + if (sig == SIGHUP) { + fprintf(stderr, "SIGHUP received\n"); + } + if (sig == SIGTERM || sig == SIGINT) { + fprintf(stderr, "ctrl-c pressed, shutting down\n"); + endme = 1; + } +} + + +int tpu_callback(fddi_tpu_t *tpu, void *arg) +{ + printf("callback\n"); + return 0; +} /* FIXME: we have to agree on a bus start workflow! */ int main(void) { + struct sigaction action; + fddi_iface_attr_t modbus0_attr; fddi_iface_t modbus0_iface; fddi_id_t modbus0_id; + fddi_tpu_t *tpu; int ret; + /* setup signal handler */ + action.sa_handler = signalhandler; + sigemptyset(&action.sa_mask); + action.sa_flags = 0; + sigaction(SIGTERM, &action, 0); /* catches kill from the shell */ + sigaction(SIGINT, &action, 0); /* catches Ctrl-C from the shell */ + sigaction(SIGPIPE, &action, 0); /* catches Broken Pipe exception */ + sigaction(SIGHUP, &action, 0); /* catches HUP */ + fddi_id_init(&modbus0_id, "modbus", 0, NULL); /* instanciate io_interface */ @@ -35,7 +68,12 @@ return ret; } - /* TODO: attach callbacks to TPUs here */ + /* attach callbacks to TPUs */ + fddi_iface_gettpulist(&modbus0_iface, &tpu); + while (tpu) { + fddi_tpu_setcallback(tpu, tpu_callback, NULL); + fddi_tpu_getnext(&tpu); + } /* everything is configured, now we can start */ ret = fddi_iface_cmd(&modbus0_iface, CMD_START); @@ -44,11 +82,9 @@ return ret; } - while (!endme) { - countdown--; - if (countdown == 0) - endme = 1; - } + printf("entering main loop, press ctrl-c to end\n"); + while (!endme) + sleep(1); /* destruct io_interface */ fddi_iface_destroy(&modbus0_iface); From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:45:17 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:45:17 +0200 Subject: [OSADL-svn-commits] r58 - in fddi-20070618-1-trunk: include/osadl src tests Message-ID: <200710020945.l929jHsf020328@www.osadl.org> Author: robert Date: Fri Jul 13 11:00:53 2007 New Revision: 58 Log: first version which makes noise on the modbus coupler Modified: fddi-20070618-1-trunk/include/osadl/fddi_iface.h fddi-20070618-1-trunk/include/osadl/fddi_tpu.h fddi-20070618-1-trunk/src/libfddi.c fddi-20070618-1-trunk/src/libfddi_libmodbus.c fddi-20070618-1-trunk/tests/libfddi_examplebus.c fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c Modified: fddi-20070618-1-trunk/include/osadl/fddi_iface.h ============================================================================== --- fddi-20070618-1-trunk/include/osadl/fddi_iface.h (original) +++ fddi-20070618-1-trunk/include/osadl/fddi_iface.h Fri Jul 13 11:00:53 2007 @@ -34,6 +34,8 @@ struct fddi_iface_backend_ops { + int (*init) (fddi_iface_t *iface); + int (*destroy) (fddi_iface_t *iface); int (*configure) (fddi_iface_t *iface, const char *configfile, void *data); int (*setstate) (fddi_iface_t *iface, fddi_state_enum_t state); int (*cmd) (fddi_iface_t *iface, fddi_cmd_enum_t cmd); Modified: fddi-20070618-1-trunk/include/osadl/fddi_tpu.h ============================================================================== --- fddi-20070618-1-trunk/include/osadl/fddi_tpu.h (original) +++ fddi-20070618-1-trunk/include/osadl/fddi_tpu.h Fri Jul 13 11:00:53 2007 @@ -42,7 +42,6 @@ struct fddi_tpu *previous; fddi_pv_t *pv_list_head; - unsigned long flags; char *payload; void *callback_arg; @@ -56,7 +55,6 @@ extern int fddi_tpu_getnext(fddi_tpu_t **tpu); extern int fddi_tpu_getid(fddi_tpu_t *tpu, fddi_id_t *id); extern int fddi_tpu_gettimestamp(fddi_tpu_t *tpu, int *timestamp); /* FIXME tv */ -extern int fddi_tpu_getflags(fddi_tpu_t *tpu, unsigned long *flags); extern int fddi_tpu_setcallback(fddi_tpu_t *tpu, int(*tpu_callback)(fddi_tpu_t *tpu, void *arg), void *arg); extern int fddi_tpu_getpvlist(fddi_tpu_t *tpu, fddi_pv_t **pv); extern int fddi_tpu_getpayload(fddi_tpu_t *tpu, char **payload); Modified: fddi-20070618-1-trunk/src/libfddi.c ============================================================================== --- fddi-20070618-1-trunk/src/libfddi.c (original) +++ fddi-20070618-1-trunk/src/libfddi.c Fri Jul 13 11:00:53 2007 @@ -72,6 +72,7 @@ int fddi_iface_init(fddi_iface_t *iface, fddi_iface_attr_t *attr) { const char *error_string; + int ret = 0; if ((!iface) || (!attr)) return EINVAL; @@ -101,6 +102,18 @@ lt_dlerror(); /* register backend functions */ + iface->backend.init = lt_dlsym(iface->backend_lib, "fddi_backend_init"); + if ((error_string = lt_dlerror())) { + pthread_mutex_unlock(<_dl_mutex); + goto iface_init_err; + } + + iface->backend.destroy = lt_dlsym(iface->backend_lib, "fddi_backend_destroy"); + if ((error_string = lt_dlerror())) { + pthread_mutex_unlock(<_dl_mutex); + goto iface_init_err; + } + iface->backend.configure = lt_dlsym(iface->backend_lib, "fddi_backend_configure"); if ((error_string = lt_dlerror())) { pthread_mutex_unlock(<_dl_mutex); @@ -121,7 +134,11 @@ pthread_mutex_unlock(<_dl_mutex); - return 0; + ret = iface->backend.init(iface); + if (ret) + fprintf(stderr, "error: backend init returned %i\n", ret); + + return ret; iface_init_err: @@ -134,14 +151,20 @@ int fddi_iface_destroy(fddi_iface_t *iface) { + int ret = 0; + if (!iface) return EINVAL; + ret = iface->backend.destroy(iface); + if (ret) + fprintf(stderr, "error: backend init returned %i\n", ret); + pthread_mutex_lock(<_dl_mutex); lt_dlclose(iface->backend_lib); pthread_mutex_unlock(<_dl_mutex); - return 0; + return ret; } int fddi_iface_configure(fddi_iface_t *iface, const char *configfile, void *data) @@ -184,7 +207,7 @@ memcpy(id, &iface->id, sizeof(fddi_id_t)); - return 0; + return 0; } int fddi_iface_setid(fddi_iface_t *iface, fddi_id_t id) @@ -419,15 +442,6 @@ 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, void *arg), void *arg) { if ((!tpu) || (!tpu_callback)) @@ -513,7 +527,7 @@ fddi_id->prefix = strdup(prefix); if (!fddi_id->prefix) goto prefix_err; - } else + } else prefix_len = 0; if (postfix) { @@ -521,7 +535,7 @@ fddi_id->postfix = strdup(postfix); if (!fddi_id->postfix) goto postfix_err; - } else + } else postfix_len = 0; @@ -531,7 +545,7 @@ if (!fddi_id->id_as_string) goto id_as_str_err; - sprintf(fddi_id->id_as_string, "%s%s%s", + sprintf(fddi_id->id_as_string, "%s%s%s", fddi_id->prefix ? fddi_id->prefix : "", index_as_string ? index_as_string : "", fddi_id->postfix ? fddi_id->postfix: ""); Modified: fddi-20070618-1-trunk/src/libfddi_libmodbus.c ============================================================================== --- fddi-20070618-1-trunk/src/libfddi_libmodbus.c (original) +++ fddi-20070618-1-trunk/src/libfddi_libmodbus.c Fri Jul 13 11:00:53 2007 @@ -9,9 +9,11 @@ #include #include +#include + #include -static fddi_tpu_t tpu = { +static fddi_tpu_t tpu1 = { .id = { .prefix = "dout", .index = -1, @@ -60,51 +62,123 @@ .bit = 1, }; -/* modbus cycle timer */ +struct modbus_tpu { + timer_t timer; + struct sigevent event; + struct itimerspec timer_spec; + modbus_dev_t *modbus_dev; +}; +struct modbus_tpu modbus_tpu1; + +struct modbus_iface { + modbus_dev_t modbus_dev; +}; +struct modbus_iface modbus_iface1; + +int coil; -static timer_t modbus_timer; -static struct sigevent modbus_timer_event; -static struct itimerspec modbus_timer_spec; +void _modbus_tpu_out(fddi_tpu_t *tpu) +{ + struct modbus_tpu *modbus_tpu = (struct modbus_tpu*)(tpu->priv); + + /* application callback */ + if (tpu->callback) + tpu->callback(tpu, NULL); + + /* bus transfer */ + modbus_w_single_coil(modbus_tpu->modbus_dev, 1, coil); + coil = coil == 0 ? 1:0; +} -void flagset_sig_handler(sigval_t sigval) +void _modbus_tpu_in(fddi_tpu_t *tpu) { + /* bus transfer */ + + /* application callback */ + if (tpu->callback) + tpu->callback(tpu, NULL); +} + + +void modbus_timer_handler(sigval_t sigval) +{ + fddi_tpu_t *tpu = (fddi_tpu_t*)sigval.sival_ptr; + + if ((tpu->direction == OUT) || (tpu->direction == INOUT)) + _modbus_tpu_out(tpu); + + if ((tpu->direction == IN) || (tpu->direction == INOUT)) + _modbus_tpu_in(tpu); + return; } -/* fddi backend functions */ +/* + * fddi backend functions + */ +int fddi_backend_init(fddi_iface_t *iface); +int fddi_backend_destroy(fddi_iface_t *iface); int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data); int fddi_backend_setstate(fddi_iface_t *iface, fddi_state_enum_t state); int fddi_backend_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd); +int fddi_backend_init(fddi_iface_t *iface) +{ + iface->priv = &modbus_iface1; + return 0; +} + +int fddi_backend_destroy(fddi_iface_t *iface) +{ + modbus_dev_t *modbus_dev = (modbus_dev_t*)(iface->priv); + + if (modbus_unbind (modbus_dev) == -1) + return -1; + + return 0; +} + int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data) { int ret; + modbus_dev_t *modbus_dev = (modbus_dev_t*)(iface->priv); printf("parsing configfile: %s\n", configfile); printf("for interface: %s\n", iface->id.id_as_string); /* FIXME private */ - /* FIXME: everything's hardcoded for now, we add an xml parser later */ + /* FIXME: everything's hardcoded & static for now, we add an xml parser later */ - iface->tpulist_head = &tpu; - tpu.pv_list_head = &pv1; + iface->tpulist_head = &tpu1; + tpu1.pv_list_head = &pv1; pv1.next = &pv2; pv2.previous = &pv1; pv2.next = &pv3; pv3.previous = &pv2; - /* modbus has no hardware bus cycle, emulate one */ + /* modbus has no hardware bus cycle, emulate one for each tpu */ + /* FIXME: loop */ + { + modbus_tpu1.event.sigev_notify = SIGEV_THREAD; + modbus_tpu1.event.sigev_notify_function = modbus_timer_handler; + modbus_tpu1.event.sigev_notify_attributes = NULL; + modbus_tpu1.event.sigev_value.sival_ptr = &tpu1; + tpu1.priv = &modbus_tpu1; - modbus_timer_event.sigev_notify = SIGEV_THREAD; - modbus_timer_event.sigev_notify_function = flagset_sig_handler; - modbus_timer_event.sigev_notify_attributes = NULL; - modbus_timer_event.sigev_value.sival_ptr = NULL; + if ((ret = timer_create(CLOCK_REALTIME, &modbus_tpu1.event, &modbus_tpu1.timer)) < 0 ) { + perror("timer create"); + return -1; + } + } - if ((ret = timer_create(CLOCK_REALTIME, &modbus_timer_event, &modbus_timer)) < 0 ) { - perror("timer create"); + if (modbus_bind(modbus_dev, "192.168.23.242", 502) == -1) { + fprintf(stderr, "modbus_bind() failed\n"); return -1; } + + /* FIXME: modbus_dev must be put into the device, not iface! */ + modbus_tpu1.modbus_dev = modbus_dev; /* we are ready now and go into preoperational state */ @@ -142,15 +216,21 @@ case CMD_START: - /* FIXME */ - modbus_timer_spec.it_value.tv_sec = 1; - modbus_timer_spec.it_value.tv_nsec = 0; - modbus_timer_spec.it_interval.tv_sec = 0; - modbus_timer_spec.it_interval.tv_nsec = 500*1000*1000; - - if ((retval = timer_settime(modbus_timer, 0, &modbus_timer_spec, NULL)) < 0 ) { - perror("timer settime"); - return -1; + printf("start\n"); + /* FIXME loop over all tpus here */ + { + struct modbus_tpu *mtpu = ((struct modbus_tpu*)(iface->tpulist_head->priv)); + + mtpu->timer_spec.it_value.tv_sec = 1; + mtpu->timer_spec.it_value.tv_nsec = 0; + mtpu->timer_spec.it_interval.tv_sec = 0; + mtpu->timer_spec.it_interval.tv_nsec = 500*1000*1000; + + if ((retval = timer_settime(mtpu->timer, 0, &mtpu->timer_spec, NULL)) < 0 ) { + perror("timer settime"); + /* FIXME: disarm timers here */ + return -1; + } } retval = 0; @@ -158,17 +238,23 @@ case CMD_STOP: - modbus_timer_spec.it_value.tv_sec = 0; - modbus_timer_spec.it_value.tv_nsec = 0; - modbus_timer_spec.it_interval.tv_sec = 0; - modbus_timer_spec.it_interval.tv_nsec = 0; - - if ((retval = timer_settime(modbus_timer, 0, &modbus_timer_spec, NULL)) < 0 ) { - perror("timer settime"); - return -1; + /* FIXME: loop over all tpus here */ + { + struct modbus_tpu *mtpu = ((struct modbus_tpu*)(iface->tpulist_head->priv)); + + mtpu->timer_spec.it_value.tv_sec = 0; + mtpu->timer_spec.it_value.tv_nsec = 0; + mtpu->timer_spec.it_interval.tv_sec = 0; + mtpu->timer_spec.it_interval.tv_nsec = 0; + + if ((retval = timer_settime(mtpu->timer, 0, &mtpu->timer_spec, NULL)) < 0 ) { + perror("timer settime"); + return -1; + } } - + retval = 0; + break; case CMD_RESET: case CMD_IDENTIFY: Modified: fddi-20070618-1-trunk/tests/libfddi_examplebus.c ============================================================================== --- fddi-20070618-1-trunk/tests/libfddi_examplebus.c (original) +++ fddi-20070618-1-trunk/tests/libfddi_examplebus.c Fri Jul 13 11:00:53 2007 @@ -5,6 +5,16 @@ #include #include +int fddi_backend_init(fddi_iface_t *iface) +{ + return 0; +} + +int fddi_backend_destroy(fddi_iface_t *iface) +{ + return 0; +} + int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data) { return 0; Modified: fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c ============================================================================== --- fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c (original) +++ fddi-20070618-1-trunk/tests/test_fddi_libmodbus1.c Fri Jul 13 11:00:53 2007 @@ -27,7 +27,9 @@ return 0; } -/* FIXME: we have to agree on a bus start workflow! */ +/* + * FIXME: we have to agree on a bus start workflow! + */ int main(void) { From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:45:21 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:45:21 +0200 Subject: [OSADL-svn-commits] r59 - fapia-trunk Message-ID: <200710020945.l929jLAs020354@www.osadl.org> Author: tb10rts Date: Thu Jul 19 06:55:59 2007 New Revision: 59 Log: Created folder remotely Added: fapia-trunk/ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:45:24 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:45:24 +0200 Subject: [OSADL-svn-commits] r60 - fapia-trunk/doc Message-ID: <200710020945.l929jOE9020385@www.osadl.org> Author: tb10rts Date: Thu Jul 19 06:58:44 2007 New Revision: 60 Log: Added a folder remotely Added: fapia-trunk/doc/ fapia-trunk/doc/Doxyfile fapia-trunk/doc/FAPIA.txt fapia-trunk/doc/FAPIALicense.txt fapia-trunk/doc/FAPIA_Architecture.pdf (contents, props changed) fapia-trunk/doc/FAPIA_SW_Guidelines.pdf (contents, props changed) Added: fapia-trunk/doc/Doxyfile ============================================================================== --- (empty file) +++ fapia-trunk/doc/Doxyfile Thu Jul 19 06:58:44 2007 @@ -0,0 +1,1238 @@ +# Doxyfile 1.4.4 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = FAPIA + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = . + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = YES + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, +# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, +# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, +# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, +# Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# This tag can be used to specify the encoding used in the generated output. +# The encoding is not always determined by the language that is chosen, +# but also whether or not the output is meant for Windows or non-Windows users. +# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES +# forces the Windows encoding (this is the default for the Windows binary), +# whereas setting the tag to NO uses a Unix-style encoding (the default for +# all platforms other than Windows). + +USE_WINDOWS_ENCODING = YES + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like the Qt-style comments (thus requiring an +# explicit @brief command for a brief description. + +JAVADOC_AUTOBRIEF = YES + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# will output the detailed description near the top, like JavaDoc. +# If set to NO, the detailed description appears after the member +# documentation. + +DETAILS_AT_TOP = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources +# only. Doxygen will then generate output that is more tailored for Java. +# For instance, namespaces will be presented as packages, qualified scopes +# will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = YES + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is YES. + +SHOW_DIRECTORIES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from the +# version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the progam writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = FAPIA.txt \ + ..\interface \ + ..\FAPIAConfiguration \ + ..\FAPIAController \ + ..\FAPIAIPCParameter \ + ..\FAPIAIPCSynchronize + + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = . + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES (the default) +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be +# generated containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = YES + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_PREDEFINED tags. + +EXPAND_ONLY_PREDEF = YES + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = "ACE_ENV_ARG_DECL_WITH_DEFAULTS=" \ + "ACE_ENV_ARG_DECL=" \ + "ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS=" \ + "ACE_ENV_SINGLE_ARG_DECL=" \ + "ACE_THROW_SPEC=throws" + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = YES + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will +# generate a call dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable call graphs for selected +# functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_WIDTH = 1024 + +# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_HEIGHT = 1024 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that a graph may be further truncated if the graph's +# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH +# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), +# the graph is not depth-constrained. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, which results in a white background. +# Warning: Depending on the platform used, enabling this option may lead to +# badly anti-aliased labels on the edges of a graph (i.e. they become hard to +# read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO Added: fapia-trunk/doc/FAPIA.txt ============================================================================== --- (empty file) +++ fapia-trunk/doc/FAPIA.txt Thu Jul 19 06:58:44 2007 @@ -0,0 +1,37 @@ +/*! \mainpage + Overview of the FAPIA \n \n + \ref fapia_strategy \n + \ref fapia_interface \n + \ref fapia_packages \n + \ref fapia_architecture \n + + \n \n \n \section fapia_strategy 1. Strategy of FAPIA + bla bla bla + + \n \n \n \section fapia_interface 2. FAPIA interface + bla bla bla + + \n \n \n \section fapia_packages 3. Packages of FAPIA + The FAPIA has following packages: + + FAPIA::Controller\n + FAPIA::Configuration\n + FAPIA::IPC::Parameter\n + FAPIA::IPC::Synchronize\n\n + + The layers are separated by their namespaces in the software. Just click on them to see their purpose. + + \n \n \n \section fapia_architecture 4. Architecture of FAPIA + bla bla bla + +*/ + +/*! \page todo_list Todo List + Activities which can be done \n \n + \ref todo_fapia_xy \n + + \n \n \n \section todo_fapia_xy 1. XY + + bla bla bla + +*/ \ No newline at end of file Added: fapia-trunk/doc/FAPIALicense.txt ============================================================================== --- (empty file) +++ fapia-trunk/doc/FAPIALicense.txt Thu Jul 19 06:58:44 2007 @@ -0,0 +1,50 @@ + + _________________________________________________________________ + + Copyright and Licensing Information for the FAPIA of Homag AG, Germany + + The Homag AG FAPIA, following named as HomFapia, is copyrighted by + the Homag AG, Germany, Copyright (c) 200x-20xx, all rights reserved. + Since HomFapia is open source free software, you are free to use, modify, + and distribute the HomFapia source code and object code produced from + the source, as long as you include this copyright statement along with + code built using HomFapia. + + In particular, you can use in proprietary software and are + under no obligation to redistribute any of your source code that is + built using HomFapia. Note, however, that you may not do anything + to the HomFapia code, such as copyrighting it yourself or claiming + authorship of the HomFapia code, that will prevent HomFapia from + being distributed freely using an open source development model. + + HomFapia is provided as is with no warranties of any kind, + including the warranties of design, merchantibility and fitness for a + particular purpose, noninfringement, or arising from a course of + dealing, usage or trade practice. Moreover, HomFapia is provided + with no support and without any obligation on the part of Homag AG, Germany + to assist in its use, correction, modification, or enhancement. + + Homag AG, Germany shall have no + liability with respect to the infringement of copyrights, trade + secrets or any patents by HomFapia or any part thereof. Moreover, + in no event will Homag AG, Germany be + liable for any lost revenue or profits or other special, indirect and + consequential damages. + + By submitting comments, suggestions, code, code + snippets, techniques (including that of usage), and algorithms, + submitters acknowledge that they have the right to do so, that any + such submissions are given freely and unreservedly, and that they + waive any claims to copyright or ownership. In addition, submitters + acknowledge that any such submission might become part of the + copyright maintained on the overall body of code, which comprises the + HomFapia software. By making a submission, submitter agree + to these terms. Furthermore, submitters acknowledge that the + incorporation or modification of such submissions is entirely at the + discretion of the moderators of the open source HomFapia projects + or their designees. + + The names HomFapia, and Homag AG, Germany may not be used to endorse or + promote products or services derived from this source without express + written permission from Homag AG, Germany. Further, products or + services derived from this source may not be called HomFapia. Added: fapia-trunk/doc/FAPIA_Architecture.pdf ============================================================================== Binary file. No diff available. Added: fapia-trunk/doc/FAPIA_SW_Guidelines.pdf ============================================================================== Binary file. No diff available. From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:45:29 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:45:29 +0200 Subject: [OSADL-svn-commits] r61 - fapia-trunk/FAPIAConfiguration Message-ID: <200710020945.l929jTeD020416@www.osadl.org> Author: tb10rts Date: Thu Jul 19 06:59:18 2007 New Revision: 61 Log: Added a folder remotely Added: fapia-trunk/FAPIAConfiguration/ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:45:32 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:45:32 +0200 Subject: [OSADL-svn-commits] r62 - fapia-trunk/FAPIAController Message-ID: <200710020945.l929jWse020438@www.osadl.org> Author: tb10rts Date: Thu Jul 19 06:59:42 2007 New Revision: 62 Log: Added a folder remotely Added: fapia-trunk/FAPIAController/ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:45:34 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:45:34 +0200 Subject: [OSADL-svn-commits] r63 - fapia-trunk/FAPIAIPCParameter Message-ID: <200710020945.l929jYpf020458@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:00:19 2007 New Revision: 63 Log: Added a folder remotely Added: fapia-trunk/FAPIAIPCParameter/ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:45:37 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:45:37 +0200 Subject: [OSADL-svn-commits] r64 - fapia-trunk/FAPIAIPCSynchronize Message-ID: <200710020945.l929jbdT020565@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:00:51 2007 New Revision: 64 Log: Added a folder remotely Added: fapia-trunk/FAPIAIPCSynchronize/ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:45:40 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:45:40 +0200 Subject: [OSADL-svn-commits] r65 - fapia-trunk/interface Message-ID: <200710020945.l929jefT020651@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:01:28 2007 New Revision: 65 Log: Added a folder remotely Added: fapia-trunk/interface/ fapia-trunk/interface/FAPIA.h fapia-trunk/interface/FAPIATrace.h Added: fapia-trunk/interface/FAPIA.h ============================================================================== --- (empty file) +++ fapia-trunk/interface/FAPIA.h Thu Jul 19 07:01:28 2007 @@ -0,0 +1,549 @@ +/* -*- C -*- */ + +//============================================================================= +/** + * @file FAPIA.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + + +#ifndef _FAPI_ACYCLIC_H_ +#define _FAPI_ACYCLIC_H_ + + +#ifdef __cplusplus +extern "C" { +#endif + + +//============================================================================= +/** + * Structures + */ +//============================================================================= + +/** + * @struct FAPIAParameter + * + * @brief This structure is used to identify a Parameter. + * + */ +typedef struct + { + /// Name of the parameter. E.g. "[;]". + char * parameter_name; + } FAPIAParameter; + + +/** + * @enum FAPIADataType + * + * @brief Enumeration for datatypes. + * + */ +typedef enum + { + FAPIA_DATA_TYPE_UNS08 = 1, + FAPIA_DATA_TYPE_SGN08 = 2, + FAPIA_DATA_TYPE_UNS16 = 3, + FAPIA_DATA_TYPE_SGN16 = 4, + FAPIA_DATA_TYPE_UNS32 = 5, + FAPIA_DATA_TYPE_SGN32 = 6, + FAPIA_DATA_TYPE_STRING = 7, + FAPIA_DATA_TYPE_REAL32 = 8, + FAPIA_DATA_TYPE_REAL64 = 9 + } FAPIADataType; + + +/** + * @struct FAPIAValue + * + * @brief This structure is used to transmit the value for a parameter. + * + */ +typedef struct + { + /// Datatype of the value. + FAPIADataType data_type; + + /// Length in bytes of the value. + unsigned long data_length; + + /// Pointer to the value. Dependend on the data_type it must be casted. + void* data_value; + } FAPIAValue; + + + +/** + * @enum FAPIAErrorCode + * + * @brief Possible error codes. + * + */ +typedef enum + { + FAPIA_ERROR_OK = 0, + FAPIA_ERROR_COMMUNICATION = -1, + FAPIA_ERROR_DESTINATION_NOT_ONLINE = -2, + FAPIA_ERROR_OBJECT_NOT_FOUND = -3, + FAPIA_ERROR_PARAMETER_NOT_FOUND = -4, + FAPIA_ERROR_CONFIG_PARSE_ERROR = -5, + FAPIA_ERROR_CONFIG_HAS_WRONG_FORMAT = -6, + FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED = -7, + FAPIA_ERROR_SHARED_MEMORY_ERROR = -8 + } FAPIAErrorCode; + + +/** + * @struct FAPIAError + * + * @brief This structure holds the error information. + * + */ +typedef struct + { + /// Error code of the error. + FAPIAErrorCode error_code; + + /// Reason as a string. + char * reason; + } FAPIAError; + + +/** + * @enum FAPIACommunicationPriority + * + * @brief Priority of the Message. Default should be + * FAPIA_COMMUNICATION_PRIORITY_NORMAL. + * + */ +typedef enum + { + FAPIA_COMMUNICATION_PRIORITY_LOWEST = 1, + FAPIA_COMMUNICATION_PRIORITY_LOW = 2, + FAPIA_COMMUNICATION_PRIORITY_NORMAL = 3, + FAPIA_COMMUNICATION_PRIORITY_HIGH = 4, + FAPIA_COMMUNICATION_PRIORITY_HIGHEST = 5 + } FAPIACommunicationPriority; + + +/** + * @struct FAPIACommunication + * + * @brief This structure holds the necessary communication parameters. + * + */ +typedef struct + { + /// Possible communication error. If the error_code is not ok then the + /// whole transaction was canceled. + FAPIAError communication_error; + + /// Id of the transaction. It is unique within this process. + unsigned long transaction_id; + + /// Name of the logical object. Maybe e.g. the device_name. + char * logical_object_name; + + /// Name of the physical source object. Needed for replies. Requests do not + /// need to set it. It can be NULLL. + char * source_physical_object_name; + + /// Priority of the transaction. + FAPIACommunicationPriority priority; + + /// Indicates whether the caller likes to have a reply or not. This is only + /// reasonable on write requests. Otherwise an error occurs. + unsigned char send_reply; + + /// Number of entries. This belongs to the amount of FAPIAParameter, + /// FAPIAValue and FAPIAError elements following. + unsigned long number_of_entries; + } FAPIACommunication; + + +/** + * @enum FAPIACommunicationPriority + * + * @brief Priority of the Message. Default should be + * FAPIA_COMMUNICATION_PRIORITY_NORMAL. + * + */ +typedef enum + { + FAPIA_ACCESS_RIGHTS_READ = 1, + FAPIA_ACCESS_RIGHTS_WRITE = 2, + FAPIA_ACCESS_RIGHTS_READWRITE = 3 + } FAPIAAccessRights; + + +/** + * @struct FAPIAInfo + * + * @brief This structure is used to hold information about a Parameter. + * + */ +typedef struct + { + /// Datatype of the value. + FAPIADataType data_type; + + /// Length in bytes of the value. + unsigned long data_length; + + /// Pointer to the minimum value. Dependend on the data_type + /// it must be casted. + void* min_value; + + /// Pointer to the minimum value. Dependend on the data_type + /// it must be casted. + void* max_value; + + /// Priority of the transaction. + FAPIAAccessRights access_rights; + + /// Unit of the value. + char * unit; + + /// Exponent of base 10 to determine value for corresponding unit. + /// If exponent is not used it must be 0. + long exponent; + + /// Factor to determine value for corresponding unit. + /// If factor is not used it must be 1. + long factor; + + /// Descriptoin of the parameter. + char * description; + + } FAPIAInfo; + + +//============================================================================= +/** + * Functions + */ +//============================================================================= + + +/** + * @brief Initializes the FAPIA. name is the physical_object_name of this + * communication node. + * + * If it returns a negative number there was an error. + * + */ +long fapia_init ( + int argc, + char* argv[], + const char * const name); + + +/** + * @brief Deinitializes the FAPIA. FAPIA has to deallocate all allocated memory + * and shut down. + * + * If it returns a negative number there was an error. + * + */ +long fapia_deinit (void); + + +/** + * @brief Retrieves the logical object names from the FAPIA. + * + * If it returns a negative number there was an error. + * + */ +long fapia_logical_object_names ( + char*** logical_object_names, + unsigned long* number_of_logical_object_names); + + +//----------------------------------------------------------------------------- +/** + * Callback setting functions + */ +//----------------------------------------------------------------------------- + +/** + * @brief Initializing the caller for responses of read requests. FAPIA holds a + * reference to the function and calls it when a response is received. + * + * If it returns a negative number there was an error. + * + */ +long fapia_set_callback_for_parameter_read_response_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAValue *, + const FAPIAError *)); + + +/** + * @brief Initializing the caller for responses of write requests. FAPIA holds a + * reference to the function and calls it when a response is received. + * + * If it returns a negative number there was an error. + * + */ +long fapia_set_callback_for_parameter_write_response_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAError *)); + + +/** + * @brief Initializing the caller for responses of info requests. FAPIA holds a + * reference to the function and calls it when a response is received. + * + * If it returns a negative number there was an error. + * + */ +long fapia_set_callback_for_parameter_info_response_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAInfo *, + const FAPIAError *)); + + +/** + * @brief Initializing the callee for read requests. FAPIA holds a + * reference to the function and calls it when a request is received. + * + * If it returns a negative number there was an error. + * + */ +long fapia_set_callback_for_parameter_read_request_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *)); + + +/** + * @brief Initializing the callee for write requests. FAPIA holds a + * reference to the function and calls it when a request is received. + * + * If it returns a negative number there was an error. + * + */ +long fapia_set_callback_for_parameter_write_request_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAValue *)); + + +/** + * @brief Initializing the callee for info requests. FAPIA holds a + * reference to the function and calls it when a request is received. + * + * If it returns a negative number there was an error. + * + */ +long fapia_set_callback_for_parameter_info_request_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *)); + + +//----------------------------------------------------------------------------- +/** + * Read functions + */ +//----------------------------------------------------------------------------- + +/** + * @brief Sends a read request to the callee. fapia_communication.transaction_id + * and fapia_communication.source_physical_object_name are filled out by the + * FAPIA. + * + * If it returns a negative number there was an error. + * + */ +long fapia_parameter_read_request ( + FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters); + + +#if 0 +/** + * @brief This is the callback response function of the read_request. It is _not_ + * implemented by FAPIA. This may be done by the caller application. A function + * with this signature must be set by function + * fapia_set_callback_for_parameter_read_response_callback. + * + * If it returns a negative number there was an error. + * + */ +long fapia_parameter_read_response_callback ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAValue * const fapia_values, + const FAPIAError * const fapia_errors); + + + +/** + * @brief This is the callback request function of the read_request. It is _not_ + * implemented by FAPIA. This may be done by the callee application. A function + * with this signature must be set by function + * fapia_set_callback_for_parameter_read_request_callback. + * + * If it returns a negative number there was an error. + * + */ +long fapia_parameter_read_request_callback ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters); +#endif + + +/** + * @brief Sends a read response to the caller. + * + * If it returns a negative number there was an error. + * + */ +long fapia_parameter_read_response ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAValue * const fapia_values, + const FAPIAError * const fapia_errors); + + +//----------------------------------------------------------------------------- +/** + * Write functions + */ +//----------------------------------------------------------------------------- + +/** + * @brief Sends a write request to the callee. fapia_communication.transaction_id + * and fapia_communication.source_physical_object_name are filled out by the + * FAPIA. + * + * If it returns a negative number there was an error. + * + */ +long fapia_parameter_write_request ( + FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAValue * const fapia_values); + + +#if 0 +/** + * @brief This is the callback response function of the write_request. It is _not_ + * implemented by FAPIA. This may be done by the caller application. A function + * with this signature must be set by function + * fapia_set_callback_for_parameter_write_response_callback. + * + * If it returns a negative number there was an error. + * + */ +long fapia_parameter_write_response_callback ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAError * const fapia_errors); + + +/** + * @brief This is the callback response function of the write_request. It is _not_ + * implemented by FAPIA. This may be done by the caller application. A function + * with this signature must be set by function + * fapia_set_callback_for_parameter_write_response_callback. + * + * If it returns a negative number there was an error. + * + */ +long fapia_parameter_write_request_callback ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAValue * const fapia_values); +#endif + + +/** + * @brief Sends a write response to the caller. + * + * If it returns a negative number there was an error. + * + */ +long fapia_parameter_write_response ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAError * const fapia_errors); + + +//----------------------------------------------------------------------------- +/** + * Info functions + */ +//----------------------------------------------------------------------------- + +/** + * @brief Sends a info request to the callee. fapia_communication.transaction_id + * and fapia_communication.source_physical_object_name are filled out by the + * FAPIA. + * + * If it returns a negative number there was an error. + * + */ +long fapia_parameter_info_request ( + FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters); + + +#if 0 +/** + * @brief This is the callback response function of the info_request. It is _not_ + * implemented by FAPIA. This may be done by the caller application. A function + * with this signature must be set by function + * fapia_set_callback_for_parameter_info_response_callback. + * + * If it returns a negative number there was an error. + * + */ +long fapia_parameter_info_response_callback ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAInfo * const fapia_infos, + const FAPIAError * const fapia_errors); + + +/** + * @brief This is the callback response function of the info_request. It is _not_ + * implemented by FAPIA. This may be done by the caller application. A function + * with this signature must be set by function + * fapia_set_callback_for_parameter_info_response_callback. + * + * If it returns a negative number there was an error. + * + */ +long fapia_parameter_info_request_callback ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters); +#endif + + +/** + * @brief Sends a info response to the caller. + * + * If it returns a negative number there was an error. + * + */ +long fapia_parameter_info_response ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAInfo * const fapia_infos, + const FAPIAError * const fapia_errors); + + +#ifdef __cplusplus +} +#endif + +#endif /* _FAPI_ACYCLIC_H_ */ Added: fapia-trunk/interface/FAPIATrace.h ============================================================================== --- (empty file) +++ fapia-trunk/interface/FAPIATrace.h Thu Jul 19 07:01:28 2007 @@ -0,0 +1,68 @@ +/* -*- C -*- */ + +//============================================================================= +/** + * @file FAPIATrace.h + * + * $Id$ + * + * @author Friedhelm Wolf + */ +//============================================================================= + + +#ifndef _FAPI_ACYCLIC_TRACE_H_ +#define _FAPI_ACYCLIC_TRACE_H_ + +#include + +//============================================================================= +/** + * Preprocessor Definitions + */ +//============================================================================= + +/** + * + * @brief The FAPIA_DEBUG macro behaves like the + * ACE_DEBUG macro, but adds additional information + * to the printed message + * + * appropriate debug levels are: + * 1. LM_TRACE - not used (use FAPIA_TRACE instead) + * 2. LM_DEBUG - detailed output of data content + * 3. LM_INFO - internal messages + * 4. LM_NOTICE - description of the general program progress + * 5. LM_WARNING - warning without program termination + * 6. LM_ERROR - error message without program termination + * 7. LM_CRITICAL - error message leading to transaction termination + * 8. LM_ALERT - error message leading to program termination + * 9. LM_EMERGENCY - not used + * + */ +#if (ACE_NTRACE == 1) +#define FAPIA_DEBUG(LEVEL, ...) do \ + { \ + ACE_DEBUG((LEVEL, ACE_TEXT("(%t) "))); \ + ACE_DEBUG((LEVEL, __VA_ARGS__)); \ + ACE_DEBUG((LEVEL, ACE_TEXT("\t[line %l, func=%s file=%N]\n"), __FUNCTION__)); \ + } while (0) +#else +#define FAPIA_DEBUG(LEVEL, ...) do \ + { \ + ACE_DEBUG((LEVEL, ACE_TEXT("%I(%t) "))); \ + ACE_DEBUG((LEVEL, __VA_ARGS__)); \ + ACE_DEBUG((LEVEL, ACE_TEXT("%I\t\t[line %l, func=%s file=%N]\n"), __FUNCTION__)); \ + } while (0) +#endif +/** + * + * @brief The FAPIA_TRACE macro uses the ACE_TRACE + * macros to print out the start and the end of a function call + * automatically, by using the __FUNCTION__ compiler + * macro. + * + */ +#define FAPIA_TRACE ACE_TRACE (ACE_TEXT (__FUNCTION__)) + +#endif /* _FAPI_ACYCLIC_H_ */ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:45:43 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:45:43 +0200 Subject: [OSADL-svn-commits] r66 - fapia-trunk/make Message-ID: <200710020945.l929jhLI020783@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:01:51 2007 New Revision: 66 Log: Added a folder remotely Added: fapia-trunk/make/ fapia-trunk/make/makeall.bat fapia-trunk/make/makefile Added: fapia-trunk/make/makeall.bat ============================================================================== --- (empty file) +++ fapia-trunk/make/makeall.bat Thu Jul 19 07:01:51 2007 @@ -0,0 +1,2 @@ +set ARP_Tools=%cd%\..\..\..\DevTools_vob\ARP-Tools +ccperl %arp_tools%\mk.pl %* \ No newline at end of file Added: fapia-trunk/make/makefile ============================================================================== --- (empty file) +++ fapia-trunk/make/makefile Thu Jul 19 07:01:51 2007 @@ -0,0 +1,26 @@ +MODULE=FAPIA + +TYPES:= VC8_STATIC Automake + +NMAKE_STATIC_CFG="Static_Multi_Ansi_Debug_StaticRTL" "Static_Multi_Ansi_Release_StaticRTL" "Static_Multi_Ansi_Debug_DllRTL" "Static_Multi_Ansi_Release_DllRTL" +NMAKE_DLL_CFG= + +MPC_DIRS := $(VIEW_ROOT)/IOFramework_vob/FAPIA/make/MPC/config $(VIEW_ROOT)/ACE_Wrappers_vob/ACE_wrappers/make/MPC/config $(VIEW_ROOT)/XML_vob/xerces/make/MPC/config + +ALL: MPC BUILD + +BUILD: BUILD_ALL + +CLEAN: CLEAN_BUILD CLEAN_MPC + +REALCLEAN: REALCLEAN_BUILD CLEAN_MPC + +EXPORT: EXPORT_ALL + +%include <.homag_make_rules> +%include <.homag_mpc_make_rules> +%include <.homag_build_make_rules> +%include <.homag_export_make_rules> + +MAKE_RUNDIR:= os9/run +AUTOMAKE_RUNDIR:= i686_linux32/.libs From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:45:47 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:45:47 +0200 Subject: [OSADL-svn-commits] r67 - fapia-trunk Message-ID: <200710020945.l929jl6K020797@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:02:18 2007 New Revision: 67 Log: Added a file remotely Added: fapia-trunk/makeall.bat Added: fapia-trunk/makeall.bat ============================================================================== --- (empty file) +++ fapia-trunk/makeall.bat Thu Jul 19 07:02:18 2007 @@ -0,0 +1,2 @@ +set ARP_Tools=%cd%\..\..\DevTools_vob\ARP-Tools +ccperl %arp_tools%\mk.pl %* \ No newline at end of file From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:45:50 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:45:50 +0200 Subject: [OSADL-svn-commits] r68 - fapia-trunk Message-ID: <200710020945.l929jo3e020828@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:02:40 2007 New Revision: 68 Log: Added a file remotely Added: fapia-trunk/makefile Added: fapia-trunk/makefile ============================================================================== --- (empty file) +++ fapia-trunk/makefile Thu Jul 19 07:02:40 2007 @@ -0,0 +1,11 @@ +SPEC = * +MODULE_DIRS= $(SPEC,*D) +MODULE_DIRS = ./make + + + +ALL: $(MODULE_DIRS) $(MAKETARGETS) + %echo ALL_SOURCES $(.SOURCES) + +%include <.homag_make_rules> +%include <.homag_release_make_rules> From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:45:52 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:45:52 +0200 Subject: [OSADL-svn-commits] r69 - fapia-trunk/FAPIAConfiguration/interface Message-ID: <200710020945.l929jqbr020851@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:04:26 2007 New Revision: 69 Log: Added a folder remotely Added: fapia-trunk/FAPIAConfiguration/interface/ fapia-trunk/FAPIAConfiguration/interface/FAPIAConfiguration.h fapia-trunk/FAPIAConfiguration/interface/FAPIAConfiguration.i fapia-trunk/FAPIAConfiguration/interface/FAPIAConfigurationError.h fapia-trunk/FAPIAConfiguration/interface/FAPIAConfigurationError.i fapia-trunk/FAPIAConfiguration/interface/FAPIAConfigurationInit.h fapia-trunk/FAPIAConfiguration/interface/FAPIAConfigurationInit.i fapia-trunk/FAPIAConfiguration/interface/FAPIAConfigurationLogicalPhysicalObject.h fapia-trunk/FAPIAConfiguration/interface/FAPIAConfigurationLogicalPhysicalObject.i fapia-trunk/FAPIAConfiguration/interface/FAPIAIConfiguration.h Added: fapia-trunk/FAPIAConfiguration/interface/FAPIAConfiguration.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAConfiguration/interface/FAPIAConfiguration.h Thu Jul 19 07:04:26 2007 @@ -0,0 +1,156 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAConfiguration.h + * + * $Id$ + * + * @author Martin Meintel + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_CONFIGURATION_H_ +#define _FAPI_ACYCLIC_CONFIGURATION_H_ + +#ifdef WIN32 + #define CONFIGFILE "C:/Machine1/SPS1/fieldbus_conf.xml" +#else + #define CONFIGFILE "/c/machine1/sps1/fieldbus_conf.xml" +#endif +#define XMLCONFIG_LOGICALDEVICES "logicaldevices" +#define XMLCONFIG_LOGICALDEVICE "logicaldevice" +#define XMLCONFIG_PHYSICALDEVICE "physicaldevice" +#define XMLCONFIG_NAME "name" +#define XMLCONFIG_COMMUNICATION "communication" +#define XMLCONFIG_DESCRIPTOR "descriptor" + + +#include "../interface/FAPIAIConfiguration.h" +#include +#include /**/ + + + +namespace FAPI + { + namespace Acyclic + { + namespace Configuration + { + /** + * @class Configuration + * + * @brief The Configuration class collects the information needed + * for the fapia to run from the xml configuration file. + * + */ + class Configuration : public IConfiguration + { + public: + /** + * @brief Constructor of Configuration. + * + */ + Configuration (void); + + /** + * @brief Copy Constructor. + * + */ + Configuration (const Configuration&); + + /** + * @brief Assignment Operator. + * + */ + const Configuration& operator= (const Configuration&); + + /** + * @brief Destructor of Configuration. + * + */ + virtual ~Configuration (void); + + /** + * @brief Initializes the Configuration module. + * + * If it returns -1 there was an error. Have a look at the + * error object. + * + */ + virtual int init + ( + FAPI::Acyclic::Configuration::Init& init, + FAPI::Acyclic::Configuration::Error& error + ); + + private: + /** + * @brief initializes the Configuration module with default + * values. + * + */ + void open (void); + + /** + * @brief closesthe Configuration module + * + */ + void close(void); + + /** + * @brief copies the given values to this object + * + */ + void copy (const Configuration&); + + /** + * @brief starts parsing the xml file. + * + */ + int parseConfigurationFile + ( + FAPI::Acyclic::Configuration::Init& init, + FAPI::Acyclic::Configuration::Error& error + ); + + /** + * @brief tells whether the node has the specific attribute. + * + */ + bool hasAttribute + ( + const XERCES_CPP_NAMESPACE::DOMNode *dnp, + const char* cpAttrName + ); + + /** + * @brief for returning the attributes value + * + */ + const ACE_CString getAttributeValue + ( + const XERCES_CPP_NAMESPACE::DOMNode *dnp, + const char* cpAttrName + ); + + + bool isNodeNameLikeThis + ( + const XERCES_CPP_NAMESPACE::DOMNode *dnp, + const char* cp + ); + + }; /* class Configuration */ + } /* namespace Configuration */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + + +#if defined (__ACE_INLINE__) +#include "FAPIAConfiguration.i" +#endif /* __ACE_INLINE__ */ + + +#endif /*_FAPI_ACYCLIC_CONFIGURATION_H_ */ Added: fapia-trunk/FAPIAConfiguration/interface/FAPIAConfiguration.i ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAConfiguration/interface/FAPIAConfiguration.i Thu Jul 19 07:04:26 2007 @@ -0,0 +1,35 @@ +// $Id$ + +namespace FAPI + { + namespace Acyclic + { + namespace Configuration + { + ACE_INLINE const Configuration& Configuration::operator= (const Configuration& conf) + { + if (this != &conf) + { + this->copy(conf); + } + return *this; + } + + ACE_INLINE void Configuration::open (void) + { + //var = 123; + } + + ACE_INLINE void Configuration::close (void) + { + //var = 456; + } + + ACE_INLINE void Configuration::copy (const Configuration& /*conf*/) + { + //this->var = conf.var; + } + + }/* namespace Configuration */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAConfiguration/interface/FAPIAConfigurationError.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAConfiguration/interface/FAPIAConfigurationError.h Thu Jul 19 07:04:26 2007 @@ -0,0 +1,106 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAConfigurationError.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_CONFIGURATION_ERROR_H_ +#define _FAPI_ACYCLIC_CONFIGURATION_ERROR_H_ + +#include /**/ +#include /**/ +#include "../../interface/FAPIA.h" + +namespace FAPI + { + namespace Acyclic + { + namespace Configuration + { + /** + * @class Error + * + * @brief The Error struct contains error information. + * + */ + class Error + { + + public: + /** + * @brief Constructor of Error. + * + */ + Error (void); + + /** + * @brief Copy Constructor. + * + */ + Error (const Error&); + + /** + * @brief Assignment operator. + * + */ + const Error& operator= (const Error&); + + /** + * @brief Destructor of Error. + * + */ + virtual ~Error (void); + + // The member variables are public. Therefore there is no need + // to implement get and set methods. This class is used as a + // structure with constructor, destructor, copy constructor and + // assignement operator. + public: + /// Error code. Maybe ok. + FAPIAErrorCode error_code_; + + /// Reason of failure. If error_ is ok the reason_ is an + /// empty string. + ACE_CString reason_; + + private: + /** + * @brief for initializing the values. + * + */ + void open (void); + + /** + * @brief for copying the values. + * + */ + void copy (const Error&); + + /** + * @brief to deinitialize the values. + * + */ + void close (void); + + + + }; /* class Error */ + + /// This typedef is a container for Errors. + typedef ACE_Vector Errors; + + } /* namespace Configuration */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#if defined (__ACE_INLINE__) +#include "FAPIAConfigurationError.i" +#endif /* __ACE_INLINE__ */ + +#endif /* _FAPI_ACYCLIC_CONFIGURATION_ERROR_H_ */ Added: fapia-trunk/FAPIAConfiguration/interface/FAPIAConfigurationError.i ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAConfiguration/interface/FAPIAConfigurationError.i Thu Jul 19 07:04:26 2007 @@ -0,0 +1,39 @@ +// $Id$ + + +namespace FAPI + { + namespace Acyclic + { + namespace Configuration + { + ACE_INLINE const Error& Error::operator= (const Error& err) + { + if (this != &err) + { + this->copy(err); + } + return *this; + } + + ACE_INLINE void Error::open (void) + { + error_code_ = FAPIA_ERROR_OK; + reason_ = ""; + } + + ACE_INLINE void Error::close (void) + { + error_code_ = FAPIA_ERROR_OK; + reason_ = "deinit"; + } + + ACE_INLINE void Error::copy (const Error& err) + { + this->error_code_ = err.error_code_; + this->reason_ = err.reason_; + } + + }/* namespace Configuration */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAConfiguration/interface/FAPIAConfigurationInit.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAConfiguration/interface/FAPIAConfigurationInit.h Thu Jul 19 07:04:26 2007 @@ -0,0 +1,104 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAConfigurationInit.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_CONFIGURATION_INIT_H_ +#define _FAPI_ACYCLIC_CONFIGURATION_INIT_H_ + +#include /**/ +#include "FAPIAConfigurationLogicalPhysicalObject.h" + +namespace FAPI + { + namespace Acyclic + { + namespace Configuration + { + /** + * @class Init + * + * @brief The Init structure is used to initialize the + * Configuration module. + * + */ + class Init + { + + public: + /** + * @brief Constructor of Init. + * + */ + Init (void); + + /** + * @brief Copy Constructor. + * + */ + Init (const Init&); + + /** + * @brief Assignment operator. + * + */ + const Init& operator= (const Init&); + + /** + * @brief Destructor of Init. + * + */ + virtual ~Init (void); + + // The member variables are public. Therefore there is no need + // to implement get and set methods. This class is used as a + // structure with constructor, destructor, copy constructor and + // assignement operator. + public: + /// Name of the file for the shared memory. + ACE_CString fapia_shared_memory_name_; + + /// Name of this physical object. + ACE_CString physical_object_name_; + + /// Logical objects and their corresponding physical objects. + FAPI::Acyclic::Configuration::LogicalPhysicalObjects logical_physical_objects_; + + + private: + /** + * @brief for initializing the values. + * + */ + void open (void); + + /** + * @brief for copying the values. + * + */ + void copy (const Init&); + + /** + * @brief to deinitialize the values. + * + */ + void close (void); + + }; /* class Init */ + + } /* namespace Configuration */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#if defined (__ACE_INLINE__) +#include "FAPIAConfigurationInit.i" +#endif /* __ACE_INLINE__ */ + +#endif /* _FAPI_ACYCLIC_CONFIGURATION_INIT_H_ */ Added: fapia-trunk/FAPIAConfiguration/interface/FAPIAConfigurationInit.i ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAConfiguration/interface/FAPIAConfigurationInit.i Thu Jul 19 07:04:26 2007 @@ -0,0 +1,39 @@ +// $Id$ + + +namespace FAPI + { + namespace Acyclic + { + namespace Configuration + { + ACE_INLINE const Init& Init::operator= (const Init& init) + { + if (this != &init) + { + this->copy(init); + } + return *this; + } + + ACE_INLINE void Init::open (void) + { + physical_object_name_ = ""; + logical_physical_objects_.clear(); + } + + ACE_INLINE void Init::close (void) + { + physical_object_name_ = "deinit"; + logical_physical_objects_.clear(); + } + + ACE_INLINE void Init::copy (const Init& init) + { + this->physical_object_name_ = init.physical_object_name_; + this->logical_physical_objects_ = init.logical_physical_objects_; + } + + }/* namespace Configuration */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAConfiguration/interface/FAPIAConfigurationLogicalPhysicalObject.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAConfiguration/interface/FAPIAConfigurationLogicalPhysicalObject.h Thu Jul 19 07:04:26 2007 @@ -0,0 +1,106 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAConfigurationLogicalPhysicalObject.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_CONFIGURATION_LOGICAL_PHYSICAL_OBJECT_H_ +#define _FAPI_ACYCLIC_CONFIGURATION_LOGICAL_PHYSICAL_OBJECT_H_ + +#include /**/ +#include /**/ +#include /**/ + +namespace FAPI + { + namespace Acyclic + { + namespace Configuration + { + /** + * @class LogicalPhysicalObject + * + * @brief The LogicalPhysicalObject holds the relation between + * logical and physical objects. + * + */ + class LogicalPhysicalObject + { + + public: + /** + * @brief Constructor of LogicalPhysicalObject. + * + */ + LogicalPhysicalObject (void); + + /** + * @brief Copy Constructor. + * + */ + LogicalPhysicalObject (const LogicalPhysicalObject&); + + /** + * @brief Assignment operator. + * + */ + const LogicalPhysicalObject& operator= (const LogicalPhysicalObject&); + + /** + * @brief Destructor of LogicalPhysicalObject. + * + */ + virtual ~LogicalPhysicalObject (void); + + // The member variables are public. Therefore there is no need + // to implement get and set methods. This class is used as a + // structure with constructor, destructor, copy constructor and + // assignement operator. + public: + /// Name of the logical object. + ACE_CString logical_object_name_; + + /// Name of the corresponding physical object. + ACE_CString physical_object_name_; + + private: + /** + * @brief for initializing the values. + * + */ + void open (void); + + /** + * @brief for copying the values. + * + */ + void copy (const LogicalPhysicalObject&); + + /** + * @brief to deinitialize the values. + * + */ + void close (void); + + }; /* class LogicalPhysicalObject */ + + /// This typedef is a container for LogicalPhysicalObjects. + typedef ACE_Vector LogicalPhysicalObjects; + + } /* namespace Configuration */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + + + +#if defined (__ACE_INLINE__) +#include "FAPIAConfigurationLogicalPhysicalObject.i" +#endif /* __ACE_INLINE__ */ + +#endif /* _FAPI_ACYCLIC_CONFIGURATION_LOGICAL_PHYSICAL_OBJECT_H_ */ Added: fapia-trunk/FAPIAConfiguration/interface/FAPIAConfigurationLogicalPhysicalObject.i ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAConfiguration/interface/FAPIAConfigurationLogicalPhysicalObject.i Thu Jul 19 07:04:26 2007 @@ -0,0 +1,40 @@ +// $Id$ + + +namespace FAPI + { + namespace Acyclic + { + namespace Configuration + { + ACE_INLINE const LogicalPhysicalObject& LogicalPhysicalObject::operator= + (const LogicalPhysicalObject& lpo) + { + if (this != &lpo) + { + this->copy(lpo); + } + return *this; + } + + ACE_INLINE void LogicalPhysicalObject::open (void) + { + logical_object_name_ = ""; + physical_object_name_ = ""; + } + + ACE_INLINE void LogicalPhysicalObject::close (void) + { + logical_object_name_ = "deinit"; + physical_object_name_ = "deinit"; + } + + ACE_INLINE void LogicalPhysicalObject::copy (const LogicalPhysicalObject& lpo) + { + this->logical_object_name_ = lpo.logical_object_name_; + this->physical_object_name_ = lpo.physical_object_name_; + } + + }/* namespace Configuration */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAConfiguration/interface/FAPIAIConfiguration.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAConfiguration/interface/FAPIAIConfiguration.h Thu Jul 19 07:04:26 2007 @@ -0,0 +1,51 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIConfiguration.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_ICONFIGURATION_H_ +#define _FAPI_ACYCLIC_ICONFIGURATION_H_ + +#include "FAPIAConfigurationInit.h" +#include "FAPIAConfigurationError.h" + +namespace FAPI + { + namespace Acyclic + { + /** + * @interface IConfiguration + * + * @brief The IConfiguration is the interface for the configuration + * module. + * + */ + class IConfiguration + { + + public: + /** + * @brief Initializes the Configuration module. + * + * If it returns -1 there was an error. Look at the error object. + * + */ + virtual int init + ( + FAPI::Acyclic::Configuration::Init& init, + FAPI::Acyclic::Configuration::Error& error + ) = 0; + + }; /* class IConfiguration */ + + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_ICONFIGURATION_H_ */ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:45:56 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:45:56 +0200 Subject: [OSADL-svn-commits] r70 - fapia-trunk/FAPIAConfiguration/make Message-ID: <200710020945.l929juYe020882@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:05:09 2007 New Revision: 70 Log: Added a folder remotely Added: fapia-trunk/FAPIAConfiguration/make/ fapia-trunk/FAPIAConfiguration/make/makeall.bat fapia-trunk/FAPIAConfiguration/make/makefile Added: fapia-trunk/FAPIAConfiguration/make/makeall.bat ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAConfiguration/make/makeall.bat Thu Jul 19 07:05:09 2007 @@ -0,0 +1,2 @@ +set ARP_Tools=%cd%\..\..\..\..\DevTools_vob\ARP-Tools +ccperl %arp_tools%\mk.pl %* \ No newline at end of file Added: fapia-trunk/FAPIAConfiguration/make/makefile ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAConfiguration/make/makefile Thu Jul 19 07:05:09 2007 @@ -0,0 +1,26 @@ +MODULE=FAPIAConfiguration + +TYPES:= VC8_STATIC Automake + +NMAKE_STATIC_CFG="Static_Multi_Unicode_Debug_StaticRTL" "Static_Multi_Unicode_Release_StaticRTL" +NMAKE_DLL_CFG= + +MPC_DIRS := $(VIEW_ROOT)/IOFramework_vob/FAPIA/make/MPC/config $(VIEW_ROOT)/ACE_Wrappers_vob/ACE_wrappers/make/MPC/config $(VIEW_ROOT)/XML_vob/xerces/make/MPC/config + +ALL: MPC BUILD + +BUILD: BUILD_ALL + +CLEAN: CLEAN_BUILD CLEAN_MPC + +REALCLEAN: REALCLEAN_BUILD CLEAN_MPC + +EXPORT: EXPORT_ALL + +%include <.homag_make_rules> +%include <.homag_mpc_make_rules> +%include <.homag_build_make_rules> +%include <.homag_export_make_rules> + +MAKE_RUNDIR:= os9/run +AUTOMAKE_RUNDIR:= i686_linux32 From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:45:58 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:45:58 +0200 Subject: [OSADL-svn-commits] r71 - fapia-trunk/FAPIAConfiguration/make/MPC Message-ID: <200710020945.l929jwdp020904@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:05:40 2007 New Revision: 71 Log: Added a folder remotely Added: fapia-trunk/FAPIAConfiguration/make/MPC/ fapia-trunk/FAPIAConfiguration/make/MPC/FAPIAConfiguration.mpc fapia-trunk/FAPIAConfiguration/make/MPC/FAPIAConfiguration.mwc Added: fapia-trunk/FAPIAConfiguration/make/MPC/FAPIAConfiguration.mpc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAConfiguration/make/MPC/FAPIAConfiguration.mpc Thu Jul 19 07:05:40 2007 @@ -0,0 +1,3 @@ + +project : FAPIAConfigurationsource { +} \ No newline at end of file Added: fapia-trunk/FAPIAConfiguration/make/MPC/FAPIAConfiguration.mwc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAConfiguration/make/MPC/FAPIAConfiguration.mwc Thu Jul 19 07:05:40 2007 @@ -0,0 +1,3 @@ +workspace { + FAPIAConfiguration.mpc +} \ No newline at end of file From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:46:02 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:46:02 +0200 Subject: [OSADL-svn-commits] r72 - fapia-trunk/FAPIAController/make Message-ID: <200710020946.l929k2YX020918@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:06:21 2007 New Revision: 72 Log: Added a folder remotely Added: fapia-trunk/FAPIAController/make/ fapia-trunk/FAPIAController/make/makeall.bat fapia-trunk/FAPIAController/make/makefile Added: fapia-trunk/FAPIAController/make/makeall.bat ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/make/makeall.bat Thu Jul 19 07:06:21 2007 @@ -0,0 +1,2 @@ +set ARP_Tools=%cd%\..\..\..\..\DevTools_vob\ARP-Tools +ccperl %arp_tools%\mk.pl %* \ No newline at end of file Added: fapia-trunk/FAPIAController/make/makefile ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/make/makefile Thu Jul 19 07:06:21 2007 @@ -0,0 +1,26 @@ +MODULE=FAPIAController + +TYPES:= VC8_STATIC Automake + +NMAKE_STATIC_CFG="Static_Multi_Unicode_Debug_StaticRTL" "Static_Multi_Unicode_Release_StaticRTL" +NMAKE_DLL_CFG= + +MPC_DIRS := $(VIEW_ROOT)/IOFramework_vob/FAPIA/make/MPC/config $(VIEW_ROOT)/ACE_Wrappers_vob/ACE_wrappers/make/MPC/config $(VIEW_ROOT)/XML_vob/xerces/make/MPC/config + +ALL: MPC BUILD + +BUILD: BUILD_ALL + +CLEAN: CLEAN_BUILD CLEAN_MPC + +REALCLEAN: REALCLEAN_BUILD CLEAN_MPC + +EXPORT: EXPORT_ALL + +%include <.homag_make_rules> +%include <.homag_mpc_make_rules> +%include <.homag_build_make_rules> +%include <.homag_export_make_rules> + +MAKE_RUNDIR:= os9/run +AUTOMAKE_RUNDIR:= i686_linux32 From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:46:05 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:46:05 +0200 Subject: [OSADL-svn-commits] r73 - fapia-trunk/FAPIAConfiguration/source Message-ID: <200710020946.l929k5oJ020943@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:06:45 2007 New Revision: 73 Log: Added a folder remotely Added: fapia-trunk/FAPIAConfiguration/source/ fapia-trunk/FAPIAConfiguration/source/FAPIAConfiguration.cpp fapia-trunk/FAPIAConfiguration/source/FAPIAConfigurationError.cpp fapia-trunk/FAPIAConfiguration/source/FAPIAConfigurationInit.cpp fapia-trunk/FAPIAConfiguration/source/FAPIAConfigurationLogicalPhysicalObject.cpp Added: fapia-trunk/FAPIAConfiguration/source/FAPIAConfiguration.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAConfiguration/source/FAPIAConfiguration.cpp Thu Jul 19 07:06:45 2007 @@ -0,0 +1,407 @@ +// $Id$ + + +#include "../interface/FAPIAConfiguration.h" +#include "../interface/FAPIAIConfiguration.h" +#include "../../interface/FAPIATrace.h" + +#if !defined (__ACE_INLINE__) +#include "../interface/FAPIAConfiguration.i" +#endif /* __ACE_INLINE__ */ + +#include +#include +#include + +#include + +namespace FAPI + { + namespace Acyclic + { + +/* ---------------------------------------------------------------------------*/ + + namespace Configuration + { + Configuration::Configuration (void) + { + FAPIA_TRACE; + open(); + } + +/* ---------------------------------------------------------------------------*/ + + Configuration::Configuration (const Configuration& conf) + { + FAPIA_TRACE; + open(); + copy(conf); + } + +/* ---------------------------------------------------------------------------*/ + + Configuration::~Configuration (void) + { + FAPIA_TRACE; + XERCES_CPP_NAMESPACE::XMLPlatformUtils::Terminate(); + close(); + } + +/* ---------------------------------------------------------------------------*/ + + int Configuration::init + ( + FAPI::Acyclic::Configuration::Init& init, + FAPI::Acyclic::Configuration::Error& error + ) + { + FAPIA_TRACE; + return parseConfigurationFile(init, error); + } + +/* ---------------------------------------------------------------------------*/ + + int Configuration::parseConfigurationFile + ( + FAPI::Acyclic::Configuration::Init& init, + FAPI::Acyclic::Configuration::Error& error + ) + { + FAPIA_TRACE; + // Initialisieren des Parsers + FAPIA_DEBUG( + LM_NOTICE, + "Initializing the xml platform utils...\n"); + XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize(); + + + FAPIA_DEBUG( + LM_NOTICE, + "creating dom parser and setting the specific options...\n"); + XERCES_CPP_NAMESPACE::XercesDOMParser *parser = new XERCES_CPP_NAMESPACE::XercesDOMParser(); +//ACTIVATE!! IF NOT VALID, STOP HANDLING +parser->setValidationScheme(XERCES_CPP_NAMESPACE::XercesDOMParser::Val_Auto); + parser->setDoNamespaces(false); + parser->setDoSchema(false); + parser->setValidationSchemaFullChecking(false); + parser->setCreateEntityReferenceNodes(false); + + try + { + FAPIA_DEBUG( + LM_NOTICE, + "parsing the xml file...\n"); + + parser->parse(CONFIGFILE); + } + catch(...) + { + ACE_CString strError = "Fatal Error while parsing configfile "; + strError += CONFIGFILE; + + error.error_code_ = FAPIA_ERROR_CONFIG_PARSE_ERROR; + error.reason_ = strError; + + FAPIA_DEBUG ( + LM_ALERT, + "Error occurred during the parse operation of the configuration file.\n"); + + return FAPIA_ERROR_CONFIG_PARSE_ERROR; + } + + FAPIA_DEBUG( + LM_NOTICE, + "accessing the document...\n"); + XERCES_CPP_NAMESPACE::DOMNode *pDoc = parser->getDocument(); + + if (!pDoc) + { + ACE_CString strError = "Fatal Error while parsing configfile "; + strError += CONFIGFILE; + + error.error_code_ = FAPIA_ERROR_CONFIG_PARSE_ERROR; + error.reason_ = strError; + + FAPIA_DEBUG ( + LM_ALERT, + "Error document node of configuration file is null.\n"); + + return FAPIA_ERROR_CONFIG_PARSE_ERROR; + } + + + /* get the logicaldevices node */ + FAPIA_DEBUG( + LM_NOTICE, + "getting the commonfieldbusnode...\n"); + XERCES_CPP_NAMESPACE::DOMNode *pDNCommonFieldBusNode = pDoc->getFirstChild(); + + if ( !pDNCommonFieldBusNode ) + { + ACE_CString strError = "Missing Information in config file. Commonfieldbus Node not found!"; + strError += CONFIGFILE; + + error.error_code_ = FAPIA_ERROR_CONFIG_HAS_WRONG_FORMAT; + error.reason_ = strError; + + strError += "\n"; + + FAPIA_DEBUG ( + LM_ALERT, + strError.c_str()); + + return FAPIA_ERROR_CONFIG_HAS_WRONG_FORMAT; + } + + + /* Find the logicaldevices node */ + FAPIA_DEBUG( + LM_NOTICE, + "getting the logicaldevices node...\n"); + XERCES_CPP_NAMESPACE::DOMNode *pDNIteratorNode = pDNCommonFieldBusNode->getFirstChild(); + while( NULL != pDNIteratorNode ) + { + if ( isNodeNameLikeThis(pDNIteratorNode, XMLCONFIG_LOGICALDEVICES) ) + { + break; + } + pDNIteratorNode = pDNIteratorNode->getNextSibling(); + } + + if ( !pDNIteratorNode ) + { + ACE_CString strError = "Missing Information in config file. Logicaldevices Node not found!"; + strError += CONFIGFILE; + + error.error_code_ = FAPIA_ERROR_CONFIG_HAS_WRONG_FORMAT; + error.reason_ = strError; + + strError += "\n"; + + FAPIA_DEBUG ( + LM_ALERT, + strError.c_str()); + + return FAPIA_ERROR_CONFIG_HAS_WRONG_FORMAT; + } + + /* get all devices */ + FAPIA_DEBUG( + LM_NOTICE, + "iterating through all logicaldevice nodes...\n"); + XERCES_CPP_NAMESPACE::DOMNode *pDNLogicalDevice = pDNIteratorNode->getFirstChild(); + while( pDNLogicalDevice ) + { + ACE_CString logicalDeviceName; + ACE_CString physicalDeviceName; + + + FAPIA_DEBUG( + LM_DEBUG, + "new child node of logicaldevices found...\n"); + + if (isNodeNameLikeThis(pDNLogicalDevice, XMLCONFIG_LOGICALDEVICE)) + { + FAPIA_DEBUG( + LM_DEBUG, + "\tlogicaldevice node found...\n"); + + if (hasAttribute(pDNLogicalDevice, XMLCONFIG_NAME)) + { + FAPIA_DEBUG( + LM_DEBUG, + "\t\tname attribute found:>"); + + logicalDeviceName = getAttributeValue(pDNLogicalDevice, XMLCONFIG_NAME); + + FAPIA_DEBUG( + LM_DEBUG, + logicalDeviceName.c_str()); + + FAPIA_DEBUG( + LM_DEBUG, + "<\n"); + } + + /* find the physical device */ + XERCES_CPP_NAMESPACE::DOMNode *pDNPhysicalDevice = pDNLogicalDevice->getFirstChild(); + while(pDNPhysicalDevice) + { + if (isNodeNameLikeThis(pDNPhysicalDevice, XMLCONFIG_PHYSICALDEVICE)) + { + FAPIA_DEBUG( + LM_DEBUG, + "\t\t\tphysicaldevicenode found...\n"); + break; + } + pDNPhysicalDevice = pDNPhysicalDevice->getNextSibling(); + } + + /* get the communication node */ + if (!pDNPhysicalDevice) + { + ACE_CString strError = "Missing Information in config file. Physicaldevice Node not found!"; + error.error_code_ = FAPIA_ERROR_CONFIG_HAS_WRONG_FORMAT; + error.reason_ = strError; + + strError += "\n"; + + FAPIA_DEBUG ( + LM_ALERT, + strError.c_str()); + + return FAPIA_ERROR_CONFIG_HAS_WRONG_FORMAT; + }/* if !pDNPhysicalDevice */ + + XERCES_CPP_NAMESPACE::DOMNode *pDNCommunication = pDNPhysicalDevice->getFirstChild(); + while(pDNCommunication) + { + pDNCommunication = pDNCommunication->getNextSibling(); + if ( pDNCommunication && isNodeNameLikeThis(pDNCommunication, XMLCONFIG_COMMUNICATION) ) + { + FAPIA_DEBUG( + LM_DEBUG, + "\t\t\tcommunicationnode found...\n"); + break; + } + } + + if (!pDNCommunication) + { + ACE_CString strError = "Missing Information in config file. Communication Node not found!"; + error.error_code_ = FAPIA_ERROR_CONFIG_HAS_WRONG_FORMAT; + error.reason_ = strError; + + strError += "\n"; + + FAPIA_DEBUG ( + LM_ALERT, + strError.c_str()); + + return FAPIA_ERROR_CONFIG_HAS_WRONG_FORMAT; + } + + + if ( hasAttribute(pDNCommunication, XMLCONFIG_DESCRIPTOR) ) + { + FAPIA_DEBUG( + LM_DEBUG, + "\t\t\t\tattribute name of communication node found:"); + physicalDeviceName = getAttributeValue(pDNCommunication, XMLCONFIG_DESCRIPTOR); + + FAPIA_DEBUG( + LM_DEBUG, + physicalDeviceName.c_str()); + + FAPIA_DEBUG( + LM_DEBUG, + "\n"); + + } + + + if ( 0 != logicalDeviceName.compare("") && 0 != physicalDeviceName.compare("") ) + { + LogicalPhysicalObject lpo; + lpo.logical_object_name_ = logicalDeviceName; + lpo.physical_object_name_ = physicalDeviceName; + + init.logical_physical_objects_.push_back(lpo); + } + + }/* if nodenamelike XMLCONFIG_LOGICALDEVICE */ + pDNLogicalDevice = pDNLogicalDevice->getNextSibling(); + }/* isNodeNameLikeThis LOGICALDEVICE */ + + FAPIA_DEBUG( + LM_NOTICE, + "parsing the config file finished...\n"); + + + if(parser) + { + delete parser; + } + + return init.logical_physical_objects_.size(); + }/* parseConfigurationFile */ + +/* ---------------------------------------------------------------------------*/ + + bool Configuration::isNodeNameLikeThis(const XERCES_CPP_NAMESPACE::DOMNode *dnp, const char* cp) + { + FAPIA_TRACE; + char *pNodeName = XERCES_CPP_NAMESPACE::XMLString::transcode(dnp->getNodeName()); + if (0 == XERCES_CPP_NAMESPACE::XMLString::compareString(pNodeName, cp) ) + { + XERCES_CPP_NAMESPACE::XMLString::release(&pNodeName); + return true; + } + XERCES_CPP_NAMESPACE::XMLString::release(&pNodeName); + return false; + }/* isNodeNameLikeThis */ + +/* ---------------------------------------------------------------------------*/ + + bool Configuration::hasAttribute + ( + const XERCES_CPP_NAMESPACE::DOMNode *dnp, + const char* cpAttrName + ) + { + FAPIA_TRACE; + XERCES_CPP_NAMESPACE::DOMNode *dnpTemp = NULL; + XMLCh *xcAttrName = XERCES_CPP_NAMESPACE::XMLString::transcode(cpAttrName); + + if ( dnp && dnp->getAttributes() ) + { + dnpTemp = dnp->getAttributes()->getNamedItem(xcAttrName); + } + + XERCES_CPP_NAMESPACE::XMLString::release(&xcAttrName); + + if (!dnpTemp) + { + return false; + } + + return true; + }/* hasAttribute */ + +/* ---------------------------------------------------------------------------*/ + + const ACE_CString Configuration::getAttributeValue + ( + const XERCES_CPP_NAMESPACE::DOMNode *dnp, + const char* cpAttrName + ) + { + FAPIA_TRACE; + XERCES_CPP_NAMESPACE::DOMNode *dnpTemp = NULL; + XMLCh *xcAttrName = XERCES_CPP_NAMESPACE::XMLString::transcode(cpAttrName); + + if ( dnp && dnp->getAttributes() ) + { + dnpTemp = dnp->getAttributes()->getNamedItem(xcAttrName); + } + + XERCES_CPP_NAMESPACE::XMLString::release(&xcAttrName); + + if (!dnpTemp) + { + return ACE_CString(); + } + + char* cpTmp = XERCES_CPP_NAMESPACE::XMLString::transcode(dnpTemp->getNodeValue()); + ACE_CString strTemp = cpTmp; + XERCES_CPP_NAMESPACE::XMLString::release(&cpTmp); + + return strTemp; + }/* getAttributeValue */ + +/* ---------------------------------------------------------------------------*/ + + }/* namespace Configuration */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAConfiguration/source/FAPIAConfigurationError.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAConfiguration/source/FAPIAConfigurationError.cpp Thu Jul 19 07:06:45 2007 @@ -0,0 +1,47 @@ +// $Id$ + + +#include "../interface/FAPIAConfigurationError.h" +#include "../../interface/FAPIATrace.h" + +#if !defined (__ACE_INLINE__) +#include "../interface/FAPIAConfigurationError.i" +#endif + +namespace FAPI + { + namespace Acyclic + { + +/* ---------------------------------------------------------------------------*/ + + namespace Configuration + { + Error::Error (void) + { + FAPIA_TRACE; + open(); + } + +/* ---------------------------------------------------------------------------*/ + + Error::Error (const Error& err) + { + FAPIA_TRACE; + open(); + copy(err); + } + +/* ---------------------------------------------------------------------------*/ + + Error::~Error (void) + { + FAPIA_TRACE; + close(); + } + +/* ---------------------------------------------------------------------------*/ + + }/* namespace Configuration */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAConfiguration/source/FAPIAConfigurationInit.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAConfiguration/source/FAPIAConfigurationInit.cpp Thu Jul 19 07:06:45 2007 @@ -0,0 +1,48 @@ +// $Id$ + + +#include "../interface/FAPIAConfigurationInit.h" +#include "../../interface/FAPIATrace.h" + + +#if !defined (__ACE_INLINE__) +#include "../interface/FAPIAConfigurationInit.i" +#endif /* __ACE_INLINE__ */ + +namespace FAPI + { + namespace Acyclic + { + namespace Configuration + { + +/* ---------------------------------------------------------------------------*/ + + Init::Init (void) + { + FAPIA_TRACE; + open(); + } + +/* ---------------------------------------------------------------------------*/ + + Init::Init (const Init& init) + { + FAPIA_TRACE; + open(); + copy(init); + } + +/* ---------------------------------------------------------------------------*/ + + Init::~Init (void) + { + FAPIA_TRACE; + close(); + } + +/* ---------------------------------------------------------------------------*/ + + }/* namespace Configuration */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAConfiguration/source/FAPIAConfigurationLogicalPhysicalObject.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAConfiguration/source/FAPIAConfigurationLogicalPhysicalObject.cpp Thu Jul 19 07:06:45 2007 @@ -0,0 +1,48 @@ +// $Id$ + + +#include "../interface/FAPIAConfigurationLogicalPhysicalObject.h" +#include "../../interface/FAPIATrace.h" + +#if !defined (__ACE_INLINE__) +#include "../interface/FAPIAConfigurationLogicalPhysicalObject.i" +#endif /* __ACE_INLINE__ */ + +namespace FAPI + { + namespace Acyclic + { + namespace Configuration + { + +/* ---------------------------------------------------------------------------*/ + + LogicalPhysicalObject::LogicalPhysicalObject (void) + { + FAPIA_TRACE; + open(); + } + +/* ---------------------------------------------------------------------------*/ + + LogicalPhysicalObject::LogicalPhysicalObject + (const LogicalPhysicalObject& lpo) + { + FAPIA_TRACE; + open(); + copy(lpo); + } + +/* ---------------------------------------------------------------------------*/ + + LogicalPhysicalObject::~LogicalPhysicalObject (void) + { + FAPIA_TRACE; + close(); + } + +/* ---------------------------------------------------------------------------*/ + + }/* namespace Configuration */ + } /* namespace Acyclic */ + } /* namespace FAPI */ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:46:08 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:46:08 +0200 Subject: [OSADL-svn-commits] r74 - fapia-trunk/FAPIAController/MPC Message-ID: <200710020946.l929k8iA020967@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:07:23 2007 New Revision: 74 Log: Added a folder remotely Added: fapia-trunk/FAPIAController/MPC/ fapia-trunk/FAPIAController/MPC/FAPIAController.mpc fapia-trunk/FAPIAController/MPC/FAPIAController.mwc Added: fapia-trunk/FAPIAController/MPC/FAPIAController.mpc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/MPC/FAPIAController.mpc Thu Jul 19 07:07:23 2007 @@ -0,0 +1,3 @@ + +project : FAPIAControllersource { +} \ No newline at end of file Added: fapia-trunk/FAPIAController/MPC/FAPIAController.mwc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/MPC/FAPIAController.mwc Thu Jul 19 07:07:23 2007 @@ -0,0 +1,3 @@ +workspace { + FAPIAController.mpc +} \ No newline at end of file From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:46:10 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:46:10 +0200 Subject: [OSADL-svn-commits] r75 - fapia-trunk/FAPIAController/MPC Message-ID: <200710020946.l929kAoh020983@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:07:40 2007 New Revision: 75 Log: Removed file/folder Removed: fapia-trunk/FAPIAController/MPC/ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:46:13 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:46:13 +0200 Subject: [OSADL-svn-commits] r76 - fapia-trunk/FAPIAController/make/MPC Message-ID: <200710020946.l929kDCH021005@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:08:16 2007 New Revision: 76 Log: Added a folder remotely Added: fapia-trunk/FAPIAController/make/MPC/ fapia-trunk/FAPIAController/make/MPC/FAPIAController.mpc fapia-trunk/FAPIAController/make/MPC/FAPIAController.mwc Added: fapia-trunk/FAPIAController/make/MPC/FAPIAController.mpc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/make/MPC/FAPIAController.mpc Thu Jul 19 07:08:16 2007 @@ -0,0 +1,3 @@ + +project : FAPIAControllersource { +} \ No newline at end of file Added: fapia-trunk/FAPIAController/make/MPC/FAPIAController.mwc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/make/MPC/FAPIAController.mwc Thu Jul 19 07:08:16 2007 @@ -0,0 +1,3 @@ +workspace { + FAPIAController.mpc +} \ No newline at end of file From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:46:15 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:46:15 +0200 Subject: [OSADL-svn-commits] r77 - fapia-trunk/FAPIAController/source Message-ID: <200710020946.l929kFr1021029@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:08:51 2007 New Revision: 77 Log: Added a folder remotely Added: fapia-trunk/FAPIAController/source/ fapia-trunk/FAPIAController/source/FAPIA.cpp fapia-trunk/FAPIAController/source/FAPIAControllerController.cpp fapia-trunk/FAPIAController/source/FAPIAControllerController.h fapia-trunk/FAPIAController/source/FAPIAControllerMethodRequestShutdown.cpp fapia-trunk/FAPIAController/source/FAPIAControllerMethodRequestShutdown.h fapia-trunk/FAPIAController/source/FAPIAControllerReplyCommandHandler.cpp fapia-trunk/FAPIAController/source/FAPIAControllerReplyCommandHandler.h Added: fapia-trunk/FAPIAController/source/FAPIA.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/source/FAPIA.cpp Thu Jul 19 07:08:51 2007 @@ -0,0 +1,270 @@ +// $Id$ + + +#include "../../interface/FAPIA.h" +#include "FAPIAControllerController.h" + +/* ---------------------------------------------------------------------------*/ + +long fapia_init ( + int argc, + char* argv[], + const char * const name) +{ + return FAPIA_CONTROLLER->fapia_init (argc, argv, name); +} + + +/* ---------------------------------------------------------------------------*/ + +long fapia_deinit (void) +{ + return FAPIA_CONTROLLER->fapia_deinit (); +} + + +/* ---------------------------------------------------------------------------*/ + +long fapia_logical_object_names ( + char*** logical_object_names, + unsigned long* number_of_logical_object_names) + { + return FAPIA_CONTROLLER->fapia_logical_object_names ( + logical_object_names, + number_of_logical_object_names); + } + + +/* ---------------------------------------------------------------------------*/ + +long fapia_set_callback_for_parameter_read_response_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAValue *, + const FAPIAError *)) + { + return FAPIA_CONTROLLER->fapia_set_callback_for_parameter_read_response_callback (f); + } + + +/* ---------------------------------------------------------------------------*/ + +long fapia_set_callback_for_parameter_write_response_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAError *)) + { + return FAPIA_CONTROLLER->fapia_set_callback_for_parameter_write_response_callback (f); + } + + +/* ---------------------------------------------------------------------------*/ + +long fapia_set_callback_for_parameter_info_response_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAInfo *, + const FAPIAError *)) + { + return FAPIA_CONTROLLER->fapia_set_callback_for_parameter_info_response_callback (f); + } + + +/* ---------------------------------------------------------------------------*/ + +long fapia_set_callback_for_parameter_read_request_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *)) + { + return FAPIA_CONTROLLER->fapia_set_callback_for_parameter_read_request_callback (f); + } + + +/* ---------------------------------------------------------------------------*/ + +long fapia_set_callback_for_parameter_write_request_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAValue *)) + { + return FAPIA_CONTROLLER->fapia_set_callback_for_parameter_write_request_callback (f); + } + + +/* ---------------------------------------------------------------------------*/ + +long fapia_set_callback_for_parameter_info_request_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *)) + { + return FAPIA_CONTROLLER->fapia_set_callback_for_parameter_info_request_callback (f); + } + + +/* ---------------------------------------------------------------------------*/ + +long fapia_parameter_read_request ( + FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters) + { + return FAPIA_CONTROLLER->fapia_parameter_read_request ( + fapia_communication, + fapia_parameters); + } + + +/* ---------------------------------------------------------------------------*/ +#if 0 +long fapia_parameter_read_response_callback ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAValue * const fapia_values, + const FAPIAError * const fapia_errors) + { + return FAPIA_CONTROLLER->fapia_parameter_read_response_callback ( + fapia_communication, + fapia_parameters, + fapia_values, + fapia_errors); + } + + +/* ---------------------------------------------------------------------------*/ + +long fapia_parameter_read_request_callback ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters) + { + return FAPIA_CONTROLLER->fapia_parameter_read_request_callback ( + fapia_communication, + fapia_parameters); + } +#endif + +/* ---------------------------------------------------------------------------*/ + +long fapia_parameter_read_response ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAValue * const fapia_values, + const FAPIAError * const fapia_errors) + { + return FAPIA_CONTROLLER->fapia_parameter_read_response ( + fapia_communication, + fapia_parameters, + fapia_values, + fapia_errors); + } + + +/* ---------------------------------------------------------------------------*/ + +long fapia_parameter_write_request ( + FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAValue * const fapia_values) + { + return FAPIA_CONTROLLER->fapia_parameter_write_request ( + fapia_communication, + fapia_parameters, + fapia_values); + } + + +/* ---------------------------------------------------------------------------*/ +#if 0 +long fapia_parameter_write_response_callback ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAError * const fapia_errors) + { + return FAPIA_CONTROLLER->fapia_parameter_write_response_callback ( + fapia_communication, + fapia_parameters, + fapia_errors); + } + + +/* ---------------------------------------------------------------------------*/ + +long fapia_parameter_write_request_callback ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAValue * const fapia_values) + { + return FAPIA_CONTROLLER->fapia_parameter_write_request_callback ( + fapia_communication, + fapia_parameters, + fapia_values); + } +#endif + +/* ---------------------------------------------------------------------------*/ + +long fapia_parameter_write_response ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAError * const fapia_errors) + { + return FAPIA_CONTROLLER->fapia_parameter_write_response ( + fapia_communication, + fapia_parameters, + fapia_errors); + } + +/* ---------------------------------------------------------------------------*/ + +long fapia_parameter_info_request ( + FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters) + { + return FAPIA_CONTROLLER->fapia_parameter_info_request ( + fapia_communication, + fapia_parameters); + } + + +/* ---------------------------------------------------------------------------*/ +#if 0 +long fapia_parameter_info_response_callback ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAInfo * const fapia_infos, + const FAPIAError * const fapia_errors) + { + return FAPIA_CONTROLLER->fapia_parameter_info_response_callback ( + fapia_communication, + fapia_parameters, + fapia_infos, + fapia_errors); + } + + +/* ---------------------------------------------------------------------------*/ + +long fapia_parameter_info_request_callback ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters) + { + return FAPIA_CONTROLLER->fapia_parameter_info_request_callback ( + fapia_communication, + fapia_parameters); + } +#endif + +/* ---------------------------------------------------------------------------*/ + +long fapia_parameter_info_response ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAInfo * const fapia_infos, + const FAPIAError * const fapia_errors) + { + return FAPIA_CONTROLLER->fapia_parameter_info_response ( + fapia_communication, + fapia_parameters, + fapia_infos, + fapia_errors); + } + +/* ---------------------------------------------------------------------------*/ Added: fapia-trunk/FAPIAController/source/FAPIAControllerController.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/source/FAPIAControllerController.cpp Thu Jul 19 07:08:51 2007 @@ -0,0 +1,2731 @@ +// $Id$ + + +#include "FAPIAControllerController.h" +#include "FAPIAControllerReplyCommandHandler.h" +#include "../../FAPIAConfiguration/interface/FAPIAIConfiguration.h" +#include "../../FAPIAConfiguration/interface/FAPIAConfiguration.h" +#include "../../FAPIAIPCParameter/interface/FAPIAIPCIParameter.h" +#include "../../FAPIAIPCParameter/interface/FAPIAIPCParameterImplementation.h" +#include "../../FAPIAIPCSynchronize/interface/FAPIAIPCSynchronize.h" +#include "../../interface/FAPIATrace.h" +#include /**/ + +namespace FAPI + { + namespace Acyclic + { + namespace Controller + { + +/* ---------------------------------------------------------------------------*/ + + Controller::Controller (void) + { + FAPIA_TRACE; + + // Initialize ACE first. + ACE::init (); + ACE_LOG_MSG->priority_mask ( + LM_ERROR | + LM_CRITICAL | + LM_ALERT | + LM_EMERGENCY, + ACE_Log_Msg::PROCESS); + + // Initialize members. + state_ = INITIAL; + transaction_id_ = 0; + physical_object_name_ = ""; + number_of_logical_object_names_ = 0; + logical_object_names_ = 0; + reply_command_handler_ = 0; + parameter_read_response_callback_ = 0; + parameter_write_response_callback_ = 0; + parameter_info_response_callback_ = 0; + parameter_read_request_callback_ = 0; + parameter_write_request_callback_ = 0; + parameter_info_request_callback_ = 0; + ipc_parameter_ = 0; + ipc_synchronize_ = 0; + } + +/* ---------------------------------------------------------------------------*/ + + Controller::~Controller (void) + { + FAPIA_TRACE; + + state_ = SHUTDOWN; + + // Free members. + physical_object_name_ = ""; + + if (logical_object_names_ != 0) + { + unsigned long i = 0; + for (i = 0; i < number_of_logical_object_names_; ++i) + { + delete [] logical_object_names_[i]; + logical_object_names_[i] = 0; + } + delete [] logical_object_names_; + logical_object_names_ = 0; + number_of_logical_object_names_ = 0; + } + + logical_physical_object_names_.clear (); + + // Shut down reply command handler. + if (this->shutdown_reply_command_handler () < 0) + { + FAPIA_DEBUG ( + LM_ERROR, + "Error on shutdown of reply command handler.\n"); + } + parameter_read_response_callback_ = 0; + parameter_write_response_callback_ = 0; + parameter_info_response_callback_ = 0; + parameter_read_request_callback_ = 0; + parameter_write_request_callback_ = 0; + parameter_info_request_callback_ = 0; + if (ipc_parameter_) + { + delete ipc_parameter_; + ipc_parameter_ = 0; + } + if (ipc_synchronize_) + { + delete ipc_synchronize_; + ipc_synchronize_ = 0; + } + + // Cleanup ACE. + ACE::fini (); + state_ = EXITED; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::fapia_init ( + int argc, + char* argv[], + const char * const name) + { + FAPIA_TRACE; + + // Check if state is valid. + if (state_ == RUNNING) + { + FAPIA_DEBUG ( + LM_WARNING, + "State is already running.\n"); + return -1; + } + + if (state_ == ABORTED) + { + FAPIA_DEBUG ( + LM_ERROR, + "State is aborted.\n"); + return -1; + } + + if (state_ == SHUTDOWN) + { + FAPIA_DEBUG ( + LM_ERROR, + "Shutdown in progress.\n"); + return -1; + } + + + // Initialize Logging from argc, argv + if (this->process_commandline_arguments (argc, argv) < 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error processing commandline.\n"); + state_ = ABORTED; + return -1; + } + + + // Initialize own module. + this->physical_object_name_ = name; + + ACE_NEW_NORETURN ( + reply_command_handler_, + FAPI::Acyclic::Controller::ReplyCommandHandler ( + this, + &this->receive_queue_)); + if (reply_command_handler_ == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPI::Acyclic::Controller::ReplyCommandHandler.\n"); + state_ = ABORTED; + return -1; + } + + // Start up the created thread; + if (reply_command_handler_->activate () == -1) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error activating reply_command_handler.\n"); + delete reply_command_handler_; + reply_command_handler_ = 0; + state_ = ABORTED; + } + ACE_Thread::yield (); + ACE_OS::sleep(1); + + // Retrieve initialization data from configuration module. + FAPI::Acyclic::IConfiguration * configuration = 0; + ACE_NEW_NORETURN ( + configuration, + FAPI::Acyclic::Configuration::Configuration ()); + + if (configuration == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPI::Acyclic::Configuration::Configuration.\n"); + if (this->shutdown_reply_command_handler () < 0) + { + FAPIA_DEBUG ( + LM_ERROR, + "Error on shutdown of reply command handler.\n"); + } + state_ = ABORTED; + return -1; + } + + FAPI::Acyclic::Configuration::Init configuration_init; + FAPI::Acyclic::Configuration::Error configuration_error; + + configuration_init.physical_object_name_ = + this->physical_object_name_; + + if (configuration->init( + configuration_init, + configuration_error) + < 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error %d initializing Configuration module. Reason: %C\n", + configuration_error.error_code_, + configuration_error.reason_.c_str ()); + + if (this->shutdown_reply_command_handler () < 0) + { + FAPIA_DEBUG ( + LM_ERROR, + "Error on shutdown of reply command handler.\n"); + } + delete configuration; + configuration = 0; + state_ = ABORTED; + return -1; + } + + // Not needed any more. + delete configuration; + configuration = 0; + +#ifdef WIN32 + configuration_init.fapia_shared_memory_name_ = "C:\\machine1\\sharedmem\\FAPIA_Shared_Memory.txt"; +#else + configuration_init.fapia_shared_memory_name_ = "/sharedmem/FAPIA_Shared_Memory.txt"; +#endif + + ACE_NEW_NORETURN (this->logical_object_names_, char *[configuration_init.logical_physical_objects_.size ()]); + if (logical_object_names_ == 0) + { + FAPIA_DEBUG ( + LM_ERROR, + "Array for logical objects could not be allocated.\n"); + state_ = ABORTED; + return -1; + } + + number_of_logical_object_names_ = configuration_init.logical_physical_objects_.size (); + + // Create the mapping between logical and physical object names. + unsigned long i = 0; + for (i = 0; i < configuration_init.logical_physical_objects_.size (); ++i) + { + int rc = this->logical_physical_object_names_.bind ( + configuration_init.logical_physical_objects_[i].logical_object_name_, + configuration_init.logical_physical_objects_[i].physical_object_name_); + if (rc == 1) + { + FAPIA_DEBUG ( + LM_ERROR, + "Logical object %C and physical object %C are already bounded together\n", + configuration_init.logical_physical_objects_[i].logical_object_name_.c_str (), + configuration_init.logical_physical_objects_[i].physical_object_name_.c_str ()); + } + else if (rc == -1) + { + FAPIA_DEBUG ( + LM_ALERT, + "Logical object %C and physical object %C could not be bounded together\n", + configuration_init.logical_physical_objects_[i].logical_object_name_.c_str (), + configuration_init.logical_physical_objects_[i].physical_object_name_.c_str ()); + + if (this->shutdown_reply_command_handler () < 0) + { + FAPIA_DEBUG ( + LM_ERROR, + "Error on shutdown of reply command handler.\n"); + } + state_ = ABORTED; + } + + ACE_NEW_NORETURN (this->logical_object_names_[i], char [configuration_init.logical_physical_objects_[i].logical_object_name_.length () + 1]); + if (logical_object_names_[i] == 0) + { + FAPIA_DEBUG ( + LM_ERROR, + "Memory for logical object %C could not be allocated.\n", + configuration_init.logical_physical_objects_[i].logical_object_name_.c_str ()); + state_ = ABORTED; + } + if (state_ == ABORTED) + { + unsigned long j = 0; + for (j = 0; j < i; ++j) + { + if (logical_object_names_ != 0) + { + delete [] logical_object_names_[j]; + logical_object_names_[j] = 0; + } + } + delete [] logical_object_names_; + logical_object_names_ = 0; + number_of_logical_object_names_ = 0; + this->logical_physical_object_names_.clear (); + return -1; + } + + ACE_OS::strcpy ( + logical_object_names_[i], + configuration_init.logical_physical_objects_[i].logical_object_name_.c_str ()); + } + + + // Initialize parameter module. + ipc_parameter_ = 0; + ACE_NEW_NORETURN (ipc_parameter_, FAPI::Acyclic::IPC::Parameter::ParameterImplementation ()); + if (ipc_parameter_ == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPI::Acyclic::IPC::Parameter::Parameter.\n"); + if (this->shutdown_reply_command_handler () < 0) + { + FAPIA_DEBUG ( + LM_ERROR, + "Error on shutdown of reply command handler.\n"); + } + state_ = ABORTED; + return -1; + } + + FAPI::Acyclic::IPC::Parameter::Init ipc_parameter_init; + FAPI::Acyclic::IPC::Parameter::Error ipc_parameter_error; + + // Physical object address of this process. + ACE_CString physical_object_address; + + ipc_parameter_init.receive_queue_ = &(this->receive_queue_); + ipc_parameter_init.send_queue_ = &(this->send_queue_); + + if (ipc_parameter_->init ( + ipc_parameter_init, + physical_object_address, + ipc_parameter_error) + < 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error %d initializing Parameter module. Reason: %C\n", + ipc_parameter_error.error_code_, + ipc_parameter_error.reason_.c_str ()); + if (this->shutdown_reply_command_handler () < 0) + { + FAPIA_DEBUG ( + LM_ERROR, + "Error on shutdown of reply command handler.\n"); + } + delete ipc_parameter_; + ipc_parameter_ = 0; + state_ = ABORTED; + return -1; + } + + + + // Initialize synchronize module. + ipc_synchronize_ = 0; + ACE_NEW_NORETURN (ipc_synchronize_, FAPI::Acyclic::IPC::Synchronize::Synchronize ()); + if (ipc_synchronize_ == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPI::Acyclic::IPC::Synchronize::Synchronize.\n"); + if (this->shutdown_reply_command_handler () < 0) + { + FAPIA_DEBUG ( + LM_ERROR, + "Error on shutdown of reply command handler.\n"); + } + delete ipc_parameter_; + ipc_parameter_ = 0; + state_ = ABORTED; + return -1; + } + + FAPI::Acyclic::IPC::Synchronize::Init ipc_synchronize_init; + FAPI::Acyclic::IPC::Synchronize::Error ipc_synchronize_error; + + ipc_synchronize_init.fapia_shared_memory_name_ = + configuration_init.fapia_shared_memory_name_; + + ipc_synchronize_init.physical_object_address_ = + physical_object_address; + + ipc_synchronize_init.physical_object_name_ = + this->physical_object_name_; + + if (ipc_synchronize_->init ( + ipc_synchronize_init, + ipc_synchronize_error) + < 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error %d initializing Synchronize module. Reason: %C\n", + ipc_synchronize_error.error_code_, + ipc_synchronize_error.reason_.c_str ()); + if (this->shutdown_reply_command_handler () < 0) + { + FAPIA_DEBUG ( + LM_ERROR, + "Error on shutdown of reply command handler.\n"); + } + delete ipc_parameter_; + ipc_parameter_ = 0; + delete ipc_synchronize_; + ipc_synchronize_ = 0; + state_ = ABORTED; + return -1; + } + + state_ = RUNNING; + return 0; + } + + +/* ---------------------------------------------------------------------------*/ + + long Controller::fapia_deinit (void) + { + FAPIA_TRACE; + + state_ = SHUTDOWN; + + // Free members. + physical_object_name_ = ""; + this->logical_physical_object_names_.clear (); + + long rc = 0; + if (ipc_parameter_) + { + if (ipc_parameter_->deinit () < 0) + { + FAPIA_DEBUG ( + LM_ERROR, + "Error deinitializing Parameter module.\n"); + rc = -1; + } + delete ipc_parameter_; + ipc_parameter_ = 0; + } + if (ipc_synchronize_) + { + if (ipc_synchronize_->deinit () < 0) + { + FAPIA_DEBUG ( + LM_ERROR, + "Error deinitializing Synchronization module.\n"); + rc = -1; + } + delete ipc_synchronize_; + ipc_synchronize_ = 0; + } + + // Shut down reply command handler. + if (this->shutdown_reply_command_handler () < 0) + { + FAPIA_DEBUG ( + LM_ERROR, + "Error on shutdown of reply command handler.\n"); + rc = -1; + } + + state_ = EXITED; + return rc; + } + + +/* ---------------------------------------------------------------------------*/ + + long Controller::fapia_logical_object_names ( + char*** logical_object_names, + unsigned long* number_of_logical_object_names) + { + if (number_of_logical_object_names_ == 0) + { + *logical_object_names = 0; + *number_of_logical_object_names = 0; + return -1; + } + + *logical_object_names = logical_object_names_; + *number_of_logical_object_names = number_of_logical_object_names_; + return 0; + } + + +/* ---------------------------------------------------------------------------*/ + + long Controller::fapia_set_callback_for_parameter_read_response_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAValue *, + const FAPIAError *)) + { + FAPIA_TRACE; + + parameter_read_response_callback_ = f; + return 0; + } + + +/* ---------------------------------------------------------------------------*/ + + long Controller::fapia_set_callback_for_parameter_write_response_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAError *)) + { + FAPIA_TRACE; + + parameter_write_response_callback_ = f; + return 0; + } + + +/* ---------------------------------------------------------------------------*/ + + long Controller::fapia_set_callback_for_parameter_info_response_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAInfo *, + const FAPIAError *)) + { + FAPIA_TRACE; + + parameter_info_response_callback_ = f; + return 0; + } + + +/* ---------------------------------------------------------------------------*/ + + long Controller::fapia_set_callback_for_parameter_read_request_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *)) + { + FAPIA_TRACE; + + parameter_read_request_callback_ = f; + return 0; + } + + +/* ---------------------------------------------------------------------------*/ + + long Controller::fapia_set_callback_for_parameter_write_request_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAValue *)) + { + FAPIA_TRACE; + + parameter_write_request_callback_ = f; + return 0; + } + + +/* ---------------------------------------------------------------------------*/ + + long Controller::fapia_set_callback_for_parameter_info_request_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *)) + { + FAPIA_TRACE; + + parameter_info_request_callback_ = f; + return 0; + } + + +/* ---------------------------------------------------------------------------*/ + + long Controller::fapia_parameter_read_request ( + FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters) + { + FAPIA_TRACE; + + + // Check if controller can work. + if (state_ != RUNNING) + { + FAPIA_DEBUG ( + LM_WARNING, + "State is not running.\n"); + return -1; + } + + if (this->parameter_read_response_callback_ == 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error: no callback method set, this->parameter_read_response_callback_ not valid.\n"); + return -1; + } + + + this->increment_and_get_transaction_id ( + fapia_communication->transaction_id); + + // Create method request. + FAPI::Acyclic::IPC::Parameter::MethodRequestReadRequest* mr_read_request = 0; + + ACE_NEW_NORETURN ( + mr_read_request, + FAPI::Acyclic::IPC::Parameter::MethodRequestReadRequest ()); + + if (mr_read_request == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPI::Acyclic::IPC::Parameter::MethodRequestReadRequest"); + return -1; + } + + if (this->convert_to_read_request ( + mr_read_request, + fapia_communication, + fapia_parameters) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error convert_to_read_request failed.\n"); + delete mr_read_request; + mr_read_request = 0; + return -1; + } + + this->send_queue_.enqueue (mr_read_request); + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::fapia_parameter_read_response ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAValue * const fapia_values, + const FAPIAError * const fapia_errors) + { + FAPIA_TRACE; + + // Check if controller can work. + if (state_ != RUNNING) + { + FAPIA_DEBUG ( + LM_WARNING, + "State is not running.\n"); + return -1; + } + + // Create method request. + FAPI::Acyclic::IPC::Parameter::MethodRequestReadResponse* mr_read_response = 0; + + ACE_NEW_NORETURN ( + mr_read_response, + FAPI::Acyclic::IPC::Parameter::MethodRequestReadResponse ()); + + if (mr_read_response == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPI::Acyclic::IPC::Parameter::MethodRequestReadResponse"); + return -1; + } + + if (this->convert_to_read_response ( + mr_read_response, + fapia_communication, + fapia_parameters, + fapia_values, + fapia_errors) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error convert_to_read_response failed.\n"); + delete mr_read_response; + mr_read_response = 0; + return -1; + } + + this->send_queue_.enqueue (mr_read_response); + return 0; + } + + +/* ---------------------------------------------------------------------------*/ + + long Controller::fapia_parameter_write_request ( + FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAValue * const fapia_values) + { + FAPIA_TRACE; + + // Check if controller can work. + if (state_ != RUNNING) + { + FAPIA_DEBUG ( + LM_WARNING, + "State is not running.\n"); + return -1; + } + + if (this->parameter_write_response_callback_ == 0 && fapia_communication->send_reply) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error: no callback method set, this->parameter_write_response_callback_ not valid.\n"); + return -1; + } + + + + this->increment_and_get_transaction_id ( + fapia_communication->transaction_id); + + // Create method request. + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteRequest* mr_write_request = 0; + + ACE_NEW_NORETURN ( + mr_write_request, + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteRequest ()); + + if (mr_write_request == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPI::Acyclic::IPC::Parameter::MethodRequestWriteRequest"); + return -1; + } + + if (this->convert_to_write_request ( + mr_write_request, + fapia_communication, + fapia_parameters, + fapia_values) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error convert_to_write_request failed.\n"); + delete mr_write_request; + mr_write_request = 0; + return -1; + } + + this->send_queue_.enqueue (mr_write_request); + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::fapia_parameter_write_response ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAError * const fapia_errors) + { + FAPIA_TRACE; + + // Check if controller can work. + if (state_ != RUNNING) + { + FAPIA_DEBUG ( + LM_WARNING, + "State is not running.\n"); + return -1; + } + + // Create method request. + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteResponse* mr_write_response = 0; + + ACE_NEW_NORETURN ( + mr_write_response, + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteResponse ()); + + if (mr_write_response == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPI::Acyclic::IPC::Parameter::MethodRequestWriteResponse"); + return -1; + } + + if (this->convert_to_write_response ( + mr_write_response, + fapia_communication, + fapia_parameters, + fapia_errors) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error convert_to_write_response failed.\n"); + delete mr_write_response; + mr_write_response = 0; + return -1; + } + + this->send_queue_.enqueue (mr_write_response); + return 0; + } + + +/* ---------------------------------------------------------------------------*/ + + long Controller::fapia_parameter_info_request ( + FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters) + { + FAPIA_TRACE; + + // Check if controller can work. + if (state_ != RUNNING) + { + FAPIA_DEBUG ( + LM_WARNING, + "State is not running.\n"); + return -1; + } + + if (this->parameter_info_response_callback_ == 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error: no callback method set, this->parameter_info_response_callback_ not valid.\n"); + return -1; + } + + + + this->increment_and_get_transaction_id ( + fapia_communication->transaction_id); + + // Create method request. + FAPI::Acyclic::IPC::Parameter::MethodRequestInfoRequest* mr_info_request = 0; + + ACE_NEW_NORETURN ( + mr_info_request, + FAPI::Acyclic::IPC::Parameter::MethodRequestInfoRequest ()); + + if (mr_info_request == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPI::Acyclic::IPC::Parameter::MethodRequestInfoRequest"); + return -1; + } + + if (this->convert_to_info_request ( + mr_info_request, + fapia_communication, + fapia_parameters) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error convert_to_info_request failed.\n"); + delete mr_info_request; + mr_info_request = 0; + return -1; + } + + this->send_queue_.enqueue (mr_info_request); + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::fapia_parameter_info_response ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAInfo * const fapia_infos, + const FAPIAError * const fapia_errors) + { + FAPIA_TRACE; + + // Check if controller can work. + if (state_ != RUNNING) + { + FAPIA_DEBUG ( + LM_WARNING, + "State is not running.\n"); + return -1; + } + + // Create method request. + FAPI::Acyclic::IPC::Parameter::MethodRequestInfoResponse* mr_info_response = 0; + + ACE_NEW_NORETURN ( + mr_info_response, + FAPI::Acyclic::IPC::Parameter::MethodRequestInfoResponse ()); + + if (mr_info_response == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPI::Acyclic::IPC::Parameter::MethodRequestInfoResponse"); + return -1; + } + + if (this->convert_to_info_response ( + mr_info_response, + fapia_communication, + fapia_parameters, + fapia_infos, + fapia_errors) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error convert_to_info_response failed.\n"); + delete mr_info_response; + mr_info_response = 0; + return -1; + } + + this->send_queue_.enqueue (mr_info_response); + return 0; + } + + +/* ---------------------------------------------------------------------------*/ + + void Controller::increment_and_get_transaction_id ( + unsigned long& transaction_id) + { + FAPIA_TRACE; + + ACE_Guard lock (transaction_id_mutex_); + ++this->transaction_id_; + transaction_id = this->transaction_id_; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert_to_read_request ( + FAPI::Acyclic::IPC::Parameter::MethodRequestReadRequest* mr, + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters) + { + FAPIA_TRACE; + + // Call the convert functions. + if (this->convert ( + mr->communication_, + fapia_communication) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting fapia_communication to parameter communication.\n"); + return -1; + } + + if (this->convert ( + mr->parameters_, + fapia_parameters, + fapia_communication->number_of_entries) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting fapia_parameters to parameter parameters.\n"); + return -1; + } + + mr->priority (fapia_communication->priority); + + // Retrieve physical object address. + ACE_CString physical_object_address; + FAPI::Acyclic::IPC::Synchronize::Error ipc_synchronize_error; + ACE_CString destination_physical_object_name; + + + int rc = logical_physical_object_names_.find ( + fapia_communication->logical_object_name, + destination_physical_object_name); + + if (rc != 0) + { + // Maybe the logical_object_name is a physical object. + // Just try it. + destination_physical_object_name = + fapia_communication->logical_object_name; + } + + + if (this->ipc_synchronize_->retrieve_physical_object_address ( + destination_physical_object_name, + physical_object_address, + ipc_synchronize_error) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error %d: physical object address could not be retrieved. Reason: %C\n", + ipc_synchronize_error.error_code_, + ipc_synchronize_error.reason_.c_str ()); + return -1; + } + + mr->destination_physical_object_address_ = + physical_object_address; + + return 0; + } + + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert_from_read_request ( + FAPIACommunication * const fapia_communication, + FAPIAParameter * const fapia_parameters, + const FAPI::Acyclic::IPC::Parameter::MethodRequestReadRequest* mr) + { + FAPIA_TRACE; + + // Call the convert functions. + if (this->convert ( + fapia_communication, + mr->communication_) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting parameter communication to fapia_communication.\n"); + return -1; + } + + fapia_communication->number_of_entries = + mr->parameters_.size (); + fapia_communication->priority = (FAPIACommunicationPriority)mr->priority (); + + if (this->convert ( + fapia_parameters, + mr->parameters_) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting parameter parameters to fapia_parameters.\n"); + this->free_memory (fapia_communication); + return -1; + } + + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert_to_read_response ( + FAPI::Acyclic::IPC::Parameter::MethodRequestReadResponse* mr, + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAValue * const fapia_values, + const FAPIAError * const fapia_errors) + { + FAPIA_TRACE; + + // Call the convert functions. + if (this->convert ( + mr->communication_, + fapia_communication) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting fapia_communication to parameter communication.\n"); + return -1; + } + + // Reset physical object name of source. + mr->communication_.source_physical_object_name_ = + fapia_communication->source_physical_object_name; + + + if (this->convert ( + mr->parameters_, + fapia_parameters, + fapia_communication->number_of_entries) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting fapia_parameters to parameter parameters.\n"); + return -1; + } + + if (this->convert ( + mr->values_, + fapia_values, + fapia_communication->number_of_entries) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting fapia_values to parameter values.\n"); + return -1; + } + if (this->convert ( + mr->errors_, + fapia_errors, + fapia_communication->number_of_entries) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting fapia_errors to parameter errors.\n"); + return -1; + } + + mr->priority (fapia_communication->priority); + + // Retrieve physical object address. + ACE_CString physical_object_address; + FAPI::Acyclic::IPC::Synchronize::Error ipc_synchronize_error; + + if (this->ipc_synchronize_->retrieve_physical_object_address ( + mr->communication_.source_physical_object_name_, + physical_object_address, + ipc_synchronize_error) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error %d: physical object address could not be retrieved. Reason: %C\n", + ipc_synchronize_error.error_code_, + ipc_synchronize_error.reason_.c_str ()); + return -1; + } + + mr->destination_physical_object_address_ = + physical_object_address; + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert_from_read_response ( + FAPIACommunication * const fapia_communication, + FAPIAParameter * const fapia_parameters, + FAPIAValue * const fapia_values, + FAPIAError * const fapia_errors, + const FAPI::Acyclic::IPC::Parameter::MethodRequestReadResponse* mr) + { + FAPIA_TRACE; + + // Call the convert functions. + if (this->convert ( + fapia_communication, + mr->communication_) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting parameter communication to fapia_communication.\n"); + return -1; + } + + fapia_communication->number_of_entries = + mr->parameters_.size (); + fapia_communication->priority = (FAPIACommunicationPriority)mr->priority (); + + if (this->convert ( + fapia_parameters, + mr->parameters_) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting parameter parameters to fapia_parameters.\n"); + this->free_memory (fapia_communication); + return -1; + } + + if (this->convert ( + fapia_values, + mr->values_) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting parameter values to fapia_values.\n"); + this->free_memory (fapia_parameters, fapia_communication->number_of_entries); + this->free_memory (fapia_communication); + return -1; + } + + if (this->convert ( + fapia_errors, + mr->errors_) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting parameter errors to fapia_errors.\n"); + this->free_memory (fapia_values, fapia_communication->number_of_entries); + this->free_memory (fapia_parameters, fapia_communication->number_of_entries); + this->free_memory (fapia_communication); + return -1; + } + + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert_to_write_request ( + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteRequest* mr, + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAValue * const fapia_values) + { + FAPIA_TRACE; + + // Call the convert functions. + if (this->convert ( + mr->communication_, + fapia_communication) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting fapia_communication to parameter communication.\n"); + return -1; + } + + if (this->convert ( + mr->parameters_, + fapia_parameters, + fapia_communication->number_of_entries) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting fapia_parameters to parameter parameters.\n"); + return -1; + } + + if (this->convert ( + mr->values_, + fapia_values, + fapia_communication->number_of_entries) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting fapia_values to parameter values.\n"); + return -1; + } + mr->priority (fapia_communication->priority); + + // Retrieve physical object address. + ACE_CString physical_object_address; + FAPI::Acyclic::IPC::Synchronize::Error ipc_synchronize_error; + ACE_CString destination_physical_object_name; + + + int rc = logical_physical_object_names_.find ( + fapia_communication->logical_object_name, + destination_physical_object_name); + + if (rc != 0) + { + // Maybe the logical_object_name is a physical object. + // Just try it. + destination_physical_object_name = + fapia_communication->logical_object_name; + } + + + if (this->ipc_synchronize_->retrieve_physical_object_address ( + destination_physical_object_name, + physical_object_address, + ipc_synchronize_error) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error %d: physical object address could not be retrieved. Reason: %C\n", + ipc_synchronize_error.error_code_, + ipc_synchronize_error.reason_.c_str ()); + return -1; + } + + mr->destination_physical_object_address_ = + physical_object_address; + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert_from_write_request ( + FAPIACommunication* const fapia_communication, + FAPIAParameter * const fapia_parameters, + FAPIAValue * const fapia_values, + const FAPI::Acyclic::IPC::Parameter::MethodRequestWriteRequest* mr) + { + FAPIA_TRACE; + + // Call the convert functions. + if (this->convert ( + fapia_communication, + mr->communication_) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting parameter communication to fapia_communication.\n"); + return -1; + } + + fapia_communication->number_of_entries = + mr->parameters_.size (); + fapia_communication->priority = (FAPIACommunicationPriority)mr->priority (); + + if (this->convert ( + fapia_parameters, + mr->parameters_) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting parameter parameters to fapia_parameters.\n"); + this->free_memory (fapia_communication); + return -1; + } + + if (this->convert ( + fapia_values, + mr->values_) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting parameter values to fapia_values.\n"); + this->free_memory (fapia_parameters, fapia_communication->number_of_entries); + this->free_memory (fapia_communication); + return -1; + } + + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert_to_write_response ( + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteResponse* mr, + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAError * const fapia_errors) + { + FAPIA_TRACE; + + // Call the convert functions. + if (this->convert ( + mr->communication_, + fapia_communication) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting fapia_communication to parameter communication.\n"); + return -1; + } + + // Reset physical object name of source. + mr->communication_.source_physical_object_name_ = + fapia_communication->source_physical_object_name; + + if (this->convert ( + mr->parameters_, + fapia_parameters, + fapia_communication->number_of_entries) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting fapia_parameters to parameter parameters.\n"); + return -1; + } + + if (this->convert ( + mr->errors_, + fapia_errors, + fapia_communication->number_of_entries) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting fapia_errors to parameter errors.\n"); + return -1; + } + + mr->priority (fapia_communication->priority); + + // Retrieve physical object address. + ACE_CString physical_object_address; + FAPI::Acyclic::IPC::Synchronize::Error ipc_synchronize_error; + + if (this->ipc_synchronize_->retrieve_physical_object_address ( + fapia_communication->source_physical_object_name, + physical_object_address, + ipc_synchronize_error) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error %d: physical object address could not be retrieved. Reason: %C\n", + ipc_synchronize_error.error_code_, + ipc_synchronize_error.reason_.c_str ()); + return -1; + } + + mr->destination_physical_object_address_ = + physical_object_address; + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert_from_write_response ( + FAPIACommunication * const fapia_communication, + FAPIAParameter * const fapia_parameters, + FAPIAError * const fapia_errors, + const FAPI::Acyclic::IPC::Parameter::MethodRequestWriteResponse* mr) + { + FAPIA_TRACE; + + // Call the convert functions. + if (this->convert ( + fapia_communication, + mr->communication_) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting parameter communication to fapia_communication.\n"); + return -1; + } + + fapia_communication->number_of_entries = + mr->parameters_.size (); + fapia_communication->priority = (FAPIACommunicationPriority)mr->priority (); + + if (this->convert ( + fapia_parameters, + mr->parameters_) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting parameter parameters to fapia parameters.\n"); + this->free_memory (fapia_communication); + return -1; + } + + if (this->convert ( + fapia_errors, + mr->errors_) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting parameter errors to fapia_errors.\n"); + this->free_memory (fapia_parameters, fapia_communication->number_of_entries); + this->free_memory (fapia_communication); + return -1; + } + + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert_to_info_request ( + FAPI::Acyclic::IPC::Parameter::MethodRequestInfoRequest* mr, + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters) + { + FAPIA_TRACE; + + // Call the convert functions. + if (this->convert ( + mr->communication_, + fapia_communication) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting fapia_communication to parameter communication.\n"); + return -1; + } + + if (this->convert ( + mr->parameters_, + fapia_parameters, + fapia_communication->number_of_entries) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting fapia_parameters to parameter parameters.\n"); + return -1; + } + + mr->priority (fapia_communication->priority); + + // Retrieve physical object address. + ACE_CString physical_object_address; + FAPI::Acyclic::IPC::Synchronize::Error ipc_synchronize_error; + ACE_CString destination_physical_object_name; + + + int rc = logical_physical_object_names_.find ( + fapia_communication->logical_object_name, + destination_physical_object_name); + + if (rc != 0) + { + // Maybe the logical_object_name is a physical object. + // Just try it. + destination_physical_object_name = + fapia_communication->logical_object_name; + } + + + if (this->ipc_synchronize_->retrieve_physical_object_address ( + destination_physical_object_name, + physical_object_address, + ipc_synchronize_error) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error %d: physical object address could not be retrieved. Reason: %C\n", + ipc_synchronize_error.error_code_, + ipc_synchronize_error.reason_.c_str ()); + return -1; + } + + mr->destination_physical_object_address_ = + physical_object_address; + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert_from_info_request ( + FAPIACommunication* const fapia_communication, + FAPIAParameter * const fapia_parameters, + const FAPI::Acyclic::IPC::Parameter::MethodRequestInfoRequest* mr) + { + FAPIA_TRACE; + + // Call the convert functions. + if (this->convert ( + fapia_communication, + mr->communication_) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting parameter communication to fapia_communication.\n"); + return -1; + } + + fapia_communication->number_of_entries = + mr->parameters_.size (); + fapia_communication->priority = (FAPIACommunicationPriority)mr->priority (); + + if (this->convert ( + fapia_parameters, + mr->parameters_) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting parameter parameters to fapia_parameters.\n"); + this->free_memory (fapia_communication); + return -1; + } + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert_to_info_response ( + FAPI::Acyclic::IPC::Parameter::MethodRequestInfoResponse* mr, + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAInfo * const fapia_infos, + const FAPIAError * const fapia_errors) + { + FAPIA_TRACE; + + // Call the convert functions. + if (this->convert ( + mr->communication_, + fapia_communication) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting fapia_communication to parameter communication.\n"); + return -1; + } + + // Reset physical object name of source. + mr->communication_.source_physical_object_name_ = + fapia_communication->source_physical_object_name; + + if (this->convert ( + mr->parameters_, + fapia_parameters, + fapia_communication->number_of_entries) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting fapia_parameters to parameter parameters.\n"); + return -1; + } + + if (this->convert ( + mr->infos_, + fapia_infos, + fapia_communication->number_of_entries) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting fapia_infos to parameter infos.\n"); + return -1; + } + + if (this->convert ( + mr->errors_, + fapia_errors, + fapia_communication->number_of_entries) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting fapia_errors to parameter errors.\n"); + return -1; + } + + mr->priority (fapia_communication->priority); + + // Retrieve physical object address. + ACE_CString physical_object_address; + FAPI::Acyclic::IPC::Synchronize::Error ipc_synchronize_error; + + if (this->ipc_synchronize_->retrieve_physical_object_address ( + fapia_communication->source_physical_object_name, + physical_object_address, + ipc_synchronize_error) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error %d: physical object address could not be retrieved. Reason: %C\n", + ipc_synchronize_error.error_code_, + ipc_synchronize_error.reason_.c_str ()); + return -1; + } + + mr->destination_physical_object_address_ = + physical_object_address; + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert_from_info_response ( + FAPIACommunication * const fapia_communication, + FAPIAParameter * const fapia_parameters, + FAPIAInfo * const fapia_infos, + FAPIAError * const fapia_errors, + const FAPI::Acyclic::IPC::Parameter::MethodRequestInfoResponse* mr) + { + FAPIA_TRACE; + + // Call the convert functions. + if (this->convert ( + fapia_communication, + mr->communication_) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting parameter communication to fapia_communication.\n"); + return -1; + } + + fapia_communication->number_of_entries = + mr->parameters_.size (); + fapia_communication->priority = (FAPIACommunicationPriority)mr->priority (); + + if (this->convert ( + fapia_parameters, + mr->parameters_) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting parameter parameters to fapia parameters.\n"); + this->free_memory (fapia_communication); + return -1; + } + + if (this->convert ( + fapia_infos, + mr->infos_) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting parameter infos to fapia infos.\n"); + this->free_memory (fapia_communication); + this->free_memory (fapia_parameters, fapia_communication->number_of_entries); + return -1; + } + + if (this->convert ( + fapia_errors, + mr->errors_) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error converting parameter errors to fapia_errors.\n"); + this->free_memory (fapia_infos, fapia_communication->number_of_entries); + this->free_memory (fapia_parameters, fapia_communication->number_of_entries); + this->free_memory (fapia_communication); + return -1; + } + + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert ( + FAPIACommunication * const fapia_communication, + const FAPI::Acyclic::IPC::Parameter::Communication& ipc_parameter_communication) + { + FAPIA_TRACE; + + // Set communications. + fapia_communication->communication_error.error_code = + ipc_parameter_communication.communication_error_.error_code_; + + if (fapia_communication->communication_error.error_code != FAPIA_ERROR_OK) + { + // Allocate memory for the reason. + unsigned long len = ipc_parameter_communication.communication_error_.reason_.length (); + + ACE_NEW_NORETURN (fapia_communication->communication_error.reason, char[len + 1]); + if (fapia_communication->communication_error.reason == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating fapia_communication->communication_error.reason"); + return -1; + } + + // Copy content. + ACE_OS::memcpy ( + fapia_communication->communication_error.reason, + ipc_parameter_communication.communication_error_.reason_.c_str (), + len); + + // Set a trailing zero for strings. + fapia_communication->communication_error.reason[len] = '\0'; + } + else + { + fapia_communication->communication_error.reason = 0; + } + + fapia_communication->send_reply = + ipc_parameter_communication.send_reply_; + fapia_communication->transaction_id = + ipc_parameter_communication.transaction_id_; + + + // Copy logical_object_name. + + // Allocate memory for the logical_object_name. + unsigned long len = ipc_parameter_communication.logical_object_name_.length (); + + ACE_NEW_NORETURN (fapia_communication->logical_object_name, char[len + 1]); + if (fapia_communication->logical_object_name == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating fapia_communication->logical_object_name"); + return -1; + } + + // Copy content. + ACE_OS::memcpy ( + fapia_communication->logical_object_name, + ipc_parameter_communication.logical_object_name_.c_str (), + len); + + // Set a trailing zero for strings. + fapia_communication->logical_object_name[len] = '\0'; + + + + // Copy physical_object_name. + + // Allocate memory for the physical_object_name. + len = ipc_parameter_communication.source_physical_object_name_.length (); + + ACE_NEW_NORETURN (fapia_communication->source_physical_object_name, char[len + 1]); + if (fapia_communication->source_physical_object_name == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating fapia_communication->source_physical_object_name"); + + delete fapia_communication->logical_object_name; + fapia_communication->logical_object_name = 0; + + if (fapia_communication->communication_error.reason != 0) + { + delete fapia_communication->communication_error.reason; + fapia_communication->communication_error.reason = 0; + } + return -1; + } + + // Copy content. + ACE_OS::memcpy ( + fapia_communication->source_physical_object_name, + ipc_parameter_communication.source_physical_object_name_.c_str (), + len); + + // Set a trailing zero for strings. + fapia_communication->source_physical_object_name[len] = '\0'; + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert ( + FAPI::Acyclic::IPC::Parameter::Communication& ipc_parameter_communication, + const FAPIACommunication * const fapia_communication) + { + FAPIA_TRACE; + + // Set communication structure. + ipc_parameter_communication.communication_error_.error_code_ = + fapia_communication->communication_error.error_code; + + ipc_parameter_communication.communication_error_.reason_ = + fapia_communication->communication_error.reason; + + ipc_parameter_communication.send_reply_ = + fapia_communication->send_reply == 0 ? false : true; + + ipc_parameter_communication.transaction_id_ = + fapia_communication->transaction_id; + + if (fapia_communication->logical_object_name == 0) + { + FAPIA_DEBUG ( + LM_WARNING, + "Logical object name is a NULL pointer."); + return -1; + } + + ipc_parameter_communication.logical_object_name_ = + fapia_communication->logical_object_name; + + ipc_parameter_communication.source_physical_object_name_ = + this->physical_object_name_; + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert ( + FAPIAParameter * const fapia_parameters, + const FAPI::Acyclic::IPC::Parameter::Parameters& ipc_parameter_parameters) + { + FAPIA_TRACE; + + // Set parameters. + unsigned long count = ipc_parameter_parameters.size (); + unsigned long i = 0; + for (i = 0; i < count; ++i) + { + // Copy parameter_name. + + // Allocate memory for the parameter_name. + unsigned long len = ipc_parameter_parameters[i].parameter_name_.length (); + + ACE_NEW_NORETURN (fapia_parameters[i].parameter_name, char[len + 1]); + if (fapia_parameters[i].parameter_name == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating fapia_parameters[i].parameter_name"); + unsigned long j = 0; + for (j = 0; j < i; ++j) + { + delete [] fapia_parameters[j].parameter_name; + fapia_parameters[j].parameter_name = 0; + } + return -1; + } + + // Copy content. + ACE_OS::memcpy ( + fapia_parameters[i].parameter_name, + ipc_parameter_parameters[i].parameter_name_.c_str (), + len); + + // Set a trailing zero for strings. + fapia_parameters[i].parameter_name[len] = '\0'; + + } + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert ( + FAPI::Acyclic::IPC::Parameter::Parameters& ipc_parameter_parameters, + const FAPIAParameter * const fapia_parameters, + unsigned long count) + { + FAPIA_TRACE; + + // Set parameters. + FAPI::Acyclic::IPC::Parameter::Parameter ipc_parameter_parameter; + ipc_parameter_parameters.max_size (count); + + unsigned long i = 0; + for (i = 0; i < count; ++i) + { + ipc_parameter_parameter.parameter_name_ = + fapia_parameters[i].parameter_name; + + ipc_parameter_parameters.push_back ( + ipc_parameter_parameter); + } + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert ( + FAPIAValue * const fapia_values, + const FAPI::Acyclic::IPC::Parameter::Values& ipc_parameter_values) + { + FAPIA_TRACE; + + // Set values. + unsigned long count = ipc_parameter_values.size (); + unsigned long i = 0; + for (i = 0; i < count; ++i) + { + fapia_values[i].data_length = + ipc_parameter_values[i].data_len (); + fapia_values[i].data_type = + ipc_parameter_values[i].data_type_; + + + // Copy data value. + + // Allocate memory for the value. + // If string then reserve a char for trailing zero. + unsigned long len = + fapia_values[i].data_type == FAPIA_DATA_TYPE_STRING ? + fapia_values[i].data_length + 1 : + fapia_values[i].data_length; + + ACE_NEW_NORETURN (fapia_values[i].data_value, char[len]); + if (fapia_values[i].data_value == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating fapia_values[i].data_value"); + unsigned long j = 0; + for (j = 0; j < i; ++j) + { + delete [] (char *)fapia_values[j].data_value; + fapia_values[j].data_value= 0; + } + return -1; + } + + // Copy content. + ACE_OS::memcpy ( + fapia_values[i].data_value, + ipc_parameter_values[i].data_value (), + fapia_values[i].data_length); + + // Set a trailing zero for strings. + if (fapia_values[i].data_type == FAPIA_DATA_TYPE_STRING) + { + ACE_static_cast ( + char* , + fapia_values[i].data_value)[fapia_values[i].data_length] = + '\0'; + } + } + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert ( + FAPI::Acyclic::IPC::Parameter::Values& ipc_parameter_values, + const FAPIAValue * const fapia_values, + unsigned long count) + { + FAPIA_TRACE; + + // Set values. + FAPI::Acyclic::IPC::Parameter::Value ipc_parameter_value; + ipc_parameter_values.max_size (count); + + unsigned long i = 0; + for (i = 0; i < count; ++i) + { + ipc_parameter_value.data_type_ = + fapia_values[i].data_type; + if (ipc_parameter_value.data_value ( + fapia_values[i].data_value, + fapia_values[i].data_length) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error setting data_value for parameter failed.\n"); + return -1; + } + ipc_parameter_values.push_back ( + ipc_parameter_value); + } + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert ( + FAPIAInfo * const fapia_infos, + const FAPI::Acyclic::IPC::Parameter::Infos& ipc_parameter_infos) + { + FAPIA_TRACE; + + // Set infos. + unsigned long count = ipc_parameter_infos.size (); + unsigned long i = 0; + for (i = 0; i < count; ++i) + { + fapia_infos[i].data_length = + ipc_parameter_infos[i].data_len_; + fapia_infos[i].data_type = + ipc_parameter_infos[i].data_type_; + fapia_infos[i].access_rights = + ipc_parameter_infos[i].access_rights_; + fapia_infos[i].exponent = + ipc_parameter_infos[i].exponent_; + fapia_infos[i].factor = + ipc_parameter_infos[i].factor_; + + + + // Copy min value. + + if (ipc_parameter_infos[i].min_value_ != 0) + { + // Allocate memory for the info. + // If string then reserve a char for trailing zero. + unsigned long len = + fapia_infos[i].data_type == FAPIA_DATA_TYPE_STRING ? + fapia_infos[i].data_length + 1 : + fapia_infos[i].data_length; + + ACE_NEW_NORETURN (fapia_infos[i].min_value, char[len]); + if (fapia_infos[i].min_value == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating fapia_infos[i].min_value"); + unsigned long j = 0; + for (j = 0; j < i; ++j) + { + if (fapia_infos[j].min_value) + { + delete [] (char *)fapia_infos[j].min_value; + fapia_infos[j].min_value = 0; + } + if (fapia_infos[j].max_value) + { + delete [] (char *)fapia_infos[j].max_value; + fapia_infos[j].max_value = 0; + } + if (fapia_infos[j].unit) + { + delete [] (char *)fapia_infos[j].unit; + fapia_infos[j].unit = 0; + } + if (fapia_infos[j].description) + { + delete [] (char *)fapia_infos[j].description; + fapia_infos[j].description = 0; + } + } + return -1; + } + + // Copy content. + ACE_OS::memcpy ( + fapia_infos[i].min_value, + ipc_parameter_infos[i].min_value_, + fapia_infos[i].data_length); + + // Set a trailing zero for strings. + if (fapia_infos[i].data_type == FAPIA_DATA_TYPE_STRING) + { + ACE_static_cast ( + char* , + fapia_infos[i].min_value)[fapia_infos[i].data_length] = + '\0'; + } + } + else + { + fapia_infos[i].min_value = 0; + } + + // Copy max value. + + if (ipc_parameter_infos[i].max_value_ != 0) + { + // Allocate memory for the info. + // If string then reserve a char for trailing zero. + unsigned long len = + fapia_infos[i].data_type == FAPIA_DATA_TYPE_STRING ? + fapia_infos[i].data_length + 1 : + fapia_infos[i].data_length; + + ACE_NEW_NORETURN (fapia_infos[i].max_value, char[len]); + if (fapia_infos[i].max_value == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating fapia_infos[i].max_value"); + unsigned long j = 0; + for (j = 0; j < i; ++j) + { + if (fapia_infos[j].min_value) + { + delete [] (char *)fapia_infos[j].min_value; + fapia_infos[j].min_value = 0; + } + if (fapia_infos[j].max_value) + { + delete [] (char *)fapia_infos[j].max_value; + fapia_infos[j].max_value = 0; + } + if (fapia_infos[j].unit) + { + delete [] (char *)fapia_infos[j].unit; + fapia_infos[j].unit = 0; + } + if (fapia_infos[j].description) + { + delete [] (char *)fapia_infos[j].description; + fapia_infos[j].description = 0; + } + } + if (fapia_infos[i].min_value) + { + delete [] (char *)fapia_infos[i].min_value; + fapia_infos[i].min_value = 0; + } + return -1; + } + + // Copy content. + ACE_OS::memcpy ( + fapia_infos[i].max_value, + ipc_parameter_infos[i].max_value_, + fapia_infos[i].data_length); + + // Set a trailing zero for strings. + if (fapia_infos[i].data_type == FAPIA_DATA_TYPE_STRING) + { + ACE_static_cast ( + char* , + fapia_infos[i].max_value)[fapia_infos[i].data_length] = + '\0'; + } + } + else + { + fapia_infos[i].max_value = 0; + } + + // Copy unit. + + // Allocate memory for the unit. + // If string then reserve a char for trailing zero. + unsigned long len = ipc_parameter_infos[i].unit_.length (); + + ACE_NEW_NORETURN (fapia_infos[i].unit, char[len + 1]); + if (fapia_infos[i].unit == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating fapia_infos[i].unit"); + unsigned long j = 0; + for (j = 0; j < i; ++j) + { + if (fapia_infos[j].min_value) + { + delete [] (char *)fapia_infos[j].min_value; + fapia_infos[j].min_value = 0; + } + if (fapia_infos[j].max_value) + { + delete [] (char *)fapia_infos[j].max_value; + fapia_infos[j].max_value = 0; + } + + delete [] fapia_infos[j].unit; + fapia_infos[j].unit = 0; + + if (fapia_infos[j].description) + { + delete [] (char *)fapia_infos[j].description; + fapia_infos[j].description = 0; + } + } + if (fapia_infos[i].min_value) + { + delete [] (char *)fapia_infos[i].min_value; + fapia_infos[i].min_value = 0; + } + if (fapia_infos[i].max_value) + { + delete [] (char *)fapia_infos[i].max_value; + fapia_infos[i].max_value = 0; + } + + return -1; + } + + // Copy content. + ACE_OS::memcpy ( + fapia_infos[i].unit, + ipc_parameter_infos[i].unit_.c_str (), + len); + + // Set a trailing zero for strings. + fapia_infos[i].unit[len] = '\0'; + + + // Copy description. + + // Allocate memory for the description. + // If string then reserve a char for trailing zero. + len = ipc_parameter_infos[i].description_.length (); + + ACE_NEW_NORETURN (fapia_infos[i].description, char[len + 1]); + if (fapia_infos[i].description == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating fapia_infos[i].description"); + unsigned long j = 0; + for (j = 0; j < i; ++j) + { + if (fapia_infos[j].min_value) + { + delete [] (char *)fapia_infos[j].min_value; + fapia_infos[j].min_value = 0; + } + if (fapia_infos[j].max_value) + { + delete [] (char *)fapia_infos[j].max_value; + fapia_infos[j].max_value = 0; + } + + if (fapia_infos[j].unit) + { + delete [] fapia_infos[j].unit; + fapia_infos[j].unit = 0; + } + + if (fapia_infos[j].description) + { + delete [] (char *)fapia_infos[j].description; + fapia_infos[j].description = 0; + } + } + if (fapia_infos[i].min_value) + { + delete [] (char *)fapia_infos[i].min_value; + fapia_infos[i].min_value = 0; + } + if (fapia_infos[i].max_value) + { + delete [] (char *)fapia_infos[i].max_value; + fapia_infos[i].max_value = 0; + } + + if (fapia_infos[i].unit) + { + delete [] fapia_infos[i].unit; + fapia_infos[i].unit = 0; + } + + return -1; + } + + // Copy content. + ACE_OS::memcpy ( + fapia_infos[i].description, + ipc_parameter_infos[i].description_.c_str (), + len); + + // Set a trailing zero for strings. + fapia_infos[i].description[len] = '\0'; + + } + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert ( + FAPI::Acyclic::IPC::Parameter::Infos& ipc_parameter_infos, + const FAPIAInfo * const fapia_infos, + unsigned long count) + { + FAPIA_TRACE; + + // Set infos. + FAPI::Acyclic::IPC::Parameter::Info ipc_parameter_info; + ipc_parameter_infos.max_size (count); + + unsigned long i = 0; + for (i = 0; i < count; ++i) + { + ipc_parameter_info.data_type_ = + fapia_infos[i].data_type; + ipc_parameter_info.data_len_ = + fapia_infos[i].data_length; + ipc_parameter_info.access_rights_ = + fapia_infos[i].access_rights; + ipc_parameter_info.unit_ = + fapia_infos[i].unit; + ipc_parameter_info.exponent_ = + fapia_infos[i].exponent; + ipc_parameter_info.factor_ = + fapia_infos[i].factor; + ipc_parameter_info.description_ = + fapia_infos[i].description; + + unsigned long len = + fapia_infos[i].data_type == FAPIA_DATA_TYPE_STRING ? + fapia_infos[i].data_length + 1 : + fapia_infos[i].data_length; + + if (fapia_infos[i].min_value) + { + // allocate memory for the min value. + ACE_NEW_NORETURN (ipc_parameter_info.min_value_, char[len]); + if (ipc_parameter_info.min_value_ == 0) + { + FAPIA_DEBUG (LM_ALERT, + "Error allocating ipc_parameter_info.min_value_"); + unsigned long j = 0; + for (j = 0; j < i; ++j) + { + if (ipc_parameter_infos[j].min_value_) + { + delete [] (char *)ipc_parameter_infos[j].min_value_; + ipc_parameter_infos[j].min_value_ = 0; + } + if (ipc_parameter_infos[j].max_value_) + { + delete [] (char *)ipc_parameter_infos[j].max_value_; + ipc_parameter_infos[j].min_value_ = 0; + } + } + return -1; + } + + // copy content + ACE_OS::memcpy ( + ipc_parameter_info.min_value_, + fapia_infos[i].min_value, + fapia_infos[i].data_length); + + // Set a trailing zero for strings. + if (fapia_infos[i].data_type == FAPIA_DATA_TYPE_STRING) + { + ACE_static_cast ( + char* , + ipc_parameter_info.min_value_)[fapia_infos[i].data_length] = + '\0'; + } + } + else + { + ipc_parameter_info.min_value_ = 0; + } + + if (fapia_infos[i].max_value) + { + // allocate memory for the max value. + ACE_NEW_NORETURN (ipc_parameter_info.max_value_, char[len]); + if (ipc_parameter_info.max_value_ == 0) + { + FAPIA_DEBUG (LM_ALERT, + "Error allocating ipc_parameter_info.max_value_"); + unsigned long j = 0; + for (j = 0; j < i; ++j) + { + if (ipc_parameter_infos[j].min_value_) + { + delete [] (char *)ipc_parameter_infos[j].min_value_; + ipc_parameter_infos[j].min_value_ = 0; + } + if (ipc_parameter_infos[j].max_value_) + { + delete [] (char *)ipc_parameter_infos[j].max_value_; + ipc_parameter_infos[j].min_value_ = 0; + } + } + if (ipc_parameter_infos[i].min_value_) + { + delete [] (char *)ipc_parameter_infos[i].min_value_; + ipc_parameter_infos[i].min_value_ = 0; + } + return -1; + } + + // copy content + ACE_OS::memcpy ( + ipc_parameter_info.max_value_, + fapia_infos[i].max_value, + fapia_infos[i].data_length); + + // Set a trailing zero for strings. + if (fapia_infos[i].data_type == FAPIA_DATA_TYPE_STRING) + { + ACE_static_cast ( + char* , + ipc_parameter_info.max_value_)[fapia_infos[i].data_length] = + '\0'; + } + } + else + { + ipc_parameter_info.max_value_ = 0; + } + + + ipc_parameter_infos.push_back ( + ipc_parameter_info); + } + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert ( + FAPIAError * const fapia_errors, + const FAPI::Acyclic::IPC::Parameter::Errors& ipc_parameter_errors) + { + FAPIA_TRACE; + + // Set errors. + unsigned long count = ipc_parameter_errors.size (); + unsigned long i = 0; + for (i = 0; i < count; ++i) + { + fapia_errors[i].error_code = + ipc_parameter_errors[i].error_code_ ; + + + // Copy reason. + + // Allocate memory for the reason. + unsigned long len = ipc_parameter_errors[i].reason_.length (); + + ACE_NEW_NORETURN (fapia_errors[i].reason, char[len + 1]); + if (fapia_errors[i].reason == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating fapia_errors[i].reason"); + unsigned long j = 0; + for (j = 0; j < i; ++j) + { + delete [] fapia_errors[j].reason; + fapia_errors[j].reason = 0; + } + return -1; + } + + // Copy content. + ACE_OS::memcpy ( + fapia_errors[i].reason, + ipc_parameter_errors[i].reason_.c_str (), + len); + + // Set a trailing zero for strings. + fapia_errors[i].reason[len] = '\0'; + + } + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::convert ( + FAPI::Acyclic::IPC::Parameter::Errors& ipc_parameter_errors, + const FAPIAError * const fapia_errors, + unsigned long count) + { + FAPIA_TRACE; + + // Set errors. + FAPI::Acyclic::IPC::Parameter::Error ipc_parameter_error; + ipc_parameter_errors.max_size (count); + + unsigned long i = 0; + for (i = 0; i < count; ++i) + { + ipc_parameter_error.error_code_ = + fapia_errors[i].error_code; + ipc_parameter_error.reason_ = + fapia_errors[i].reason; + + ipc_parameter_errors.push_back ( + ipc_parameter_error); + } + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + void Controller::free_memory ( + FAPIACommunication * const fapia_communication) + { + FAPIA_TRACE; + + if (fapia_communication->communication_error.reason) + { + delete [] fapia_communication->communication_error.reason; + fapia_communication->communication_error.reason = 0; + } + + if (fapia_communication->logical_object_name) + { + delete [] fapia_communication->logical_object_name; + fapia_communication->logical_object_name = 0; + } + + if (fapia_communication->source_physical_object_name) + { + delete [] fapia_communication->source_physical_object_name; + fapia_communication->source_physical_object_name = 0; + } + } + +/* ---------------------------------------------------------------------------*/ + + void Controller::free_memory ( + FAPIAParameter * const fapia_parameters, + unsigned long count) + { + FAPIA_TRACE; + + unsigned long i = 0; + for (i = 0; i < count; ++i) + { + if (fapia_parameters[i].parameter_name) + { + delete [] fapia_parameters[i].parameter_name; + fapia_parameters[i].parameter_name = 0; + } + } + } + +/* ---------------------------------------------------------------------------*/ + + void Controller::free_memory ( + FAPIAValue * const fapia_values, + unsigned long count) + { + FAPIA_TRACE; + + unsigned long i = 0; + for (i = 0; i < count; ++i) + { + if (fapia_values[i].data_value) + { + delete [] (char *)fapia_values[i].data_value; + fapia_values[i].data_value = 0; + } + } + } + +/* ---------------------------------------------------------------------------*/ + + void Controller::free_memory ( + FAPIAInfo * const fapia_infos, + unsigned long count) + { + FAPIA_TRACE; + + unsigned long i = 0; + for (i = 0; i < count; ++i) + { + if (fapia_infos[i].min_value) + { + delete [] fapia_infos[i].min_value; + fapia_infos[i].min_value = 0; + } + if (fapia_infos[i].max_value) + { + delete [] fapia_infos[i].max_value; + fapia_infos[i].max_value = 0; + } + if (fapia_infos[i].unit) + { + delete [] fapia_infos[i].unit; + fapia_infos[i].unit = 0; + } + if (fapia_infos[i].description) + { + delete [] fapia_infos[i].description; + fapia_infos[i].description = 0; + } + } + } + +/* ---------------------------------------------------------------------------*/ + + void Controller::free_memory ( + FAPIAError * const fapia_errors, + unsigned long count) + { + FAPIA_TRACE; + + unsigned long i = 0; + for (i = 0; i < count; ++i) + { + if (fapia_errors[i].reason) + { + delete [] fapia_errors[i].reason; + fapia_errors[i].reason = 0; + } + } + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::process_commandline_arguments ( + int argc, + char* argv[]) + { + FAPIA_TRACE; + + // Set the default debug level + unsigned long fapia_debug_level = LM_ERROR | LM_CRITICAL | LM_ALERT | LM_EMERGENCY; + + // Retrieve arguments for FAPIA. + ACE_Arg_Shifter arg_shifter (argc, argv); + while (arg_shifter.is_anything_left ()) + { + const ACE_TCHAR *current_arg = arg_shifter.get_current (); + + const ACE_TCHAR fapia_debug_levelopt[] = ACE_TEXT("-FAPIADebugLevel"); + size_t fapia_debug_levellen = ACE_OS::strlen (fapia_debug_levelopt); + + // Handle option FAPIADebugLevel. + if (ACE_OS::strcasecmp (current_arg, fapia_debug_levelopt) == 0) + { + arg_shifter.consume_arg (); + if (arg_shifter.is_parameter_next ()) + { + fapia_debug_level = atol (ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ())); + arg_shifter.consume_arg (); + } + } + else if (ACE_OS::strncasecmp (current_arg, fapia_debug_levelopt, fapia_debug_levellen) == 0) + { + arg_shifter.consume_arg (); + // The rest of the argument is the FAPIA debug level... + // but we should skip an optional space... + if (current_arg[fapia_debug_levellen] == ' ') + fapia_debug_level = atol (ACE_TEXT_ALWAYS_CHAR(current_arg + fapia_debug_levellen + 1)); + else + fapia_debug_level = atol (ACE_TEXT_ALWAYS_CHAR(current_arg + fapia_debug_levellen)); + } + else + arg_shifter.ignore_arg (); + } + + // Set the logging level. + ACE_LOG_MSG->priority_mask (fapia_debug_level, ACE_Log_Msg::PROCESS); + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long Controller::shutdown_reply_command_handler (void) + { + FAPIA_TRACE; + + if (reply_command_handler_) + { + if (reply_command_handler_->shutdown () < 0) + { + FAPIA_DEBUG ( + LM_ERROR, + "Error shutting reply command handler down.\n"); + return -1; + } + + delete reply_command_handler_; + reply_command_handler_ = 0; + } + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + } /* namespace Controller */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAController/source/FAPIAControllerController.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/source/FAPIAControllerController.h Thu Jul 19 07:08:51 2007 @@ -0,0 +1,767 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAControllerController.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_CONTROLLER_CONTROLLER_H_ +#define _FAPI_ACYCLIC_CONTROLLER_CONTROLLER_H_ + +#include /**/ +#include /**/ +#include /**/ +#include /**/ +#include "../../interface/FAPIA.h" +#include "FAPIAControllerReplyCommandHandler.h" +#include "../../FAPIAIPCParameter/interface/FAPIAIPCIParameter.h" +#include "../../FAPIAIPCSynchronize/interface/FAPIAIPCISynchronize.h" +#include "../../FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestReadRequest.h" +#include "../../FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestReadResponse.h" +#include "../../FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestWriteRequest.h" +#include "../../FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestWriteResponse.h" +#include "../../FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestInfoRequest.h" +#include "../../FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestInfoResponse.h" + + +namespace FAPI + { + namespace Acyclic + { + namespace Controller + { + namespace Test + { + class ConversionsTest; // Forward declaration. + } + + /** + * @class Controller + * + * @brief The Controller class is a singleton and implements the + * FAPIA interface. + * + */ + class Controller + { + + public: + friend class FAPI::Acyclic::Controller::ReplyCommandHandler; + friend class FAPI::Acyclic::Controller::Test::ConversionsTest; + + /** + * @brief Constructor. + * + */ + Controller (void); + + /** + * @brief Destructor. + * + */ + virtual ~Controller (void); + + /** + * @brief Initializes the FAPIA. name is the physical_object_name of this + * communication node. + * + * If it returns a negative number there was an error. + * + */ + long fapia_init ( + int argc, + char* argv[], + const char * const name); + + + /** + * @brief Deinitializes the FAPIA. FAPIA has to deallocate all allocated memory + * and shut down. + * + * If it returns a negative number there was an error. + * + */ + long fapia_deinit (void); + + + /** + * @brief Retrieves the logical object names from the FAPIA. + * + * If it returns a negative number there was an error. + * + */ + long fapia_logical_object_names ( + char*** logical_object_names, + unsigned long* number_of_logical_object_names); + + + /** + * @brief Initializing the caller for responses of read requests. FAPIA holds a + * reference to the function and calls it when a response is received. + * + * If it returns a negative number there was an error. + * + */ + long fapia_set_callback_for_parameter_read_response_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAValue *, + const FAPIAError *)); + + + /** + * @brief Initializing the caller for responses of write requests. FAPIA holds a + * reference to the function and calls it when a response is received. + * + * If it returns a negative number there was an error. + * + */ + long fapia_set_callback_for_parameter_write_response_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAError *)); + + + /** + * @brief Initializing the caller for responses of info requests. FAPIA holds a + * reference to the function and calls it when a response is received. + * + * If it returns a negative number there was an error. + * + */ + long fapia_set_callback_for_parameter_info_response_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAInfo *, + const FAPIAError *)); + + + /** + * @brief Initializing the callee for read requests. FAPIA holds a + * reference to the function and calls it when a request is received. + * + * If it returns a negative number there was an error. + * + */ + long fapia_set_callback_for_parameter_read_request_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *)); + + + /** + * @brief Initializing the callee for write requests. FAPIA holds a + * reference to the function and calls it when a request is received. + * + * If it returns a negative number there was an error. + * + */ + long fapia_set_callback_for_parameter_write_request_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAValue *)); + + + /** + * @brief Initializing the callee for info requests. FAPIA holds a + * reference to the function and calls it when a request is received. + * + * If it returns a negative number there was an error. + * + */ + long fapia_set_callback_for_parameter_info_request_callback ( + long (*f) (const FAPIACommunication *, + const FAPIAParameter *)); + + + /** + * @brief Sends a read request to the callee. fapia_communication.transaction_id + * and fapia_communication.source_physical_object_name are filled out by the + * FAPIA. + * + * If it returns a negative number there was an error. + * + */ + long fapia_parameter_read_request ( + FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters); + +#if 0 + /** + * @brief This is the callback response function of the read_request. It is _not_ + * implemented by FAPIA. This may be done by the caller application. A function + * with this signature must be set by function + * fapia_set_callback_for_parameter_read_response_callback. + * + * If it returns a negative number there was an error. + * + */ + long fapia_parameter_read_response_callback ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAValue * const fapia_values, + const FAPIAError * const fapia_errors); + + + + /** + * @brief This is the callback request function of the read_request. It is _not_ + * implemented by FAPIA. This may be done by the callee application. A function + * with this signature must be set by function + * fapia_set_callback_for_parameter_read_request_callback. + * + * If it returns a negative number there was an error. + * + */ + long fapia_parameter_read_request_callback ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters); +#endif + + /** + * @brief Sends a read response to the caller. + * + * If it returns a negative number there was an error. + * + */ + long fapia_parameter_read_response ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAValue * const fapia_values, + const FAPIAError * const fapia_errors); + + + /** + * @brief Sends a write request to the callee. fapia_communication.transaction_id + * and fapia_communication.source_physical_object_name are filled out by the + * FAPIA. + * + * If it returns a negative number there was an error. + * + */ + long fapia_parameter_write_request ( + FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAValue * const fapia_values); + +#if 0 + /** + * @brief This is the callback response function of the write_request. It is _not_ + * implemented by FAPIA. This may be done by the caller application. A function + * with this signature must be set by function + * fapia_set_callback_for_parameter_write_response_callback. + * + * If it returns a negative number there was an error. + * + */ + long fapia_parameter_write_response_callback ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAError * const fapia_errors); + + + /** + * @brief This is the callback response function of the write_request. It is _not_ + * implemented by FAPIA. This may be done by the caller application. A function + * with this signature must be set by function + * fapia_set_callback_for_parameter_write_response_callback. + * + * If it returns a negative number there was an error. + * + */ + long fapia_parameter_write_request_callback ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAValue * const fapia_values); +#endif + + /** + * @brief Sends a write response to the caller. + * + * If it returns a negative number there was an error. + * + */ + long fapia_parameter_write_response ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAError * const fapia_errors); + + /** + * @brief Sends a info request to the callee. fapia_communication.transaction_id + * and fapia_communication.source_physical_object_name are filled out by the + * FAPIA. + * + * If it returns a negative number there was an error. + * + */ + long fapia_parameter_info_request ( + FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters); + +#if 0 + /** + * @brief This is the callback response function of the info_request. It is _not_ + * implemented by FAPIA. This may be done by the caller application. A function + * with this signature must be set by function + * fapia_set_callback_for_parameter_info_response_callback. + * + * If it returns a negative number there was an error. + * + */ + long fapia_parameter_info_response_callback ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAInfo * const fapia_infos, + const FAPIAError * const fapia_errors); + + + /** + * @brief This is the callback response function of the info_request. It is _not_ + * implemented by FAPIA. This may be done by the caller application. A function + * with this signature must be set by function + * fapia_set_callback_for_parameter_info_response_callback. + * + * If it returns a negative number there was an error. + * + */ + long fapia_parameter_info_request_callback ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters); +#endif + + /** + * @brief Sends a info response to the caller. + * + * If it returns a negative number there was an error. + * + */ + long fapia_parameter_info_response ( + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAInfo * const fapia_infos, + const FAPIAError * const fapia_errors); + + + protected: + + /** + * @enum State + * + * @brief State of the controller module. + * + */ + enum State + { + INITIAL = 1, + RUNNING = 2, + ABORTED = 3, + SHUTDOWN = 4, + EXITED = 5 + }; + + /// State of the controller module. + State state_; + + /// Transaction id is unique related to the physical_object_name_. + unsigned long transaction_id_; + + /// Holds the physical object name of this process. + ACE_CString physical_object_name_; + + /// Mapping from logical to physical objects + /// (). + ACE_RB_Tree ,ACE_SYNCH_NULL_MUTEX> logical_physical_object_names_; + + /// Array with existing logical object names. This is needed for + /// retrieving all logical object names. The number of them + /// are stored in number_of_logical_object_names_. + char** logical_object_names_; + + /// Number of logical object names in the logical_object_names_ + /// array. + unsigned long number_of_logical_object_names_; + + + /// Pointer to command handler for replies. + FAPI::Acyclic::Controller::ReplyCommandHandler* reply_command_handler_; + + /// Callback function for read responses. + long (*parameter_read_response_callback_) ( + const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAValue *, + const FAPIAError *); + + + /// Callback function for write responses. + long (*parameter_write_response_callback_) ( + const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAError *); + + + /// Callback function for info responses. + long (*parameter_info_response_callback_) ( + const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAInfo *, + const FAPIAError *); + + + /// Callback function for read requests. + long (*parameter_read_request_callback_) ( + const FAPIACommunication *, + const FAPIAParameter *); + + + /// Callback function for write requests. + long (*parameter_write_request_callback_) ( + const FAPIACommunication *, + const FAPIAParameter *, + const FAPIAValue *); + + /// Callback function for info requests. + long (*parameter_info_request_callback_) ( + const FAPIACommunication *, + const FAPIAParameter *); + + /// Pointer to interface of ipc parameter module. + FAPI::Acyclic::IPC::IParameter* ipc_parameter_; + + /// Activation queue for sending message requests to + /// IPC::Parameter. + ACE_Activation_Queue send_queue_; + + /// Activation queue for receiving message requests from + /// IPC::Parameter. + ACE_Activation_Queue receive_queue_; + + /// Pointer to interface of ipc parameter synchronize. + FAPI::Acyclic::IPC::ISynchronize* ipc_synchronize_; + + /// Mutex to synchronize the incrementation of the + /// transaction_id_. + ACE_Thread_Mutex transaction_id_mutex_; + + /** + * @brief Increments the transaction id and returns the value. + * + * This method is thread-safe. + * + */ + void increment_and_get_transaction_id ( + unsigned long& transaction_id); + + + /** + * @brief Converts the fapia parameters to a method request. + * + */ + long convert_to_read_request ( + FAPI::Acyclic::IPC::Parameter::MethodRequestReadRequest* mr, + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters); + + + /** + * @brief Converts a method request to the fapia parameters. + * + */ + long convert_from_read_request ( + FAPIACommunication * const fapia_communication, + FAPIAParameter * const fapia_parameters, + const FAPI::Acyclic::IPC::Parameter::MethodRequestReadRequest* mr); + + + /** + * @brief Converts the fapia parameters to a method request. + * + */ + long convert_to_read_response ( + FAPI::Acyclic::IPC::Parameter::MethodRequestReadResponse* mr, + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAValue * const fapia_values, + const FAPIAError * const fapia_errors); + + + /** + * @brief Converts a method request to the fapia parameters. + * + */ + long convert_from_read_response ( + FAPIACommunication * const fapia_communication, + FAPIAParameter * const fapia_parameters, + FAPIAValue * const fapia_values, + FAPIAError * const fapia_errors, + const FAPI::Acyclic::IPC::Parameter::MethodRequestReadResponse* mr); + + + /** + * @brief Converts the fapia parameters to a method request. + * + */ + long convert_to_write_request ( + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteRequest* mr, + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAValue * const fapia_values); + + + /** + * @brief Converts a method request to the fapia parameters. + * + */ + long convert_from_write_request ( + FAPIACommunication* const fapia_communication, + FAPIAParameter * const fapia_parameters, + FAPIAValue * const fapia_values, + const FAPI::Acyclic::IPC::Parameter::MethodRequestWriteRequest* mr); + + + /** + * @brief Converts the fapia parameters to a method request. + * + */ + long convert_to_write_response ( + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteResponse* mr, + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAError * const fapia_errors); + + + /** + * @brief Converts a method request to the fapia parameters. + * + */ + long convert_from_write_response ( + FAPIACommunication * const fapia_communication, + FAPIAParameter * const fapia_parameters, + FAPIAError * const fapia_errors, + const FAPI::Acyclic::IPC::Parameter::MethodRequestWriteResponse* mr); + + + + /** + * @brief Converts the fapia parameters to a method request. + * + */ + long convert_to_info_request ( + FAPI::Acyclic::IPC::Parameter::MethodRequestInfoRequest* mr, + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters); + + + /** + * @brief Converts a method request to the fapia parameters. + * + */ + long convert_from_info_request ( + FAPIACommunication* const fapia_communication, + FAPIAParameter * const fapia_parameters, + const FAPI::Acyclic::IPC::Parameter::MethodRequestInfoRequest* mr); + + + /** + * @brief Converts the fapia parameters to a method request. + * + */ + long convert_to_info_response ( + FAPI::Acyclic::IPC::Parameter::MethodRequestInfoResponse* mr, + const FAPIACommunication * const fapia_communication, + const FAPIAParameter * const fapia_parameters, + const FAPIAInfo * const fapia_infos, + const FAPIAError * const fapia_errors); + + + /** + * @brief Converts a method request to the fapia parameters. + * + */ + long convert_from_info_response ( + FAPIACommunication * const fapia_communication, + FAPIAParameter * const fapia_parameters, + FAPIAInfo * const fapia_infos, + FAPIAError * const fapia_errors, + const FAPI::Acyclic::IPC::Parameter::MethodRequestInfoResponse* mr); + + + + /** + * @brief Converts the ipc parameter to the fapia parameter. + * + */ + long convert ( + FAPIACommunication * const fapia_communication, + const FAPI::Acyclic::IPC::Parameter::Communication& ipc_parameter_communication); + + /** + * @brief Converts the fapia parameter to the ipc parameter. + * + */ + long convert ( + FAPI::Acyclic::IPC::Parameter::Communication& ipc_parameter_communication, + const FAPIACommunication * const fapia_communication); + + + + /** + * @brief Converts the ipc parameter to the fapia parameter. + * + */ + long convert ( + FAPIAParameter * const fapia_parameters, + const FAPI::Acyclic::IPC::Parameter::Parameters& ipc_parameter_parameters); + + /** + * @brief Converts the fapia parameter to the ipc parameter. + * + */ + long convert ( + FAPI::Acyclic::IPC::Parameter::Parameters& ipc_parameter_parameters, + const FAPIAParameter * const fapia_parameters, + unsigned long count); + + + + /** + * @brief Converts the ipc parameter to the fapia parameter. + * + */ + long convert ( + FAPIAValue * const fapia_values, + const FAPI::Acyclic::IPC::Parameter::Values& ipc_parameter_values); + + /** + * @brief Converts the fapia parameter to the ipc parameter. + * + */ + long convert ( + FAPI::Acyclic::IPC::Parameter::Values& ipc_parameter_values, + const FAPIAValue * const fapia_values, + unsigned long count); + + + + /** + * @brief Converts the ipc parameter to the fapia parameter. + * + */ + long convert ( + FAPIAInfo * const fapia_infos, + const FAPI::Acyclic::IPC::Parameter::Infos& ipc_parameter_infos); + + /** + * @brief Converts the fapia parameter to the ipc parameter. + * + */ + long convert ( + FAPI::Acyclic::IPC::Parameter::Infos& ipc_parameter_infos, + const FAPIAInfo * const fapia_infos, + unsigned long count); + + + + /** + * @brief Converts the ipc parameter to the fapia parameter. + * + */ + long convert ( + FAPIAError * const fapia_errors, + const FAPI::Acyclic::IPC::Parameter::Errors& ipc_parameter_errors); + + /** + * @brief Converts the fapia parameter to the ipc parameter. + * + */ + long convert ( + FAPI::Acyclic::IPC::Parameter::Errors& ipc_parameter_errors, + const FAPIAError * const fapia_errors, + unsigned long count); + + + /** + * @brief Frees the memory. + * + */ + void free_memory ( + FAPIACommunication * const fapia_communication); + + /** + * @brief Frees the memory. + * + */ + void free_memory ( + FAPIAParameter * const fapia_parameters, + unsigned long count); + + /** + * @brief Frees the memory. + * + */ + void free_memory ( + FAPIAValue * const fapia_values, + unsigned long count); + + /** + * @brief Frees the memory. + * + */ + void free_memory ( + FAPIAInfo * const fapia_infos, + unsigned long count); + + /** + * @brief Frees the memory. + * + */ + void free_memory ( + FAPIAError * const fapia_errors, + unsigned long count); + + /** + * @brief Processes the commandline arguments, e.g sets + * the trace level + * + */ + long process_commandline_arguments ( + int argc, + char* argv[]); + + /** + * @brief Shuts the reply command handler down. + * + */ + long shutdown_reply_command_handler (void); + + private: + + /** + * Copy Constructor is private, so this object cannot be copied. + */ + Controller (const Controller&); + + /** + * Assignment operator is private, so this object cannot be copied. + */ + const Controller& operator= (const Controller&); + + + }; /* class Controller */ + + } /* namespace Controller */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +/// Typedef for singleton of controller class. +typedef ACE_Singleton FAPIAControllerControllerSingleton; + +/// Macro for accessing the controller class. +#define FAPIA_CONTROLLER FAPIAControllerControllerSingleton::instance () + + +#endif /* _FAPI_ACYCLIC_CONTROLLER_CONTROLLER_H_ */ Added: fapia-trunk/FAPIAController/source/FAPIAControllerMethodRequestShutdown.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/source/FAPIAControllerMethodRequestShutdown.cpp Thu Jul 19 07:08:51 2007 @@ -0,0 +1,36 @@ +// $Id$ + + +#include "FAPIAControllerMethodRequestShutdown.h" + +namespace FAPI + { + namespace Acyclic + { + namespace Controller + { + +/*---------------------------------------------------------------------------*/ + + MethodRequestShutdown::MethodRequestShutdown (void) + { + } + +/*---------------------------------------------------------------------------*/ + + MethodRequestShutdown::~MethodRequestShutdown (void) + { + } + +/*---------------------------------------------------------------------------*/ + + int MethodRequestShutdown::call (void) + { + return -1; + } + +/*---------------------------------------------------------------------------*/ + + } /* namespace Controller */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAController/source/FAPIAControllerMethodRequestShutdown.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/source/FAPIAControllerMethodRequestShutdown.h Thu Jul 19 07:08:51 2007 @@ -0,0 +1,81 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAControllerMethodRequestShutdown.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_CONTROLLER_METHOD_REQUEST_SHUTDOWN_H_ +#define _FAPI_ACYCLIC_CONTROLLER_METHOD_REQUEST_SHUTDOWN_H_ + +#include /**/ +#include "../../FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequest.h" + +namespace FAPI + { + namespace Acyclic + { + namespace Controller + { + /** + * @class MethodRequestShutdown + * + * @brief The MethodRequestShutdown is the class to shutdown + * the reply command handler thread. + * + */ + class MethodRequestShutdown : public FAPI::Acyclic::IPC::Parameter::MethodRequest + { + + public: + /** + * @brief Constructor of MethodRequestShutdown. + * + */ + MethodRequestShutdown (void); + + /** + * @brief Destructor of MethodRequestShutdown. + * + */ + virtual ~MethodRequestShutdown (void); + + /** + * @brief Invoked when the MethodRequestShutdown is + * scheduled to run. + * + * If it returns -1 the receiving thread of this message + * must shut down. + * + */ + virtual int call (void); + + protected: + + private: + /** + * @brief Copy Constructor is private, so this object cannot + * be copied. + * + */ + MethodRequestShutdown (const MethodRequestShutdown&); + + /** + * @brief Assignment operator is private, so this object cannot + * be copied. + * + */ + const MethodRequestShutdown& operator= (const MethodRequestShutdown&); + + }; /* class MethodRequestShutdown */ + + } /* namespace Controller */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_CONTROLLER_METHOD_REQUEST_SHUTDOWN_H_ */ Added: fapia-trunk/FAPIAController/source/FAPIAControllerReplyCommandHandler.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/source/FAPIAControllerReplyCommandHandler.cpp Thu Jul 19 07:08:51 2007 @@ -0,0 +1,686 @@ +// $Id$ + +#include "FAPIAControllerReplyCommandHandler.h" +#include "FAPIAControllerController.h" +#include "../../interface/FAPIATrace.h" +#include "FAPIAControllerMethodRequestShutdown.h" +#include "../../FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestReadRequest.h" +#include "../../FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestWriteRequest.h" +#include "../../FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestInfoRequest.h" +#include "../../FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestReadResponse.h" +#include "../../FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestWriteResponse.h" +#include "../../FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestInfoResponse.h" + +namespace FAPI + { + namespace Acyclic + { + namespace Controller + { + +/* ---------------------------------------------------------------------------*/ + + ReplyCommandHandler::ReplyCommandHandler ( + FAPI::Acyclic::Controller::Controller* fapia_controller, + ACE_Activation_Queue* receive_queue + ) : + fapia_controller_ (fapia_controller), + receive_queue_ (receive_queue) + { + FAPIA_TRACE; + } + +/* ---------------------------------------------------------------------------*/ + + ReplyCommandHandler::~ReplyCommandHandler (void) + { + FAPIA_TRACE; + this->clear_queue (); + } + +/* ---------------------------------------------------------------------------*/ + + int ReplyCommandHandler::perform (ACE_Method_Request * request) + { + FAPIA_TRACE; + return this->receive_queue_->enqueue (request); + } + +/* ---------------------------------------------------------------------------*/ + + void ReplyCommandHandler::clear_queue (void) + { + FAPIA_TRACE; + while (!this->receive_queue_->is_empty ()) + { + ACE_Method_Request * request = this->receive_queue_->dequeue (); + if (request) + { + delete request; // Free allocated memory. + request = 0; + } + } + } + +/* ---------------------------------------------------------------------------*/ + + int ReplyCommandHandler::process_request (ACE_Method_Request * request) + { + FAPIA_TRACE; + + FAPI::Acyclic::IPC::Parameter::MethodRequestReadRequest* + method_request_read_request = 0; + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteRequest* + method_request_write_request = 0; + FAPI::Acyclic::IPC::Parameter::MethodRequestInfoRequest* + method_request_info_request = 0; + FAPI::Acyclic::IPC::Parameter::MethodRequestReadResponse* + method_request_read_response = 0; + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteResponse* + method_request_write_response = 0; + FAPI::Acyclic::IPC::Parameter::MethodRequestInfoResponse* + method_request_info_response = 0; + + + method_request_read_request = + ACE_dynamic_cast ( + FAPI::Acyclic::IPC::Parameter::MethodRequestReadRequest *, + request); + + if (method_request_read_request) + { + if (fapia_controller_->parameter_read_request_callback_ == 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error callback method parameter_read_request_callback_ not set.\n"); + return -1; + } + + FAPIACommunication fapia_communication; + FAPIAParameter* fapia_parameters = 0; + + method_request_read_request->parameters_.size (); + ACE_NEW_NORETURN (fapia_parameters, FAPIAParameter[method_request_read_request->parameters_.size ()]); + if (fapia_parameters == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPIAParameter.\n"); + return -1; + } + + if (fapia_controller_->convert_from_read_request ( + &fapia_communication, + fapia_parameters, + method_request_read_request) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error convert_from_read_request failed.\n"); + return -1; + } + + if ((*fapia_controller_->parameter_read_request_callback_) + (&fapia_communication, fapia_parameters) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error on calling parameter_read_request_callback_.\n"); + fapia_controller_->free_memory (fapia_parameters, fapia_communication.number_of_entries); + fapia_controller_->free_memory (&fapia_communication); + delete [] fapia_parameters; + fapia_parameters = 0; + return -1; + } + + if (fapia_communication.communication_error.error_code == + FAPIA_ERROR_DESTINATION_NOT_ONLINE) + { + FAPI::Acyclic::IPC::Synchronize::Error error; + fapia_controller_->ipc_synchronize_->disable_physical_object ( + method_request_read_request->destination_physical_object_address_, + error); + } + + fapia_controller_->free_memory (fapia_parameters, fapia_communication.number_of_entries); + fapia_controller_->free_memory (&fapia_communication); + delete fapia_parameters; + fapia_parameters = 0; + return 0; + } + + + method_request_write_request = + ACE_dynamic_cast ( + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteRequest *, + request); + + if (method_request_write_request) + { + if (fapia_controller_->parameter_write_request_callback_ == 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error callback method parameter_write_request_callback_ not set.\n"); + return -1; + } + + FAPIACommunication fapia_communication; + FAPIAParameter* fapia_parameters = 0; + FAPIAValue* fapia_values = 0; + + ACE_NEW_NORETURN (fapia_parameters, FAPIAParameter[method_request_write_request->parameters_.size ()]); + if (fapia_parameters == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPIAParameter.\n"); + return -1; + } + + ACE_NEW_NORETURN (fapia_values, FAPIAValue[method_request_write_request->values_.size ()]); + if (fapia_values == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPIAValue.\n"); + delete [] fapia_parameters; + fapia_parameters = 0; + return -1; + } + + if (fapia_controller_->convert_from_write_request ( + &fapia_communication, + fapia_parameters, + fapia_values, + method_request_write_request) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error convert_from_write_request failed.\n"); + delete [] fapia_parameters; + fapia_parameters = 0; + delete [] fapia_values; + fapia_values = 0; + return -1; + } + + if ((*fapia_controller_->parameter_write_request_callback_) + (&fapia_communication, fapia_parameters, fapia_values) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error on calling parameter_write_request_callback_.\n"); + fapia_controller_->free_memory (fapia_values, fapia_communication.number_of_entries); + fapia_controller_->free_memory (fapia_parameters, fapia_communication.number_of_entries); + fapia_controller_->free_memory (&fapia_communication); + delete [] fapia_parameters; + fapia_parameters = 0; + delete [] fapia_values; + fapia_values = 0; + return -1; + } + + if (fapia_communication.communication_error.error_code == + FAPIA_ERROR_DESTINATION_NOT_ONLINE) + { + FAPI::Acyclic::IPC::Synchronize::Error error; + fapia_controller_->ipc_synchronize_->disable_physical_object ( + method_request_write_request->destination_physical_object_address_, + error); + } + + fapia_controller_->free_memory (fapia_values, fapia_communication.number_of_entries); + fapia_controller_->free_memory (fapia_parameters, fapia_communication.number_of_entries); + fapia_controller_->free_memory (&fapia_communication); + delete [] fapia_parameters; + fapia_parameters = 0; + delete [] fapia_values; + fapia_values = 0; + return 0; + } + + + method_request_info_request = + ACE_dynamic_cast ( + FAPI::Acyclic::IPC::Parameter::MethodRequestInfoRequest *, + request); + + if (method_request_info_request) + { + if (fapia_controller_->parameter_info_request_callback_ == 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error callback method parameter_info_request_callback_ not set.\n"); + return -1; + } + + FAPIACommunication fapia_communication; + FAPIAParameter* fapia_parameters = 0; + + ACE_NEW_NORETURN (fapia_parameters, FAPIAParameter[method_request_info_request->parameters_.size ()]); + if (fapia_parameters == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPIAParameter.\n"); + return -1; + } + + if (fapia_controller_->convert_from_info_request ( + &fapia_communication, + fapia_parameters, + method_request_info_request) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error convert_from_info_request failed.\n"); + delete [] fapia_parameters; + fapia_parameters = 0; + return -1; + } + + if ((*fapia_controller_->parameter_info_request_callback_) + (&fapia_communication, fapia_parameters) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error on calling parameter_info_request_callback_.\n"); + fapia_controller_->free_memory (fapia_parameters, fapia_communication.number_of_entries); + fapia_controller_->free_memory (&fapia_communication); + delete [] fapia_parameters; + fapia_parameters = 0; + return -1; + } + + if (fapia_communication.communication_error.error_code == + FAPIA_ERROR_DESTINATION_NOT_ONLINE) + { + FAPI::Acyclic::IPC::Synchronize::Error error; + fapia_controller_->ipc_synchronize_->disable_physical_object ( + method_request_info_request->destination_physical_object_address_, + error); + } + + fapia_controller_->free_memory (fapia_parameters, fapia_communication.number_of_entries); + fapia_controller_->free_memory (&fapia_communication); + delete [] fapia_parameters; + fapia_parameters = 0; + return 0; + } + + + method_request_read_response = + ACE_dynamic_cast ( + FAPI::Acyclic::IPC::Parameter::MethodRequestReadResponse *, + request); + if (method_request_read_response) + { + if (fapia_controller_->parameter_read_response_callback_ == 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error callback method parameter_read_response_callback_ not set.\n"); + return -1; + } + + FAPIACommunication fapia_communication; + FAPIAParameter* fapia_parameters = 0; + FAPIAValue* fapia_values = 0; + FAPIAError* fapia_errors = 0; + + ACE_NEW_NORETURN (fapia_parameters, FAPIAParameter[method_request_read_response->parameters_.size ()]); + if (fapia_parameters == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPIAParameter.\n"); + return -1; + } + + ACE_NEW_NORETURN (fapia_values, FAPIAValue[method_request_read_response->values_.size ()]); + if (fapia_values == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPIAValue.\n"); + delete [] fapia_parameters; + fapia_parameters = 0; + return -1; + } + + ACE_NEW_NORETURN (fapia_errors, FAPIAError[method_request_read_response->errors_.size ()]); + if (fapia_errors == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPIAError.\n"); + delete [] fapia_parameters; + fapia_parameters = 0; + delete [] fapia_values; + fapia_values = 0; + return -1; + } + + if (fapia_controller_->convert_from_read_response ( + &fapia_communication, + fapia_parameters, + fapia_values, + fapia_errors, + method_request_read_response) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error convert_from_read_response failed.\n"); + return -1; + } + + if ((*fapia_controller_->parameter_read_response_callback_) + (&fapia_communication, fapia_parameters, fapia_values, fapia_errors) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error on calling parameter_read_response_callback_.\n"); + fapia_controller_->free_memory (fapia_errors, fapia_communication.number_of_entries); + fapia_controller_->free_memory (fapia_values, fapia_communication.number_of_entries); + fapia_controller_->free_memory (fapia_parameters, fapia_communication.number_of_entries); + fapia_controller_->free_memory (&fapia_communication); + delete [] fapia_parameters; + fapia_parameters = 0; + delete [] fapia_values; + fapia_values = 0; + delete [] fapia_errors; + fapia_errors = 0; + return -1; + } + + if (fapia_communication.communication_error.error_code == + FAPIA_ERROR_DESTINATION_NOT_ONLINE) + { + FAPI::Acyclic::IPC::Synchronize::Error error; + fapia_controller_->ipc_synchronize_->disable_physical_object ( + method_request_read_response->destination_physical_object_address_, + error); + } + + fapia_controller_->free_memory (fapia_errors, fapia_communication.number_of_entries); + fapia_controller_->free_memory (fapia_values, fapia_communication.number_of_entries); + fapia_controller_->free_memory (fapia_parameters, fapia_communication.number_of_entries); + fapia_controller_->free_memory (&fapia_communication); + delete [] fapia_parameters; + fapia_parameters = 0; + delete [] fapia_values; + fapia_values = 0; + delete [] fapia_errors; + fapia_errors = 0; + return 0; + } + + + method_request_write_response = + ACE_dynamic_cast ( + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteResponse *, + request); + if (method_request_write_response) + { + if (fapia_controller_->parameter_write_response_callback_ == 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error callback method parameter_write_response_callback_ not set.\n"); + return -1; + } + + FAPIACommunication fapia_communication; + FAPIAParameter* fapia_parameters = 0; + FAPIAError* fapia_errors = 0; + + ACE_NEW_NORETURN (fapia_parameters, FAPIAParameter[method_request_write_response->parameters_.size ()]); + if (fapia_parameters == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPIAParameter.\n"); + return -1; + } + + ACE_NEW_NORETURN (fapia_errors, FAPIAError[method_request_write_response->errors_.size ()]); + if (fapia_errors == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPIAError.\n"); + delete [] fapia_parameters; + fapia_parameters = 0; + return -1; + } + + + if (fapia_controller_->convert_from_write_response ( + &fapia_communication, + fapia_parameters, + fapia_errors, + method_request_write_response) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error convert_from_write_response failed.\n"); + return -1; + } + + if ((*fapia_controller_->parameter_write_response_callback_) + (&fapia_communication, fapia_parameters, fapia_errors) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error on calling parameter_write_response_callback_.\n"); + fapia_controller_->free_memory (fapia_errors, fapia_communication.number_of_entries); + fapia_controller_->free_memory (fapia_parameters, fapia_communication.number_of_entries); + fapia_controller_->free_memory (&fapia_communication); + delete [] fapia_parameters; + fapia_parameters = 0; + delete [] fapia_errors; + fapia_errors = 0; + return -1; + } + + if (fapia_communication.communication_error.error_code == + FAPIA_ERROR_DESTINATION_NOT_ONLINE) + { + FAPI::Acyclic::IPC::Synchronize::Error error; + fapia_controller_->ipc_synchronize_->disable_physical_object ( + method_request_write_response->destination_physical_object_address_, + error); + } + + fapia_controller_->free_memory (fapia_errors, fapia_communication.number_of_entries); + fapia_controller_->free_memory (fapia_parameters, fapia_communication.number_of_entries); + fapia_controller_->free_memory (&fapia_communication); + delete [] fapia_parameters; + fapia_parameters = 0; + delete [] fapia_errors; + fapia_errors = 0; + return 0; + } + + method_request_info_response = + ACE_dynamic_cast ( + FAPI::Acyclic::IPC::Parameter::MethodRequestInfoResponse *, + request); + if (method_request_info_response) + { + if (fapia_controller_->parameter_info_response_callback_ == 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error callback method parameter_info_response_callback_ not set.\n"); + return -1; + } + + FAPIACommunication fapia_communication; + FAPIAParameter* fapia_parameters = 0; + FAPIAInfo* fapia_infos = 0; + FAPIAError* fapia_errors = 0; + + ACE_NEW_NORETURN (fapia_parameters, FAPIAParameter[method_request_info_response->parameters_.size ()]); + if (fapia_parameters == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPIAParameter.\n"); + return -1; + } + + ACE_NEW_NORETURN (fapia_infos, FAPIAInfo[method_request_info_response->parameters_.size ()]); + if (fapia_infos == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPIAInfo.\n"); + delete [] fapia_parameters; + fapia_parameters = 0; + return -1; + } + + ACE_NEW_NORETURN (fapia_errors, FAPIAError[method_request_info_response->errors_.size ()]); + if (fapia_errors == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPIAError.\n"); + delete [] fapia_parameters; + fapia_parameters = 0; + delete [] fapia_infos; + fapia_infos = 0; + return -1; + } + + + if (fapia_controller_->convert_from_info_response ( + &fapia_communication, + fapia_parameters, + fapia_infos, + fapia_errors, + method_request_info_response) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error convert_from_info_response failed.\n"); + return -1; + } + + if ((*fapia_controller_->parameter_info_response_callback_) + (&fapia_communication, fapia_parameters, fapia_infos, fapia_errors) < 0) + { + FAPIA_DEBUG ( + LM_CRITICAL, + "Error on calling parameter_info_response_callback_.\n"); + fapia_controller_->free_memory (fapia_errors, fapia_communication.number_of_entries); + fapia_controller_->free_memory (fapia_infos, fapia_communication.number_of_entries); + fapia_controller_->free_memory (fapia_parameters, fapia_communication.number_of_entries); + fapia_controller_->free_memory (&fapia_communication); + delete [] fapia_parameters; + fapia_parameters = 0; + delete [] fapia_infos; + fapia_infos = 0; + delete [] fapia_errors; + fapia_errors = 0; + return -1; + } + + if (fapia_communication.communication_error.error_code == + FAPIA_ERROR_DESTINATION_NOT_ONLINE) + { + FAPI::Acyclic::IPC::Synchronize::Error error; + fapia_controller_->ipc_synchronize_->disable_physical_object ( + method_request_info_response->destination_physical_object_address_, + error); + } + + fapia_controller_->free_memory (fapia_errors, fapia_communication.number_of_entries); + fapia_controller_->free_memory (fapia_infos, fapia_communication.number_of_entries); + fapia_controller_->free_memory (fapia_parameters, fapia_communication.number_of_entries); + fapia_controller_->free_memory (&fapia_communication); + delete [] fapia_parameters; + fapia_parameters = 0; + delete [] fapia_infos; + fapia_infos = 0; + delete [] fapia_errors; + fapia_errors = 0; + return 0; + } + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + int ReplyCommandHandler::svc (void) + { + FAPIA_TRACE; + + bool shutdown = false; + + while (!shutdown) + { + ACE_Method_Request * request = this->receive_queue_->dequeue (); + if (request) + { + this->process_request (request); + long result = request->call (); + delete request; // Free allocated memory. + request = 0; + if (result == -1) + { + shutdown = true; // Exit thread. + } + } + } + + // Clear the queue. + clear_queue (); + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + long ReplyCommandHandler::shutdown (void) + { + // Create shutdown method request. + FAPI::Acyclic::Controller::MethodRequestShutdown* mr_shutdown = 0; + + ACE_NEW_NORETURN ( + mr_shutdown, + FAPI::Acyclic::Controller::MethodRequestShutdown ()); + + if (mr_shutdown == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPI::Acyclic::Controller::MethodRequestShutdown\n"); + return -1; + } + + // Enqueue shutdown request into receive queue. Thread will be + // woken up and shutdown. + this->perform (mr_shutdown); + this->wait (); + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + int ReplyCommandHandler::close (u_long flags) + { + FAPIA_TRACE; + ACE_UNUSED_ARG (flags); + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + } /* namespace Controller */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAController/source/FAPIAControllerReplyCommandHandler.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/source/FAPIAControllerReplyCommandHandler.h Thu Jul 19 07:08:51 2007 @@ -0,0 +1,116 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAControllerReplyCommandHandler.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_CONTROLLER_REPLY_COMMAND_HANDLER_H_ +#define _FAPI_ACYCLIC_CONTROLLER_REPLY_COMMAND_HANDLER_H_ + +#include /**/ +#include /**/ +//#include "../../interface/FAPIA.h" +//#include "../../FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestWriteResponse.h" + + +namespace FAPI + { + namespace Acyclic + { + namespace Controller + { + // Forward declaration. + class Controller; + + /** + * @class ReplyCommandHandler + * + * @brief This command handler is responsible for the replies of the + * callee. + * + */ + class ReplyCommandHandler : public ::ACE_Task + + { + + public: + /** + * @brief Constructor. + * + */ + ReplyCommandHandler ( + FAPI::Acyclic::Controller::Controller* fapia_controller, + ACE_Activation_Queue* receive_queue); + + /** + * @brief Destructor. + * + */ + virtual ~ReplyCommandHandler (void); + + /** + * Performs a method request. + */ + int perform (ACE_Method_Request* request); + + /** + * Clears the queue. + */ + void clear_queue (void); + + /** + * Shutdowns the thread. + */ + long shutdown (void); + + /** + * Closes the command handler. + */ + virtual int close (u_long flags = 0); + + protected: + + /// Pointer to controller instance. + FAPI::Acyclic::Controller::Controller* fapia_controller_; + + /// Activation queue for receiving message requests from + /// IPC::Parameter. + ACE_Activation_Queue* receive_queue_; + + /** + * Virtual function for receiving data. + */ + virtual int svc (void); + + /** + * This method processes the requests of the queue. + */ + int process_request (ACE_Method_Request * request); + + private: + + /** + * Copy Constructor is private, so this object cannot be copied. + */ + ReplyCommandHandler (const ReplyCommandHandler&); + + /** + * Assignment operator is private, so this object cannot be copied. + */ + const ReplyCommandHandler& operator= (const ReplyCommandHandler&); + + + + }; /* class ReplyCommandHandler */ + + } /* namespace Controller */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_CONTROLLER_REPLY_COMMAND_HANDLER_H_ */ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:46:21 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:46:21 +0200 Subject: [OSADL-svn-commits] r78 - fapia-trunk/FAPIAController/test Message-ID: <200710020946.l929kL7f021056@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:10:05 2007 New Revision: 78 Log: Added a folder remotely Added: fapia-trunk/FAPIAController/test/ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:46:23 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:46:23 +0200 Subject: [OSADL-svn-commits] r79 - fapia-trunk/FAPIAController/test/conversions Message-ID: <200710020946.l929kNfJ021068@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:10:31 2007 New Revision: 79 Log: Added a folder remotely Added: fapia-trunk/FAPIAController/test/conversions/ fapia-trunk/FAPIAController/test/conversions/makeall.bat fapia-trunk/FAPIAController/test/conversions/makefile Added: fapia-trunk/FAPIAController/test/conversions/makeall.bat ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/test/conversions/makeall.bat Thu Jul 19 07:10:31 2007 @@ -0,0 +1,2 @@ +set ARP_Tools=%cd%\..\..\..\..\..\DevTools_vob\ARP-Tools +ccperl %arp_tools%\mk.pl %* \ No newline at end of file Added: fapia-trunk/FAPIAController/test/conversions/makefile ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/test/conversions/makefile Thu Jul 19 07:10:31 2007 @@ -0,0 +1,10 @@ +SPEC = * +MODULE_DIRS= $(SPEC,*D) +MODULE_DIRS = ./make + + +ALL: $(MODULE_DIRS) $(MAKETARGETS) + %echo ALL_SOURCES $(.SOURCES) + +%include <.homag_make_rules> +%include <.homag_release_make_rules> From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:46:26 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:46:26 +0200 Subject: [OSADL-svn-commits] r80 - fapia-trunk/FAPIAController/test/conversions/make Message-ID: <200710020946.l929kQfx021082@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:10:59 2007 New Revision: 80 Log: Added a folder remotely Added: fapia-trunk/FAPIAController/test/conversions/make/ fapia-trunk/FAPIAController/test/conversions/make/makefile Added: fapia-trunk/FAPIAController/test/conversions/make/makefile ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/test/conversions/make/makefile Thu Jul 19 07:10:59 2007 @@ -0,0 +1,24 @@ +MODULE=test_fapia_controller_conversions + +TYPES:= VC8_STATIC + +NMAKE_STATIC_CFG="Static_Multi_Ansi_Debug_DllRTL" "Static_Multi_Ansi_Release_DllRTL" +NMAKE_DLL_CFG= + + +MPC_DIRS := $(VIEW_ROOT)/IOFramework_vob/FAPIA/make/MPC/config $(VIEW_ROOT)/DevTools_vob/MPC/config $(VIEW_ROOT)/ACE_wrappers_vob/ACE_wrappers/make/MPC/config $(VIEW_ROOT)/DevTools_vob/cppunit/make/MPC/config $(VIEW_ROOT)/XML_vob/xerces/make/MPC/config + +ALL: MPC BUILD + +BUILD: BUILD_ALL + +CLEAN: CLEAN_BUILD CLEAN_MPC + +REALCLEAN: REALCLEAN_BUILD CLEAN_MPC + +EXPORT: EXPORT_ALL + +%include <.homag_make_rules> +%include <.homag_mpc_make_rules> +%include <.homag_build_make_rules> +%include <.homag_export_make_rules> From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:46:29 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:46:29 +0200 Subject: [OSADL-svn-commits] r81 - fapia-trunk/FAPIAController/test/conversions/make/MPC Message-ID: <200710020946.l929kTvB021103@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:11:37 2007 New Revision: 81 Log: Added a folder remotely Added: fapia-trunk/FAPIAController/test/conversions/make/MPC/ fapia-trunk/FAPIAController/test/conversions/make/MPC/test_fapia_controller_conversions.mpc fapia-trunk/FAPIAController/test/conversions/make/MPC/test_fapia_controller_conversions.mwc Added: fapia-trunk/FAPIAController/test/conversions/make/MPC/test_fapia_controller_conversions.mpc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/test/conversions/make/MPC/test_fapia_controller_conversions.mpc Thu Jul 19 07:11:37 2007 @@ -0,0 +1,13 @@ +project : FAPIAControllerpuresource, FAPIAIPCParameterpuresource, FAPIAIPCSynchronizepuresource, FAPIAConfigurationpuresource, acecomponentsexe, taocomponentsexe, cppunitcomponentsexe, xercescomponentsexe { + + exename = test_fapia_controller_conversions + + header_files { + ../../source/*.h + } + + source_files { + ../../source/*.cpp + } + +} \ No newline at end of file Added: fapia-trunk/FAPIAController/test/conversions/make/MPC/test_fapia_controller_conversions.mwc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/test/conversions/make/MPC/test_fapia_controller_conversions.mwc Thu Jul 19 07:11:37 2007 @@ -0,0 +1,3 @@ +workspace { + test_fapia_controller_conversions.mpc +} \ No newline at end of file From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:46:32 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:46:32 +0200 Subject: [OSADL-svn-commits] r82 - fapia-trunk/FAPIAController/test/conversions/source Message-ID: <200710020946.l929kW2t021118@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:12:01 2007 New Revision: 82 Log: Added a folder remotely Added: fapia-trunk/FAPIAController/test/conversions/source/ fapia-trunk/FAPIAController/test/conversions/source/main.cpp fapia-trunk/FAPIAController/test/conversions/source/test_fapia_controller_conversions.cpp fapia-trunk/FAPIAController/test/conversions/source/test_fapia_controller_conversions.h Added: fapia-trunk/FAPIAController/test/conversions/source/main.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/test/conversions/source/main.cpp Thu Jul 19 07:12:01 2007 @@ -0,0 +1,19 @@ + +#include +#include +#include +#include +#include +#include + +#include /**/ + + +int main( int argc, char **argv) +{ + CppUnit::TextUi::TestRunner runner; + CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); + runner.addTest( registry.makeTest() ); + bool wasSuccessful = runner.run( "", false); + return wasSuccessful; +} Added: fapia-trunk/FAPIAController/test/conversions/source/test_fapia_controller_conversions.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/test/conversions/source/test_fapia_controller_conversions.cpp Thu Jul 19 07:12:01 2007 @@ -0,0 +1,495 @@ +// $Id$ + + +#include "test_fapia_controller_conversions.h" +#include "../../../source/FAPIAControllerController.h" +#include "../../../../FAPIAIPCSynchronize/interface/FAPIAIPCSynchronize.h" + +namespace FAPI + { + namespace Acyclic + { + namespace Controller + { + namespace Test + { + + CPPUNIT_TEST_SUITE_REGISTRATION (ConversionsTest); + +/*---------------------------------------------------------------------------*/ + + ConversionsTest::ConversionsTest() + { + } + +/*---------------------------------------------------------------------------*/ + + void ConversionsTest::setUp() + { + } + +/*---------------------------------------------------------------------------*/ + + void ConversionsTest::tearDown() + { + } + +/*---------------------------------------------------------------------------*/ + + void ConversionsTest::test_method_request_conversions (void) + { + FAPI::Acyclic::IPC::Synchronize::Init init; + { + // Initialize controller. ***************************** + FAPI::Acyclic::Controller::Controller controller; + + FAPI::Acyclic::IPC::Synchronize::Error error; + FAPI::Acyclic::IPC::Synchronize::Synchronize* synchronize = 0; + ACE_NEW_NORETURN (synchronize, FAPI::Acyclic::IPC::Synchronize::Synchronize ()); + CPPUNIT_ASSERT (synchronize != 0); + + init.physical_object_address_ = "127.0.0.0"; + init.physical_object_name_ = "source_physical_object_name"; + init.fapia_shared_memory_name_ = "0123"; + int rc = synchronize->init (init, error); + CPPUNIT_ASSERT (rc == 0); + controller.ipc_synchronize_ = synchronize; + + FAPI::Acyclic::IPC::Parameter::MethodRequestReadRequest mr_read_request; + FAPI::Acyclic::IPC::Parameter::MethodRequestReadResponse mr_read_response; + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteRequest mr_write_request; + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteResponse mr_write_response; + FAPIACommunication fapia_communication; + FAPIAParameter fapia_parameters[3]; + FAPIAValue fapia_values[3]; + FAPIAError fapia_errors[3]; + + + + // Initialize for test 1 and 2. *********************** + fapia_communication.communication_error.error_code = FAPIA_ERROR_COMMUNICATION; + fapia_communication.communication_error.reason = "reason"; + fapia_communication.transaction_id = 4711; + fapia_communication.source_physical_object_name = "source_physical_object_name"; + fapia_communication.priority = FAPIA_COMMUNICATION_PRIORITY_LOW; + fapia_communication.send_reply = true; + fapia_communication.number_of_entries = sizeof (fapia_parameters) / sizeof (FAPIAParameter); + + fapia_parameters[0].logical_object_name = "logical_object_name0"; + fapia_parameters[1].logical_object_name = "logical_object_name1"; + fapia_parameters[2].logical_object_name = "logical_object_name2"; + fapia_parameters[0].parameter_name = "parameter_name0"; + fapia_parameters[1].parameter_name = "parameter_name1"; + fapia_parameters[2].parameter_name = "parameter_name2"; + + + + // Conversion test 1. ********************************* + rc = controller.convert_to_read_request ( + &mr_read_request, + &fapia_communication, + fapia_parameters); + + CPPUNIT_ASSERT (rc == 0); + CPPUNIT_ASSERT (mr_read_request.destination_physical_object_address_ == "127.0.0.0"); + CPPUNIT_ASSERT (mr_read_request.communication_.communication_error_.error_code_ == FAPIA_ERROR_COMMUNICATION); + CPPUNIT_ASSERT (mr_read_request.communication_.communication_error_.reason_ == "reason"); + CPPUNIT_ASSERT (mr_read_request.communication_.transaction_id_ == 4711); + CPPUNIT_ASSERT (mr_read_request.communication_.source_physical_object_name_ == "source_physical_object_name"); + CPPUNIT_ASSERT (mr_read_request.communication_.send_reply_ == true); + CPPUNIT_ASSERT (mr_read_request.parameters_.size () == 3); + CPPUNIT_ASSERT (mr_read_request.parameters_[0].logical_object_name_ == "logical_object_name0"); + CPPUNIT_ASSERT (mr_read_request.parameters_[1].logical_object_name_ == "logical_object_name1"); + CPPUNIT_ASSERT (mr_read_request.parameters_[2].logical_object_name_ == "logical_object_name2"); + CPPUNIT_ASSERT (mr_read_request.parameters_[0].parameter_name_ == "parameter_name0"); + CPPUNIT_ASSERT (mr_read_request.parameters_[1].parameter_name_ == "parameter_name1"); + CPPUNIT_ASSERT (mr_read_request.parameters_[2].parameter_name_ == "parameter_name2"); + + + + // Conversion test 2. ********************************* + rc = controller.convert_from_read_request ( + &fapia_communication, + fapia_parameters, + &mr_read_request); + + CPPUNIT_ASSERT (rc == 0); + CPPUNIT_ASSERT (fapia_communication.communication_error.error_code == FAPIA_ERROR_COMMUNICATION); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_communication.communication_error.reason, "reason") == 0); + CPPUNIT_ASSERT (fapia_communication.transaction_id == 4711); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_communication.source_physical_object_name, "source_physical_object_name") == 0); + CPPUNIT_ASSERT (fapia_communication.priority == FAPIA_COMMUNICATION_PRIORITY_LOW); + CPPUNIT_ASSERT (fapia_communication.send_reply != 0); + CPPUNIT_ASSERT (fapia_communication.number_of_entries == 3); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[0].logical_object_name, "logical_object_name0") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[1].logical_object_name, "logical_object_name1") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[2].logical_object_name, "logical_object_name2") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[0].parameter_name , "parameter_name0") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[1].parameter_name , "parameter_name1") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[2].parameter_name , "parameter_name2") == 0); + + controller.free_memory (fapia_parameters, fapia_communication.number_of_entries); + controller.free_memory (&fapia_communication); + + + + // Initialize for test 3 and 4. *********************** + fapia_communication.communication_error.error_code = FAPIA_ERROR_COMMUNICATION; + fapia_communication.communication_error.reason = "reason"; + fapia_communication.transaction_id = 4711; + fapia_communication.source_physical_object_name = "source_physical_object_name"; + fapia_communication.priority = FAPIA_COMMUNICATION_PRIORITY_LOW; + fapia_communication.send_reply = true; + fapia_communication.number_of_entries = sizeof (fapia_parameters) / sizeof (FAPIAParameter); + + fapia_parameters[0].logical_object_name = "logical_object_name0"; + fapia_parameters[1].logical_object_name = "logical_object_name1"; + fapia_parameters[2].logical_object_name = "logical_object_name2"; + fapia_parameters[0].parameter_name = "parameter_name0"; + fapia_parameters[1].parameter_name = "parameter_name1"; + fapia_parameters[2].parameter_name = "parameter_name2"; + + unsigned short us = 29; + double d = 1.234; + char * s = "test string"; + + fapia_values[0].data_type = FAPIA_DATA_TYPE_SHORT; + fapia_values[0].data_length = sizeof (unsigned short); + fapia_values[0].data_value = &us; + fapia_values[0].unit = "msec"; + + fapia_values[1].data_type = FAPIA_DATA_TYPE_DOUBLE; + fapia_values[1].data_length = sizeof (double); + fapia_values[1].data_value = &d; + fapia_values[1].unit = "kB"; + + fapia_values[2].data_type = FAPIA_DATA_TYPE_STRING; + fapia_values[2].data_length = ACE_OS::strlen (s); + fapia_values[2].data_value = s; + fapia_values[2].unit = ""; + + fapia_errors[0].error_code = FAPIA_ERROR_PARAMETER_NOT_FOUND; + fapia_errors[0].reason = "The parameter parameter_name0 could not be found"; + + fapia_errors[1].error_code = FAPIA_ERROR_OK; + fapia_errors[1].reason = ""; + + fapia_errors[2].error_code = FAPIA_ERROR_OK; + fapia_errors[2].reason = ""; + + + + // Conversion test 3. ********************************* + rc = controller.convert_to_read_response ( + &mr_read_response, + &fapia_communication, + fapia_parameters, + fapia_values, + fapia_errors); + + CPPUNIT_ASSERT (rc == 0); + CPPUNIT_ASSERT (mr_read_response.destination_physical_object_address_ == "127.0.0.0"); + CPPUNIT_ASSERT (mr_read_response.communication_.communication_error_.error_code_ == FAPIA_ERROR_COMMUNICATION); + CPPUNIT_ASSERT (mr_read_response.communication_.communication_error_.reason_ == "reason"); + CPPUNIT_ASSERT (mr_read_response.communication_.transaction_id_ == 4711); + CPPUNIT_ASSERT (mr_read_response.communication_.source_physical_object_name_ == "source_physical_object_name"); + CPPUNIT_ASSERT (mr_read_response.communication_.send_reply_ == true); + CPPUNIT_ASSERT (mr_read_response.parameters_.size () == 3); + CPPUNIT_ASSERT (mr_read_response.parameters_[0].logical_object_name_ == "logical_object_name0"); + CPPUNIT_ASSERT (mr_read_response.parameters_[1].logical_object_name_ == "logical_object_name1"); + CPPUNIT_ASSERT (mr_read_response.parameters_[2].logical_object_name_ == "logical_object_name2"); + CPPUNIT_ASSERT (mr_read_response.parameters_[0].parameter_name_ == "parameter_name0"); + CPPUNIT_ASSERT (mr_read_response.parameters_[1].parameter_name_ == "parameter_name1"); + CPPUNIT_ASSERT (mr_read_response.parameters_[2].parameter_name_ == "parameter_name2"); + CPPUNIT_ASSERT (mr_read_response.values_.size () == 3); + CPPUNIT_ASSERT (mr_read_response.values_[0].data_type_ == FAPIA_DATA_TYPE_SHORT); + CPPUNIT_ASSERT (mr_read_response.values_[0].data_len ()== sizeof (unsigned short)); + CPPUNIT_ASSERT (ACE_OS::memcmp (mr_read_response.values_[0].data_value (), &us, mr_read_response.values_[0].data_len ()) == 0); + CPPUNIT_ASSERT (mr_read_response.values_[0].unit_ == "msec"); + CPPUNIT_ASSERT (mr_read_response.values_[1].data_type_ == FAPIA_DATA_TYPE_DOUBLE); + CPPUNIT_ASSERT (mr_read_response.values_[1].data_len ()== sizeof (double)); + CPPUNIT_ASSERT (ACE_OS::memcmp (mr_read_response.values_[1].data_value (), &d, mr_read_response.values_[1].data_len ()) == 0); + CPPUNIT_ASSERT (mr_read_response.values_[1].unit_ == "kB"); + CPPUNIT_ASSERT (mr_read_response.values_[2].data_type_ == FAPIA_DATA_TYPE_STRING); + CPPUNIT_ASSERT (mr_read_response.values_[2].data_len ()== ACE_OS::strlen (s)); + CPPUNIT_ASSERT (ACE_OS::memcmp (mr_read_response.values_[2].data_value (), s, mr_read_response.values_[2].data_len ()) == 0); + CPPUNIT_ASSERT (mr_read_response.values_[2].unit_ == ""); + CPPUNIT_ASSERT (mr_read_response.errors_.size () == 3); + CPPUNIT_ASSERT (mr_read_response.errors_[0].error_code_ == FAPIA_ERROR_PARAMETER_NOT_FOUND); + CPPUNIT_ASSERT (mr_read_response.errors_[0].reason_ == "The parameter parameter_name0 could not be found"); + CPPUNIT_ASSERT (mr_read_response.errors_[1].error_code_ == FAPIA_ERROR_OK); + CPPUNIT_ASSERT (mr_read_response.errors_[1].reason_ == ""); + CPPUNIT_ASSERT (mr_read_response.errors_[2].error_code_ == FAPIA_ERROR_OK); + CPPUNIT_ASSERT (mr_read_response.errors_[2].reason_ == ""); + + + + + + // Conversion test 4. ********************************* + rc = controller.convert_from_read_response ( + &fapia_communication, + fapia_parameters, + fapia_values, + fapia_errors, + &mr_read_response); + + CPPUNIT_ASSERT (rc == 0); + CPPUNIT_ASSERT (fapia_communication.communication_error.error_code == FAPIA_ERROR_COMMUNICATION); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_communication.communication_error.reason, "reason") == 0); + CPPUNIT_ASSERT (fapia_communication.transaction_id == 4711); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_communication.source_physical_object_name, "source_physical_object_name") == 0); + CPPUNIT_ASSERT (fapia_communication.priority == FAPIA_COMMUNICATION_PRIORITY_LOW); + CPPUNIT_ASSERT (fapia_communication.send_reply != 0); + CPPUNIT_ASSERT (fapia_communication.number_of_entries == 3); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[0].logical_object_name, "logical_object_name0") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[1].logical_object_name, "logical_object_name1") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[2].logical_object_name, "logical_object_name2") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[0].parameter_name , "parameter_name0") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[1].parameter_name , "parameter_name1") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[2].parameter_name , "parameter_name2") == 0); + CPPUNIT_ASSERT (fapia_values[0].data_type == FAPIA_DATA_TYPE_SHORT); + CPPUNIT_ASSERT (fapia_values[0].data_length == sizeof (unsigned short)); + CPPUNIT_ASSERT (ACE_OS::memcmp (fapia_values[0].data_value, &us, sizeof (unsigned short)) == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp (fapia_values[0].unit, "msec") == 0); + CPPUNIT_ASSERT (fapia_values[1].data_type == FAPIA_DATA_TYPE_DOUBLE); + CPPUNIT_ASSERT (fapia_values[1].data_length == sizeof (double)); + CPPUNIT_ASSERT (ACE_OS::memcmp (fapia_values[1].data_value, &d, sizeof (double)) == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp (fapia_values[1].unit, "kB") == 0); + CPPUNIT_ASSERT (fapia_values[2].data_type == FAPIA_DATA_TYPE_STRING); + CPPUNIT_ASSERT (fapia_values[2].data_length == ACE_OS::strlen (s)); + CPPUNIT_ASSERT (ACE_OS::strcmp ((char *)fapia_values[2].data_value, s) == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp (fapia_values[2].unit, "") == 0); + CPPUNIT_ASSERT (fapia_errors[0].error_code == FAPIA_ERROR_PARAMETER_NOT_FOUND); + CPPUNIT_ASSERT (ACE_OS::strcmp (fapia_errors[0].reason , "The parameter parameter_name0 could not be found") == 0); + CPPUNIT_ASSERT (fapia_errors[1].error_code == FAPIA_ERROR_OK); + CPPUNIT_ASSERT (ACE_OS::strcmp (fapia_errors[1].reason , "") == 0); + CPPUNIT_ASSERT (fapia_errors[2].error_code == FAPIA_ERROR_OK); + CPPUNIT_ASSERT (ACE_OS::strcmp (fapia_errors[2].reason , "") == 0); + + + controller.free_memory (fapia_errors, fapia_communication.number_of_entries); + controller.free_memory (fapia_values, fapia_communication.number_of_entries); + controller.free_memory (fapia_parameters, fapia_communication.number_of_entries); + controller.free_memory (&fapia_communication); + + + + + // Initialize for test 5 and 6. *********************** + fapia_communication.communication_error.error_code = FAPIA_ERROR_COMMUNICATION; + fapia_communication.communication_error.reason = "reason"; + fapia_communication.transaction_id = 4711; + fapia_communication.source_physical_object_name = "source_physical_object_name"; + fapia_communication.priority = FAPIA_COMMUNICATION_PRIORITY_LOW; + fapia_communication.send_reply = true; + fapia_communication.number_of_entries = sizeof (fapia_parameters) / sizeof (FAPIAParameter); + + fapia_parameters[0].logical_object_name = "logical_object_name0"; + fapia_parameters[1].logical_object_name = "logical_object_name1"; + fapia_parameters[2].logical_object_name = "logical_object_name2"; + fapia_parameters[0].parameter_name = "parameter_name0"; + fapia_parameters[1].parameter_name = "parameter_name1"; + fapia_parameters[2].parameter_name = "parameter_name2"; + + fapia_values[0].data_type = FAPIA_DATA_TYPE_SHORT; + fapia_values[0].data_length = sizeof (unsigned short); + fapia_values[0].data_value = &us; + fapia_values[0].unit = "msec"; + + fapia_values[1].data_type = FAPIA_DATA_TYPE_DOUBLE; + fapia_values[1].data_length = sizeof (double); + fapia_values[1].data_value = &d; + fapia_values[1].unit = "kB"; + + fapia_values[2].data_type = FAPIA_DATA_TYPE_STRING; + fapia_values[2].data_length = ACE_OS::strlen (s); + fapia_values[2].data_value = s; + fapia_values[2].unit = ""; + + + + // Conversion test 5. ********************************* + rc = controller.convert_to_write_request ( + &mr_write_request, + &fapia_communication, + fapia_parameters, + fapia_values); + + CPPUNIT_ASSERT (rc == 0); + CPPUNIT_ASSERT (mr_write_request.destination_physical_object_address_ == "127.0.0.0"); + CPPUNIT_ASSERT (mr_write_request.communication_.communication_error_.error_code_ == FAPIA_ERROR_COMMUNICATION); + CPPUNIT_ASSERT (mr_write_request.communication_.communication_error_.reason_ == "reason"); + CPPUNIT_ASSERT (mr_write_request.communication_.transaction_id_ == 4711); + CPPUNIT_ASSERT (mr_write_request.communication_.source_physical_object_name_ == "source_physical_object_name"); + CPPUNIT_ASSERT (mr_write_request.communication_.send_reply_ == true); + CPPUNIT_ASSERT (mr_write_request.parameters_.size () == 3); + CPPUNIT_ASSERT (mr_write_request.parameters_[0].logical_object_name_ == "logical_object_name0"); + CPPUNIT_ASSERT (mr_write_request.parameters_[1].logical_object_name_ == "logical_object_name1"); + CPPUNIT_ASSERT (mr_write_request.parameters_[2].logical_object_name_ == "logical_object_name2"); + CPPUNIT_ASSERT (mr_write_request.parameters_[0].parameter_name_ == "parameter_name0"); + CPPUNIT_ASSERT (mr_write_request.parameters_[1].parameter_name_ == "parameter_name1"); + CPPUNIT_ASSERT (mr_write_request.parameters_[2].parameter_name_ == "parameter_name2"); + CPPUNIT_ASSERT (mr_write_request.values_[0].data_type_ == FAPIA_DATA_TYPE_SHORT); + CPPUNIT_ASSERT (mr_write_request.values_[0].data_len ()== sizeof (unsigned short)); + CPPUNIT_ASSERT (ACE_OS::memcmp (mr_write_request.values_[0].data_value (), &us, mr_write_request.values_[0].data_len ()) == 0); + CPPUNIT_ASSERT (mr_write_request.values_[0].unit_ == "msec"); + CPPUNIT_ASSERT (mr_write_request.values_[1].data_type_ == FAPIA_DATA_TYPE_DOUBLE); + CPPUNIT_ASSERT (mr_write_request.values_[1].data_len ()== sizeof (double)); + CPPUNIT_ASSERT (ACE_OS::memcmp (mr_write_request.values_[1].data_value (), &d, mr_write_request.values_[1].data_len ()) == 0); + CPPUNIT_ASSERT (mr_write_request.values_[1].unit_ == "kB"); + CPPUNIT_ASSERT (mr_write_request.values_[2].data_type_ == FAPIA_DATA_TYPE_STRING); + CPPUNIT_ASSERT (mr_write_request.values_[2].data_len ()== ACE_OS::strlen (s)); + CPPUNIT_ASSERT (ACE_OS::memcmp (mr_write_request.values_[2].data_value (), s, mr_write_request.values_[2].data_len ()) == 0); + CPPUNIT_ASSERT (mr_write_request.values_[2].unit_ == ""); + + + + + + // Conversion test 6. ********************************* + rc = controller.convert_from_write_request ( + &fapia_communication, + fapia_parameters, + fapia_values, + &mr_write_request); + + CPPUNIT_ASSERT (rc == 0); + CPPUNIT_ASSERT (fapia_communication.communication_error.error_code == FAPIA_ERROR_COMMUNICATION); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_communication.communication_error.reason, "reason") == 0); + CPPUNIT_ASSERT (fapia_communication.transaction_id == 4711); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_communication.source_physical_object_name, "source_physical_object_name") == 0); + CPPUNIT_ASSERT (fapia_communication.priority == FAPIA_COMMUNICATION_PRIORITY_LOW); + CPPUNIT_ASSERT (fapia_communication.send_reply != 0); + CPPUNIT_ASSERT (fapia_communication.number_of_entries == 3); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[0].logical_object_name, "logical_object_name0") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[1].logical_object_name, "logical_object_name1") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[2].logical_object_name, "logical_object_name2") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[0].parameter_name , "parameter_name0") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[1].parameter_name , "parameter_name1") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[2].parameter_name , "parameter_name2") == 0); + CPPUNIT_ASSERT (fapia_values[0].data_type == FAPIA_DATA_TYPE_SHORT); + CPPUNIT_ASSERT (fapia_values[0].data_length == sizeof (unsigned short)); + CPPUNIT_ASSERT (ACE_OS::memcmp (fapia_values[0].data_value, &us, sizeof (unsigned short)) == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp (fapia_values[0].unit, "msec") == 0); + CPPUNIT_ASSERT (fapia_values[1].data_type == FAPIA_DATA_TYPE_DOUBLE); + CPPUNIT_ASSERT (fapia_values[1].data_length == sizeof (double)); + CPPUNIT_ASSERT (ACE_OS::memcmp (fapia_values[1].data_value, &d, sizeof (double)) == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp (fapia_values[1].unit, "kB") == 0); + CPPUNIT_ASSERT (fapia_values[2].data_type == FAPIA_DATA_TYPE_STRING); + CPPUNIT_ASSERT (fapia_values[2].data_length == ACE_OS::strlen (s)); + CPPUNIT_ASSERT (ACE_OS::strcmp ((char *)fapia_values[2].data_value, s) == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp (fapia_values[2].unit, "") == 0); + + controller.free_memory (fapia_values, fapia_communication.number_of_entries); + controller.free_memory (fapia_parameters, fapia_communication.number_of_entries); + controller.free_memory (&fapia_communication); + + + + // Initialize for test 7 and 8. *********************** + fapia_communication.communication_error.error_code = FAPIA_ERROR_COMMUNICATION; + fapia_communication.communication_error.reason = "reason"; + fapia_communication.transaction_id = 4711; + fapia_communication.source_physical_object_name = "source_physical_object_name"; + fapia_communication.priority = FAPIA_COMMUNICATION_PRIORITY_LOW; + fapia_communication.send_reply = true; + fapia_communication.number_of_entries = sizeof (fapia_parameters) / sizeof (FAPIAParameter); + + fapia_parameters[0].logical_object_name = "logical_object_name0"; + fapia_parameters[1].logical_object_name = "logical_object_name1"; + fapia_parameters[2].logical_object_name = "logical_object_name2"; + fapia_parameters[0].parameter_name = "parameter_name0"; + fapia_parameters[1].parameter_name = "parameter_name1"; + fapia_parameters[2].parameter_name = "parameter_name2"; + + fapia_errors[0].error_code = FAPIA_ERROR_PARAMETER_NOT_FOUND; + fapia_errors[0].reason = "The parameter parameter_name0 could not be found"; + + fapia_errors[1].error_code = FAPIA_ERROR_OK; + fapia_errors[1].reason = ""; + + fapia_errors[2].error_code = FAPIA_ERROR_OK; + fapia_errors[2].reason = ""; + + + + // Conversion test 7. ********************************* + rc = controller.convert_to_write_response ( + &mr_write_response, + &fapia_communication, + fapia_parameters, + fapia_errors); + + CPPUNIT_ASSERT (rc == 0); + CPPUNIT_ASSERT (mr_write_response.destination_physical_object_address_ == "127.0.0.0"); + CPPUNIT_ASSERT (mr_write_response.communication_.communication_error_.error_code_ == FAPIA_ERROR_COMMUNICATION); + CPPUNIT_ASSERT (mr_write_response.communication_.communication_error_.reason_ == "reason"); + CPPUNIT_ASSERT (mr_write_response.communication_.transaction_id_ == 4711); + CPPUNIT_ASSERT (mr_write_response.communication_.source_physical_object_name_ == "source_physical_object_name"); + CPPUNIT_ASSERT (mr_write_response.communication_.send_reply_ == true); + CPPUNIT_ASSERT (mr_write_response.parameters_.size () == 3); + CPPUNIT_ASSERT (mr_write_response.parameters_[0].logical_object_name_ == "logical_object_name0"); + CPPUNIT_ASSERT (mr_write_response.parameters_[1].logical_object_name_ == "logical_object_name1"); + CPPUNIT_ASSERT (mr_write_response.parameters_[2].logical_object_name_ == "logical_object_name2"); + CPPUNIT_ASSERT (mr_write_response.parameters_[0].parameter_name_ == "parameter_name0"); + CPPUNIT_ASSERT (mr_write_response.parameters_[1].parameter_name_ == "parameter_name1"); + CPPUNIT_ASSERT (mr_write_response.parameters_[2].parameter_name_ == "parameter_name2"); + CPPUNIT_ASSERT (mr_write_response.errors_.size () == 3); + CPPUNIT_ASSERT (mr_write_response.errors_[0].error_code_ == FAPIA_ERROR_PARAMETER_NOT_FOUND); + CPPUNIT_ASSERT (mr_write_response.errors_[0].reason_ == "The parameter parameter_name0 could not be found"); + CPPUNIT_ASSERT (mr_write_response.errors_[1].error_code_ == FAPIA_ERROR_OK); + CPPUNIT_ASSERT (mr_write_response.errors_[1].reason_ == ""); + CPPUNIT_ASSERT (mr_write_response.errors_[2].error_code_ == FAPIA_ERROR_OK); + CPPUNIT_ASSERT (mr_write_response.errors_[2].reason_ == ""); + + + + + + // Conversion test 8. ********************************* + rc = controller.convert_from_write_response ( + &fapia_communication, + fapia_parameters, + fapia_errors, + &mr_write_response); + + CPPUNIT_ASSERT (rc == 0); + CPPUNIT_ASSERT (fapia_communication.communication_error.error_code == FAPIA_ERROR_COMMUNICATION); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_communication.communication_error.reason, "reason") == 0); + CPPUNIT_ASSERT (fapia_communication.transaction_id == 4711); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_communication.source_physical_object_name, "source_physical_object_name") == 0); + CPPUNIT_ASSERT (fapia_communication.priority == FAPIA_COMMUNICATION_PRIORITY_LOW); + CPPUNIT_ASSERT (fapia_communication.send_reply != 0); + CPPUNIT_ASSERT (fapia_communication.number_of_entries == 3); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[0].logical_object_name, "logical_object_name0") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[1].logical_object_name, "logical_object_name1") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[2].logical_object_name, "logical_object_name2") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[0].parameter_name , "parameter_name0") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[1].parameter_name , "parameter_name1") == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp(fapia_parameters[2].parameter_name , "parameter_name2") == 0); + CPPUNIT_ASSERT (fapia_errors[0].error_code == FAPIA_ERROR_PARAMETER_NOT_FOUND); + CPPUNIT_ASSERT (ACE_OS::strcmp (fapia_errors[0].reason , "The parameter parameter_name0 could not be found") == 0); + CPPUNIT_ASSERT (fapia_errors[1].error_code == FAPIA_ERROR_OK); + CPPUNIT_ASSERT (ACE_OS::strcmp (fapia_errors[1].reason , "") == 0); + CPPUNIT_ASSERT (fapia_errors[2].error_code == FAPIA_ERROR_OK); + CPPUNIT_ASSERT (ACE_OS::strcmp (fapia_errors[2].reason , "") == 0); + + + controller.free_memory (fapia_errors, fapia_communication.number_of_entries); + controller.free_memory (fapia_parameters, fapia_communication.number_of_entries); + controller.free_memory (&fapia_communication); + + controller.fapia_deinit (); + } + ACE_OS::unlink (init.fapia_shared_memory_name_.c_str ()); + } + +/*---------------------------------------------------------------------------*/ + + + } /* namespace Test */ + } /* namespace Controller */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + Added: fapia-trunk/FAPIAController/test/conversions/source/test_fapia_controller_conversions.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAController/test/conversions/source/test_fapia_controller_conversions.h Thu Jul 19 07:12:01 2007 @@ -0,0 +1,49 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file marshallingtest.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPIA_IPC_SYNCHRONIZE_ONE_PROCESS_TEST_H_ +#define _FAPIA_IPC_SYNCHRONIZE_ONE_PROCESS_TEST_H_ + +#include + +namespace FAPI + { + namespace Acyclic + { + namespace Controller + { + namespace Test + { + class ConversionsTest : public CppUnit::TestFixture + { + public: + CPPUNIT_TEST_SUITE (ConversionsTest); + CPPUNIT_TEST (test_method_request_conversions); + CPPUNIT_TEST_SUITE_END (); + + private: + + public: + ConversionsTest (void); + + void setUp (void); + void tearDown (void); + + void test_method_request_conversions (void); + }; /* class ConversionsTest */ + + } /* namespace Test */ + } /* namespace Controller */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif // _FAPIA_IPC_SYNCHRONIZE_ONE_PROCESS_TEST_H_ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:46:35 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:46:35 +0200 Subject: [OSADL-svn-commits] r83 - fapia-trunk/FAPIAIPCParameter/interface Message-ID: <200710020946.l929kZUd021133@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:13:16 2007 New Revision: 83 Log: Added a folder remotely Added: fapia-trunk/FAPIAIPCParameter/interface/ fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCIParameter.h fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterCommunication.h fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterError.h fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterImplementation.h fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterInfo.h fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterInit.h fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequest.h fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestInfoRequest.h fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestInfoResponse.h fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestReadRequest.h fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestReadResponse.h fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestWriteRequest.h fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestWriteResponse.h fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterParameter.h fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterValue.h Added: fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCIParameter.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCIParameter.h Thu Jul 19 07:13:16 2007 @@ -0,0 +1,64 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCIParameter.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_IPARAMETER_H_ +#define _FAPI_ACYCLIC_IPC_IPARAMETER_H_ + +#include "FAPIAIPCParameterInit.h" +#include "FAPIAIPCParameterError.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + /** + * @interface IParameter + * + * @brief The IParameter is the interface for the IPC::Parameter + * module. + * + */ + class IParameter + { + + public: + /** + * @brief Initializes the IPC::Parameter module. The + * physical_object_address is returned. + * + * If it returns -1 there was an error. Look at the error object. + * + */ + virtual int init + ( + const FAPI::Acyclic::IPC::Parameter::Init& init, + ACE_CString& physical_object_address, + FAPI::Acyclic::IPC::Parameter::Error& error + ) = 0; + + /** + * @brief Deinitializes the IPC::Parameter module. + * + * If it returns -1 an error occured. + * + */ + virtual int deinit (void) = 0; + + }; /* class IParameter */ + + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_IPARAMETER_H_ */ Added: fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterCommunication.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterCommunication.h Thu Jul 19 07:13:16 2007 @@ -0,0 +1,110 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterCommunication.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_PARAMETER_COMMUNICATION_H_ +#define _FAPI_ACYCLIC_IPC_PARAMETER_COMMUNICATION_H_ + +#include /**/ +#include "FAPIAIPCParameterError.h" + + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + /** + * @class Communication + * + * @brief The Communication is used inside all + * MethodRequests. + * + */ + class Communication + { + + public: + /** + * @brief Constructor of Communication. + * + */ + Communication (void); + + /** + * @brief Copy Constructor. + * + */ + Communication (const Communication&); + + /** + * @brief Assignment operator. + * + */ + const Communication& operator= (const Communication&); + + /** + * @brief Destructor of Communication. + * + */ + virtual ~Communication (void); + + /** + * @brief Comparison operator. + * + */ + bool operator!= (const Communication&) const; + + // The member variables are public. Therefore there is no need + // to implement get and set methods. This class is used as a + // structure with constructor, destructor, copy constructor and + // assignement operator. + public: + + /// Possible communication error. If the error_code is not + /// ok then the whole transaction was canceled. + FAPI::Acyclic::IPC::Parameter::Error communication_error_; + + /// Transaction id to identify the message. The combination + /// of source_name and transaction_id is unique. + unsigned long transaction_id_; + + /// Name of the logical object. + ACE_CString logical_object_name_; + + /// Name of the physical source object. + ACE_CString source_physical_object_name_; + + /// Indicates whether a request should be replied or not. + bool send_reply_; + + + private: + /// internal initialisation + void open (void); + + /// internal copying + void copy (const Communication&); + + /// internal cleanup + void close (void); + + }; /* class Communication */ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_PARAMETER_COMMUNICATION_H_ */ Added: fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterError.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterError.h Thu Jul 19 07:13:16 2007 @@ -0,0 +1,101 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterError.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_PARAMETER_ERROR_H_ +#define _FAPI_ACYCLIC_IPC_PARAMETER_ERROR_H_ + +#include + +#include /**/ +#include /**/ + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + /** + * @class Error + * + * @brief The Error is used as a result for all requests. + * + */ + class Error + { + + public: + /** + * @brief Constructor of Error. + * + */ + Error (void); + + /** + * @brief Copy Constructor. + * + */ + Error (const Error&); + + /** + * @brief Assignment operator. + * + */ + const Error& operator= (const Error&); + + /** + * @brief Destructor of Error. + * + */ + virtual ~Error (void); + + /** + * @brief Comparison operator. + * + */ + bool operator!= (const Error&) const; + + // The member variables are public. Therefore there is no need + // to implement get and set methods. This class is used as a + // structure with constructor, destructor, copy constructor and + // assignement operator. + public: + /// Error code. Maybe ok. + FAPIAErrorCode error_code_; + + /// Reason of failure. If error_ is ok the reason_ is an + /// empty string. + ACE_CString reason_; + + private: + /// internal initialisation + void open (void); + + /// internal copying + void copy (const Error&); + + /// internal cleanup + void close (void); + + }; /* class Error */ + + /// This typedef is a container for Errors. + typedef ACE_Vector Errors; + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_PARAMETER_ERROR_H_ */ Added: fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterImplementation.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterImplementation.h Thu Jul 19 07:13:16 2007 @@ -0,0 +1,97 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterImplementation.h + * + * $Id$ + * + * @author Friedhelm Wolf + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_ParameterImplementation_H_ +#define _FAPI_ACYCLIC_IPC_ParameterImplementation_H_ + +#include "FAPIAIPCIParameter.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + + // forward declarations + class SenderService; + class ReceiverTask; + + /** + * @class ParameterImplementation + * + * @brief The IParameterImplementation is the interface for the IPC::ParameterImplementation + * module. + * + */ + class ParameterImplementation : public IParameter + { + + public: + + /** + * @brief Constructor of ParameterImplementation. + * + */ + ParameterImplementation (); + + /** + * @brief Constructor of ParameterImplementation. + * + */ + virtual ~ParameterImplementation (); + + /** + * @sa IParameterImplementation + */ + virtual int init + ( + const FAPI::Acyclic::IPC::Parameter::Init& init, + ACE_CString& physical_object_address, + FAPI::Acyclic::IPC::Parameter::Error& error + ); + + /** + * @sa IParameterImplementation + */ + virtual int deinit (void); + + protected: + /// responsible for processing of incoming requests + ReceiverTask* recv_task_; + + /// responsible for sending requests + SenderService* send_task_; + + private: + /** + * @brief private copy constructor to prevent + * copying of this class + */ + ParameterImplementation (const ParameterImplementation&); + + /** + * @brief private assignment operator to prevent + * copying of this class + */ + const ParameterImplementation& operator= (const ParameterImplementation&); + + }; /* class ParameterImplementation */ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_ParameterImplementation_H_ */ Added: fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterInfo.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterInfo.h Thu Jul 19 07:13:16 2007 @@ -0,0 +1,128 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterInfo.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_PARAMETER_INFO_H_ +#define _FAPI_ACYCLIC_IPC_PARAMETER_INFO_H_ + +#include /**/ +#include /**/ + +#include + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + /** + * @class Info + * + * @brief The Info instance contains a info for a parameter. + * + */ + class Info + { + + public: + /** + * @brief Constructor of Info. + * + */ + Info (void); + + /** + * @brief Copy Constructor. + * + */ + Info (const Info&); + + /** + * @brief Assignment operator. + * + */ + const Info& operator= (const Info&); + + /** + * @brief Destructor of Info. + * + */ + virtual ~Info (void); + + /** + * @brief Comparison operator. + * + */ + bool operator!= (const Info&) const; + + // The member variables are public. Therefore there is no need + // to implement get and set methods. This class is used as a + // structure with constructor, destructor, copy constructor and + // assignement operator. + public: + + /// Datatype of the parameter. + FAPIADataType data_type_; + + /// Length of the info. + unsigned long data_len_; + + /// Pointer to the minimum value. Dependend on the data_type + /// it must be casted. + void* min_value_; + + /// Pointer to the minimum value. Dependend on the data_type + /// it must be casted. + void* max_value_; + + /// Priority of the transaction. + FAPIAAccessRights access_rights_; + + /// Unit of the value. + ACE_CString unit_; + + /// Exponent of base 10 to determine value for corresponding unit. + /// If exponent is not used it must be 0. + long exponent_; + + /// Factor to determine value for corresponding unit. + /// If factor is not used it must be 1. + long factor_; + + /// Descriptoin of the parameter. + ACE_CString description_; + + + private: + + /// internal initialisation + void open (void); + + /// internal copying + void copy (const Info&); + + /// internal cleanup + void close (void); + + }; /* class Info */ + + /// This typedef is a container for Infos. + typedef ACE_Vector Infos; + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_PARAMETER_INFO_H_ */ Added: fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterInit.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterInit.h Thu Jul 19 07:13:16 2007 @@ -0,0 +1,92 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterInit.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_PARAMETER_INIT_H_ +#define _FAPI_ACYCLIC_IPC_PARAMETER_INIT_H__ + +// forward declarations +class ACE_Activation_Queue; + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + /** + * @class Init + * + * @brief The Init structure is used to initialize the + * IPC::Parameter module. + * + */ + class Init + { + + public: + /** + * @brief Constructor of Init. + * + */ + Init (void); + + /** + * @brief Copy Constructor. + * + */ + Init (const Init&); + + /** + * @brief Assignment operator. + * + */ + const Init& operator= (const Init&); + + /** + * @brief Destructor of Init. + * + */ + virtual ~Init (void); + + // The member variables are public. Therefore there is no need + // to implement get and set methods. This class is used as a + // structure with constructor, destructor, copy constructor and + // assignement operator. + public: + /// Reference to the send_queue. The IPC::Parameter module + /// reads the requests from this queue. + ACE_Activation_Queue* send_queue_; + + /// Reference to the receive_queue. The IPC::Parameter module + /// writes the replies to this queue. + ACE_Activation_Queue* receive_queue_; + + private: + /// internal initialisation + void open (void); + + /// internal copying + void copy (const Init& init); + + /// internal cleanup + void close (void); + + }; /* class Init */ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_PARAMETER_INIT_H_ */ Added: fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequest.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequest.h Thu Jul 19 07:13:16 2007 @@ -0,0 +1,88 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterMethodRequest.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_H_ +#define _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_H_ + +#include /**/ +#include /**/ + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + /** + * @class MethodRequest + * + * @brief The MethodRequest is the base class for all method + * requests of the two IPC::Parameter queues. + * + */ + class MethodRequest : public ACE_Method_Request + { + + public: + /** + * @brief Constructor of MethodRequest. + * + */ + MethodRequest (unsigned long priority = 0); + + /** + * @brief Destructor of MethodRequest. + * + */ + virtual ~MethodRequest (void); + + /** + * @brief Invoked when the MethodRequest is scheduled to run. + * + * If it returns -1 the receiving thread of this message must + * shut down. + * + */ + virtual int call (void) = 0; + + /// Address of the destination endpoint. + ACE_CString destination_physical_object_address_; + + protected: + + private: + /** + * @brief Copy Constructor is private, so this object cannot + * be copied. + * + */ + MethodRequest (const MethodRequest&); + + /** + * @brief Assignment operator is private, so this object cannot + * be copied. + * + */ + const MethodRequest& operator= (const MethodRequest&); + + }; /* class MethodRequest */ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#define FAPIA_COMMUNICATION_PRIORITY_MAX 0xFFFF + +#endif /* _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_H_ */ Added: fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestInfoRequest.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestInfoRequest.h Thu Jul 19 07:13:16 2007 @@ -0,0 +1,97 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterMethodRequestInfoRequest.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_INFO_REQUEST_H_ +#define _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_INFO_REQUEST_H_ + +#include "FAPIAIPCParameterMethodRequest.h" +#include "FAPIAIPCParameterCommunication.h" +#include "FAPIAIPCParameterParameter.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + /** + * @class MethodRequestInfoRequest + * + * @brief The MethodRequestInfoRequest is the class for a info + * operation request. + * + */ + class MethodRequestInfoRequest : public FAPI::Acyclic::IPC::Parameter::MethodRequest + { + + public: + /** + * @brief Constructor of MethodRequestInfoRequest. + * + */ + MethodRequestInfoRequest (void); + + /** + * @brief Destructor of MethodRequestInfoRequest. + * + */ + virtual ~MethodRequestInfoRequest (void); + + /** + * @brief Comparison operator + * + */ + bool operator!= (const MethodRequestInfoRequest&) const; + + /** + * @brief Invoked when the MethodRequestInfoRequest is + * scheduled to run. + * + * If it returns -1 the receiving thread of this message + * must shut down. + * + */ + virtual int call (void); + + /// Information for communication purposes. + FAPI::Acyclic::IPC::Parameter::Communication communication_; + + /// Parameters to info. + FAPI::Acyclic::IPC::Parameter::Parameters parameters_; + + protected: + + private: + /** + * @brief Copy Constructor is private, so this object cannot + * be copied. + * + */ + MethodRequestInfoRequest (const MethodRequestInfoRequest&); + + /** + * @brief Assignment operator is private, so this object cannot + * be copied. + * + */ + const MethodRequestInfoRequest& operator= (const MethodRequestInfoRequest&); + + }; /* class MethodRequestInfoRequest */ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_INFO_REQUEST_H_ */ Added: fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestInfoResponse.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestInfoResponse.h Thu Jul 19 07:13:16 2007 @@ -0,0 +1,106 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterMethodRequestInfoResponse.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_INFO_RESPONSE_H_ +#define _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_INFO_RESPONSE_H_ + +#include "FAPIAIPCParameterMethodRequest.h" +#include "FAPIAIPCParameterCommunication.h" +#include "FAPIAIPCParameterParameter.h" +#include "FAPIAIPCParameterInfo.h" +#include "FAPIAIPCParameterError.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + /** + * @class MethodRequestInfoResponse + * + * @brief The MethodRequestInfoResponse is the class for a info + * operation request. + * + */ + class MethodRequestInfoResponse : public FAPI::Acyclic::IPC::Parameter::MethodRequest + { + + public: + /** + * @brief Constructor of MethodRequestInfoResponse. + * + */ + MethodRequestInfoResponse (void); + + /** + * @brief Destructor of MethodRequestInfoResponse. + * + */ + virtual ~MethodRequestInfoResponse (void); + + /** + * @brief Comparison operator + * + */ + bool operator!= (const MethodRequestInfoResponse&) const; + + /** + * @brief Invoked when the MethodRequestInfoResponse is + * scheduled to run. + * + * If it returns -1 the receiving thread of this message + * must shut down. + * + */ + virtual int call (void); + + /// Information for communication purposes. + Communication communication_; + + /// Parameters which were written. + FAPI::Acyclic::IPC::Parameter::Parameters parameters_; + + /// Infos which were written. + FAPI::Acyclic::IPC::Parameter::Infos infos_; + + /// Errors for the written parameters. If the relating error + /// is ok the value was successfully written. + FAPI::Acyclic::IPC::Parameter::Errors errors_; + + protected: + + private: + /** + * @brief Copy Constructor is private, so this object cannot + * be copied. + * + */ + MethodRequestInfoResponse (const MethodRequestInfoResponse&); + + /** + * @brief Assignment operator is private, so this object cannot + * be copied. + * + */ + const MethodRequestInfoResponse& operator= (const MethodRequestInfoResponse&); + + }; /* class MethodRequestInfoResponse */ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_INFO_RESPONSE_H_ */ Added: fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestReadRequest.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestReadRequest.h Thu Jul 19 07:13:16 2007 @@ -0,0 +1,100 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterMethodRequestReadRequest.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_READ_REQUEST_H_ +#define _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_READ_REQUEST_H_ + +#include "FAPIAIPCParameterMethodRequest.h" +#include "FAPIAIPCParameterCommunication.h" +#include "FAPIAIPCParameterParameter.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + /** + * @class MethodRequestReadRequest + * + * @brief The MethodRequestReadRequest is the class for a read + * operation request. + * + */ + class MethodRequestReadRequest : \ + public FAPI::Acyclic::IPC::Parameter::MethodRequest + { + + public: + /** + * @brief Constructor of MethodRequestReadRequest. + * + */ + MethodRequestReadRequest (void); + + /** + * @brief Destructor of MethodRequestReadRequest. + * + */ + virtual ~MethodRequestReadRequest (void); + + /** + * @brief Comparison operator + * + */ + bool operator!= (const MethodRequestReadRequest&) const; + + /** + * @brief Invoked when the MethodRequestReadRequest is + * scheduled to run. + * + * If it returns -1 the receiving thread of this message + * must shut down. + * + */ + virtual int call (void); + + /// Information for communication purposes. + FAPI::Acyclic::IPC::Parameter::Communication \ + communication_; + + /// Parameters to read. + FAPI::Acyclic::IPC::Parameter::Parameters parameters_; + + protected: + + private: + /** + * @brief Copy Constructor is private, so this object + * cannot be copied. + * + */ + MethodRequestReadRequest (const MethodRequestReadRequest&); + + /** + * @brief Assignment operator is private, so this object + * cannot be copied. + * + */ + const MethodRequestReadRequest& operator= ( \ + const MethodRequestReadRequest&); + + }; /* class MethodRequestReadRequest */ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_READ_REQUEST_H_ */ Added: fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestReadResponse.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestReadResponse.h Thu Jul 19 07:13:16 2007 @@ -0,0 +1,110 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterMethodRequestReadResponse.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_READ_RESPONSE_H_ +#define _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_READ_RESPONSE_H_ + +#include "FAPIAIPCParameterMethodRequest.h" +#include "FAPIAIPCParameterCommunication.h" +#include "FAPIAIPCParameterParameter.h" +#include "FAPIAIPCParameterValue.h" +#include "FAPIAIPCParameterError.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + /** + * @class MethodRequestReadResponse + * + * @brief The MethodRequestReadResponse is the class for a read + * operation request. + * + */ + class MethodRequestReadResponse : + public FAPI::Acyclic::IPC::Parameter::MethodRequest + { + + public: + /** + * @brief Constructor of MethodRequestReadResponse. + * + */ + MethodRequestReadResponse (void); + + /** + * @brief Destructor of MethodRequestReadResponse. + * + */ + virtual ~MethodRequestReadResponse (void); + + /** + * @brief Comparison operator + * + */ + bool operator!= (const MethodRequestReadResponse&) const; + + /** + * @brief Invoked when the MethodRequestReadResponse is + * scheduled to run. + * + * If it returns -1 the receiving thread of this message + * must shut down. + * + */ + virtual int call (void); + + /// Information for communication purposes. + Communication communication_; + + /// Parameters which were read. + FAPI::Acyclic::IPC::Parameter::Parameters parameters_; + + /// Values for parameters. The position of a value + /// relates to the position of its parameter. The + /// value is only valid if the relating error is ok. + FAPI::Acyclic::IPC::Parameter::Values values_; + + /// Errors for the parameters. If the relating error is ok + /// the value is valid. + FAPI::Acyclic::IPC::Parameter::Errors errors_; + + protected: + + private: + /** + * @brief Copy Constructor is private, so this object cannot + * be copied. + * + */ + MethodRequestReadResponse (const MethodRequestReadResponse&); + + /** + * @brief Assignment operator is private, so this object cannot + * be copied. + * + */ + const MethodRequestReadResponse& operator= ( + const MethodRequestReadResponse&); + + }; /* class MethodRequestReadResponse */ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_READ_RESPONSE_H_ */ Added: fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestWriteRequest.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestWriteRequest.h Thu Jul 19 07:13:16 2007 @@ -0,0 +1,102 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterMethodRequestWriteRequest.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_WRITE_REQUEST_H_ +#define _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_WRITE_REQUEST_H_ + +#include "FAPIAIPCParameterMethodRequest.h" +#include "FAPIAIPCParameterCommunication.h" +#include "FAPIAIPCParameterParameter.h" +#include "FAPIAIPCParameterValue.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + /** + * @class MethodRequestWriteRequest + * + * @brief The MethodRequestWriteRequest is the class for a write + * operation request. + * + */ + class MethodRequestWriteRequest : public FAPI::Acyclic::IPC::Parameter::MethodRequest + { + + public: + /** + * @brief Constructor of MethodRequestWriteRequest. + * + */ + MethodRequestWriteRequest (void); + + /** + * @brief Destructor of MethodRequestWriteRequest. + * + */ + virtual ~MethodRequestWriteRequest (void); + + /** + * @brief Comparison operator + * + */ + bool operator!= (const MethodRequestWriteRequest&) const; + + /** + * @brief Invoked when the MethodRequestWriteRequest is + * scheduled to run. + * + * If it returns -1 the receiving thread of this message + * must shut down. + * + */ + virtual int call (void); + + /// Information for communication purposes. + FAPI::Acyclic::IPC::Parameter::Communication communication_; + + /// Parameters to write. + FAPI::Acyclic::IPC::Parameter::Parameters parameters_; + + /// Values for parameters. The position of a value + /// relates to the position of its parameter. + FAPI::Acyclic::IPC::Parameter::Values values_; + + protected: + + private: + /** + * @brief Copy Constructor is private, so this object cannot + * be copied. + * + */ + MethodRequestWriteRequest (const MethodRequestWriteRequest&); + + /** + * @brief Assignment operator is private, so this object cannot + * be copied. + * + */ + const MethodRequestWriteRequest& operator= (const MethodRequestWriteRequest&); + + }; /* class MethodRequestWriteRequest */ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_WRITE_REQUEST_H_ */ Added: fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestWriteResponse.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestWriteResponse.h Thu Jul 19 07:13:16 2007 @@ -0,0 +1,102 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterMethodRequestWriteResponse.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_WRITE_RESPONSE_H_ +#define _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_WRITE_RESPONSE_H_ + +#include "FAPIAIPCParameterMethodRequest.h" +#include "FAPIAIPCParameterCommunication.h" +#include "FAPIAIPCParameterParameter.h" +#include "FAPIAIPCParameterError.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + /** + * @class MethodRequestWriteResponse + * + * @brief The MethodRequestWriteResponse is the class for a write + * operation request. + * + */ + class MethodRequestWriteResponse : public FAPI::Acyclic::IPC::Parameter::MethodRequest + { + + public: + /** + * @brief Constructor of MethodRequestWriteResponse. + * + */ + MethodRequestWriteResponse (void); + + /** + * @brief Destructor of MethodRequestWriteResponse. + * + */ + virtual ~MethodRequestWriteResponse (void); + + /** + * @brief Comparison operator + * + */ + bool operator!= (const MethodRequestWriteResponse&) const; + + /** + * @brief Invoked when the MethodRequestWriteResponse is + * scheduled to run. + * + * If it returns -1 the receiving thread of this message + * must shut down. + * + */ + virtual int call (void); + + /// Information for communication purposes. + Communication communication_; + + /// Parameters which were written. + FAPI::Acyclic::IPC::Parameter::Parameters parameters_; + + /// Errors for the written parameters. If the relating error + /// is ok the value was successfully written. + FAPI::Acyclic::IPC::Parameter::Errors errors_; + + protected: + + private: + /** + * @brief Copy Constructor is private, so this object cannot + * be copied. + * + */ + MethodRequestWriteResponse (const MethodRequestWriteResponse&); + + /** + * @brief Assignment operator is private, so this object cannot + * be copied. + * + */ + const MethodRequestWriteResponse& operator= (const MethodRequestWriteResponse&); + + }; /* class MethodRequestWriteResponse */ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_WRITE_RESPONSE_H_ */ Added: fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterParameter.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterParameter.h Thu Jul 19 07:13:16 2007 @@ -0,0 +1,96 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterParameter.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_PARAMETER_PARAMETER_H_ +#define _FAPI_ACYCLIC_IPC_PARAMETER_PARAMETER_H_ + +#include /**/ +#include /**/ + + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + /** + * @class Parameter + * + * @brief The Parameter is used inside all MethodRequests. + * + */ + class Parameter + { + + public: + /** + * @brief Constructor of Parameter. + * + */ + Parameter (void); + + /** + * @brief Copy Constructor. + * + */ + Parameter (const Parameter&); + + /** + * @brief Assignment operator. + * + */ + const Parameter& operator= (const Parameter&); + + /** + * @brief Destructor of Parameter. + * + */ + virtual ~Parameter (void); + + /** + * @brief Comparison operator. + * + */ + bool operator!= (const Parameter&) const; + + // The member variables are public. Therefore there is no need + // to implement get and set methods. This class is used as a + // structure with constructor, destructor, copy constructor and + // assignement operator. + public: + /// Name of the parameter. + ACE_CString parameter_name_; + + private: + /// internal initialisation + void open (void); + + /// internal copying + void copy (const Parameter&); + + /// internal cleanup + void close (void); + + }; /* class Parameter */ + + /// This typedef is a container for Parameters. + typedef ACE_Vector Parameters; + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_PARAMETER_PARAMETER_H_ */ Added: fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterValue.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/interface/FAPIAIPCParameterValue.h Thu Jul 19 07:13:16 2007 @@ -0,0 +1,113 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterValue.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_PARAMETER_VALUE_H_ +#define _FAPI_ACYCLIC_IPC_PARAMETER_VALUE_H_ + +#include /**/ +#include /**/ + +#include + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + /** + * @class Value + * + * @brief The Value instance contains a value for a parameter. + * + */ + class Value + { + + public: + /** + * @brief Constructor of Value. + * + */ + Value (void); + + /** + * @brief Copy Constructor. + * + */ + Value (const Value&); + + /** + * @brief Assignment operator. + * + */ + const Value& operator= (const Value&); + + /** + * @brief Destructor of Value. + * + */ + virtual ~Value (void); + + /** + * @brief Comparison operator. + * + */ + bool operator!= (const Value&) const; + + // The member variables are public. Therefore there is no need + // to implement get and set methods. This class is used as a + // structure with constructor, destructor, copy constructor and + // assignement operator. + public: + + /// Datatype of the parameter. + FAPIADataType data_type_; + + /// getter for data field length in bytes + unsigned long data_len (void) const; + + /// getter for data + const void* data_value (void) const; + + /// method to set a data value + long data_value (const void* const value, unsigned long len); + + private: + /// Length of the value. + unsigned long data_len_; + + /// Pointer to the value. + void* data_value_; + + /// internal initialisation + void open (void); + + /// internal copying + void copy (const Value&); + + /// internal cleanup + void close (void); + + }; /* class Value */ + + /// This typedef is a container for Values. + typedef ACE_Vector Values; + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_PARAMETER_VALUE_H_ */ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:46:39 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:46:39 +0200 Subject: [OSADL-svn-commits] r84 - fapia-trunk/FAPIAIPCParameter/make Message-ID: <200710020946.l929kdEu021167@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:13:50 2007 New Revision: 84 Log: Added a folder remotely Added: fapia-trunk/FAPIAIPCParameter/make/ fapia-trunk/FAPIAIPCParameter/make/makeall.bat fapia-trunk/FAPIAIPCParameter/make/makefile Added: fapia-trunk/FAPIAIPCParameter/make/makeall.bat ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/make/makeall.bat Thu Jul 19 07:13:50 2007 @@ -0,0 +1,2 @@ +set ARP_Tools=%cd%\..\..\..\..\DevTools_vob\ARP-Tools +ccperl %arp_tools%\mk.pl %* \ No newline at end of file Added: fapia-trunk/FAPIAIPCParameter/make/makefile ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/make/makefile Thu Jul 19 07:13:50 2007 @@ -0,0 +1,27 @@ +MODULE=FAPIAIPCParameter + +TYPES:= VC8_STATIC Automake + +NMAKE_STATIC_CFG="Static_Multi_Unicode_Debug_StaticRTL" "Static_Multi_Unicode_Release_StaticRTL" +NMAKE_DLL_CFG= +GNU_LINUX_CFG = "Debug" "Release" + +MPC_DIRS := $(VIEW_ROOT)/IOFramework_vob/FAPIA/make/MPC/config $(VIEW_ROOT)/ACE_Wrappers_vob/ACE_wrappers/make/MPC/config + +ALL: MPC BUILD + +BUILD: BUILD_ALL + +CLEAN: CLEAN_BUILD CLEAN_MPC + +REALCLEAN: REALCLEAN_BUILD CLEAN_MPC + +EXPORT: EXPORT_ALL + +%include <.homag_make_rules> +%include <.homag_mpc_make_rules> +%include <.homag_build_make_rules> +%include <.homag_export_make_rules> + +MAKE_RUNDIR:= os9/run +AUTOMAKE_RUNDIR:= i686_linux32 From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:46:42 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:46:42 +0200 Subject: [OSADL-svn-commits] r85 - fapia-trunk/FAPIAIPCParameter/make/MPC Message-ID: <200710020946.l929kg2p021194@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:14:19 2007 New Revision: 85 Log: Added a folder remotely Added: fapia-trunk/FAPIAIPCParameter/make/MPC/ fapia-trunk/FAPIAIPCParameter/make/MPC/FAPIAIPCParameter.mpc fapia-trunk/FAPIAIPCParameter/make/MPC/FAPIAIPCParameter.mwc Added: fapia-trunk/FAPIAIPCParameter/make/MPC/FAPIAIPCParameter.mpc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/make/MPC/FAPIAIPCParameter.mpc Thu Jul 19 07:14:19 2007 @@ -0,0 +1,3 @@ + +project : FAPIAIPCParametersource { +} \ No newline at end of file Added: fapia-trunk/FAPIAIPCParameter/make/MPC/FAPIAIPCParameter.mwc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/make/MPC/FAPIAIPCParameter.mwc Thu Jul 19 07:14:19 2007 @@ -0,0 +1,3 @@ +workspace { + FAPIAIPCParameter.mpc +} \ No newline at end of file From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:46:44 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:46:44 +0200 Subject: [OSADL-svn-commits] r86 - fapia-trunk/FAPIAIPCParameter/source Message-ID: <200710020946.l929kiRl021216@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:15:27 2007 New Revision: 86 Log: Added a folder remotely Added: fapia-trunk/FAPIAIPCParameter/source/ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterCommunication.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterError.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterImplementation.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterInfo.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterInit.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMarshalling.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMarshalling.h fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequest.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestFinish.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestFinish.h fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestInfoRequest.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestInfoResponse.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestReadRequest.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestReadResponse.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestWriteRequest.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestWriteResponse.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterParameter.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverAcceptor.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverAcceptor.h fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverService.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverService.h fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverTask.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverTask.h fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterSenderService.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterSenderService.h fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterSocket.h fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterStreaming.cpp fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterStreaming.h fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterValue.cpp Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterCommunication.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterCommunication.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,105 @@ +// $Id$ + + +#include "FAPIAIPCParameterCommunication.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + +/*---------------------------------------------------------------------------*/ + + Communication::Communication (void) + { + open (); + } + +/*---------------------------------------------------------------------------*/ + + Communication::Communication ( \ + const Communication& communication) + { + open (); + copy (communication); + } + +/*---------------------------------------------------------------------------*/ + + const Communication& Communication::operator= ( + const Communication& communication) + { + if (this != &communication) + { + copy (communication); + } + + return *this; + } + +/*---------------------------------------------------------------------------*/ + + Communication::~Communication (void) + { + close (); + } + +/*---------------------------------------------------------------------------*/ + + bool Communication::operator!= (const Communication& comm) + const + { + return ((this->send_reply_ != comm.send_reply_) || + (this->transaction_id_ != comm.transaction_id_) || + (this->logical_object_name_.compare ( + comm.logical_object_name_) != 0) || + (this->source_physical_object_name_.compare ( + comm.source_physical_object_name_) != 0) || + (this->communication_error_ != + comm.communication_error_) + ); + } + +/*---------------------------------------------------------------------------*/ + + void Communication::open (void) + { + this->transaction_id_ = 0; + this->logical_object_name_ = ACE_CString (); + this->source_physical_object_name_ = ACE_CString(); + this->send_reply_ = false; + this->communication_error_ = Error (); + } + +/*---------------------------------------------------------------------------*/ + + void Communication::copy (const Communication& communication) + { + this->transaction_id_ = communication.transaction_id_; + this->logical_object_name_ = + communication.logical_object_name_; + this->source_physical_object_name_ = + communication.source_physical_object_name_; + this->send_reply_ = communication.send_reply_; + this->communication_error_ = + communication.communication_error_; + } + +/*---------------------------------------------------------------------------*/ + + void Communication::close (void) + { + this->transaction_id_ = 0; + this->send_reply_ = false; + } + +/*---------------------------------------------------------------------------*/ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterError.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterError.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,86 @@ +// $Id$ + + +#include "FAPIAIPCParameterError.h" +#include /**/ + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + +/*---------------------------------------------------------------------------*/ + + Error::Error (void) + { + open (); + } + +/*---------------------------------------------------------------------------*/ + + Error::Error (const Error& error) + { + open (); + copy (error); + } + +/*---------------------------------------------------------------------------*/ + + const Error& Error::operator= (const Error& error) + { + if (this != &error) + { + copy (error); + } + + return *this; + } + +/*---------------------------------------------------------------------------*/ + + Error::~Error (void) + { + close (); + } + +/*---------------------------------------------------------------------------*/ + + bool Error::operator!= (const Error& error) const + { + return ((this->error_code_ != error.error_code_) || + (this->reason_.compare (error.reason_) != 0)); + } + +/*---------------------------------------------------------------------------*/ + + void Error::open (void) + { + this->error_code_ = FAPIA_ERROR_OK; + this->reason_ = ACE_CString(); + } + +/*---------------------------------------------------------------------------*/ + + void Error::copy (const Error& error) + { + this->error_code_ = error.error_code_; + this->reason_ = error.reason_; + } + +/*---------------------------------------------------------------------------*/ + + void Error::close (void) + { + this->error_code_ = FAPIA_ERROR_OK; + } + +/*---------------------------------------------------------------------------*/ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterImplementation.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterImplementation.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,177 @@ +// $Id$ + + +#include "FAPIAIPCParameterImplementation.h" + +#include "FAPIAIPCParameterReceiverTask.h" +#include "FAPIAIPCParameterSenderService.h" +#include "FAPIATrace.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + +/*---------------------------------------------------------------------------*/ + + ParameterImplementation::ParameterImplementation () + : recv_task_ (NULL), send_task_ (NULL) + { + } + +/*---------------------------------------------------------------------------*/ + + ParameterImplementation::~ParameterImplementation () + { + if (recv_task_ != NULL) + { + delete recv_task_; + recv_task_ = NULL; + } + + if (send_task_ != NULL) + { + delete send_task_; + send_task_ = NULL; + } + } + +/*---------------------------------------------------------------------------*/ + + int ParameterImplementation::init ( \ + const FAPI::Acyclic::IPC::Parameter::Init& init, + ACE_CString& physical_object_address, + FAPI::Acyclic::IPC::Parameter::Error& error) + { + FAPIA_TRACE; + + // check if queues are set + if ((init.receive_queue_ == NULL) || + (init.send_queue_ == NULL)) + { + error.error_code_ = FAPIA_ERROR_COMMUNICATION; + error.reason_ = + "init function lacks necessary parameters."; + FAPIA_DEBUG (LM_ERROR, error.reason_.c_str ()); + return -1; + } + + // create ReceiverService and check for errors + recv_task_ = new ReceiverTask (init.receive_queue_); + if (recv_task_ == NULL) + { + error.error_code_ = FAPIA_ERROR_COMMUNICATION; + error.reason_ = "could not initialize receiver."; + FAPIA_DEBUG (LM_ALERT, error.reason_.c_str ()); + return -1; + } + + // start receiver thread + if (recv_task_->activate () != 0) + { + error.error_code_ = FAPIA_ERROR_COMMUNICATION; + error.reason_ = "could not execute receiver thread."; + FAPIA_DEBUG (LM_ERROR, error.reason_.c_str ()); + return -1; + } + + // retrieve socket address and synchronize with acceptor + physical_object_address = recv_task_->listen_addr (); + + // create SenderService + send_task_ = new SenderService (); + if (send_task_ == NULL) + { + error.error_code_ = FAPIA_ERROR_COMMUNICATION; + error.reason_ = "could not initialize sender."; + FAPIA_DEBUG (LM_ALERT, error.reason_.c_str ()); + + FAPIA_DEBUG (LM_NOTICE, + "shutting down receiver thread"); + recv_task_->shutdown (); + recv_task_->wait (); + + return -1; + } + + // pass queues to the task + send_task_->receive_queue (init.receive_queue_); + send_task_->send_queue (init.send_queue_); + + // start sender service thread + if (send_task_->activate () != 0) + { + error.error_code_ = FAPIA_ERROR_COMMUNICATION; + error.reason_ = "could not execute sender thread."; + FAPIA_DEBUG (LM_ERROR, error.reason_.c_str ()); + + FAPIA_DEBUG (LM_NOTICE, + "shutting down receiver thread"); + recv_task_->shutdown (); + recv_task_->wait (); + + return -1; + } + + return 0; + } + +/*---------------------------------------------------------------------------*/ + + int ParameterImplementation::deinit (void) + { + FAPIA_TRACE; + + // check if queues are set + if ((send_task_ == NULL) || + (recv_task_ == NULL)) + { + FAPIA_DEBUG (LM_ERROR, + "deinit() called without calling init() before."); + return -1; + } + + // stop sender task + FAPIA_DEBUG (LM_NOTICE, "shutting down sender service."); + + send_task_->shutdown (); +// send_task_->close (); + + delete send_task_; + send_task_ = NULL; + + // stop receiver task + FAPIA_DEBUG (LM_NOTICE, "shutting down receiver service."); + + recv_task_->shutdown (); + + delete recv_task_; + recv_task_ = NULL; + + return 0; + } + +/*---------------------------------------------------------------------------*/ + + ParameterImplementation::ParameterImplementation ( \ + const ParameterImplementation&) + { + } + +/*---------------------------------------------------------------------------*/ + const ParameterImplementation& ParameterImplementation:: \ + operator= (const ParameterImplementation&) + { + return *this; + } + +/*---------------------------------------------------------------------------*/ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterInfo.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterInfo.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,204 @@ +// $Id$ + + +#include "FAPIAIPCParameterInfo.h" +#include "FAPIATrace.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + +/*---------------------------------------------------------------------------*/ + + Info::Info (void) + { + open (); + } + +/*---------------------------------------------------------------------------*/ + + Info::Info (const Info& info) + { + open (); + copy (info); + } + +/*---------------------------------------------------------------------------*/ + + const Info& Info::operator= (const Info& info) + { + if (this != &info) + { + close (); + copy (info); + } + + return *this; + } + +/*---------------------------------------------------------------------------*/ + + Info::~Info (void) + { + close (); + } + +/*---------------------------------------------------------------------------*/ + + bool Info::operator!= (const Info& info) const + { + + if (this->min_value_) + { + if (info.min_value_ == 0) + { + return false; + } + + if (ACE_OS::memcmp ( + this->min_value_, + info.min_value_, + info.data_len_) == 0) + { + return false; + } + } + else if (info.min_value_) + { + return false; + } + + if (this->max_value_) + { + if (info.max_value_ == 0) + { + return false; + } + + if (ACE_OS::memcmp ( + this->max_value_, + info.max_value_, + info.data_len_) == 0) + { + return false; + } + } + else if (info.max_value_) + { + return false; + } + + return ((this->data_type_ != info.data_type_) || + (this->data_len_ != info.data_len_) || + (this->access_rights_ != info.access_rights_) || + (this->unit_.compare (info.unit_) != 0) || + (this->exponent_ != info.exponent_) || + (this->factor_ != info.factor_) || + (this->description_.compare (info.description_) != 0) + ); + } + +/*---------------------------------------------------------------------------*/ + + void Info::open (void) + { + this->data_type_ = FAPIA_DATA_TYPE_UNS08; + this->data_len_ = 0; + this->min_value_ = 0; + this->max_value_ = 0; + this->access_rights_ = FAPIA_ACCESS_RIGHTS_READWRITE; + this->unit_ = ACE_CString (); + this->exponent_ = 0; + this->factor_ = 1; + this->description_ = ACE_CString (); + } + +/*---------------------------------------------------------------------------*/ + + void Info::copy (const Info& info) + { + this->data_len_ = info.data_len_; + this->data_type_ = info.data_type_; + + if (info.min_value_) + { + // allocate memory for the min_value. + ACE_NEW_NORETURN (this->min_value_, char[info.data_len_]); + if (this->min_value_ == NULL) + { + FAPIA_DEBUG (LM_CRITICAL, + "insufficient memory for heap allocation"); + return; + } + + // copy content + ACE_OS::memcpy (this->min_value_, + info.min_value_, + info.data_len_); + } + else + { + this->min_value_ = 0; + } + + if (info.max_value_) + { + // allocate memory for the max_value. + ACE_NEW_NORETURN (this->max_value_, char[info.data_len_]); + if (this->max_value_ == NULL) + { + FAPIA_DEBUG (LM_CRITICAL, + "insufficient memory for heap allocation"); + return; + } + + // copy content + ACE_OS::memcpy (this->max_value_, + info.max_value_, + info.data_len_); + } + else + { + this->max_value_ = 0; + } + + this->access_rights_ = info.access_rights_; + this->unit_ = info.unit_; + this->exponent_ = info.exponent_; + this->factor_ = info.factor_; + this->description_ = info.description_; + } + +/*---------------------------------------------------------------------------*/ + + void Info::close (void) + { + this->data_type_ = FAPIA_DATA_TYPE_UNS08; + this->data_len_ = 0; + + if (this->min_value_) + { + delete [] (char*) this->min_value_; + this->min_value_ = 0; + } + if (this->max_value_) + { + delete [] (char*) this->max_value_; + this->max_value_ = 0; + } + this->access_rights_ = FAPIA_ACCESS_RIGHTS_READWRITE; + this->exponent_ = 0; + this->factor_ = 1; + } + +/*---------------------------------------------------------------------------*/ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterInit.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterInit.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,80 @@ +// $Id$ + + +#include "FAPIAIPCParameterInit.h" + +#include + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + +/*---------------------------------------------------------------------------*/ + + Init::Init (void) + { + open (); + } + +/*---------------------------------------------------------------------------*/ + + Init::Init (const Init& init) + { + open (); + copy (init); + } + +/*---------------------------------------------------------------------------*/ + + const Init& Init::operator= (const Init& init) + { + if (this != &init) + { + copy (init); + } + + return *this; + } + +/*---------------------------------------------------------------------------*/ + + Init::~Init (void) + { + close (); + } + +/*---------------------------------------------------------------------------*/ + + void Init::open (void) + { + this->send_queue_ = NULL; + this->receive_queue_ = NULL; + } + +/*---------------------------------------------------------------------------*/ + + void Init::copy (const Init& init) + { + this->send_queue_ = init.send_queue_; + this->receive_queue_ = init.receive_queue_; + } + +/*---------------------------------------------------------------------------*/ + + void Init::close (void) + { + this->send_queue_ = NULL; + this->receive_queue_ = NULL; + } + +/*---------------------------------------------------------------------------*/ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMarshalling.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMarshalling.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,879 @@ +// $Id$ + +#include "FAPIAIPCParameterMarshalling.h" + +#include + +/*---------------------------------------------------------------------------*/ + +unsigned long operator+= (unsigned long& ul, + const FAPI::Acyclic::IPC::Parameter::Parameter &p) + { + return ul += ACE_CDR::LONG_SIZE + p.parameter_name_.length () + 1; + } + +/*---------------------------------------------------------------------------*/ + +int operator<< (ACE_OutputCDR &cdr, + const FAPI::Acyclic::IPC::Parameter::Parameter ¶meter) +{ + // insert the fields into the output CDR stream + return cdr.write_string (parameter.parameter_name_); +} + +/*---------------------------------------------------------------------------*/ + +int operator>> (ACE_InputCDR &cdr, + FAPI::Acyclic::IPC::Parameter::Parameter ¶meter) +{ + // extract all fields from the input CDR stream into . + return cdr.read_string (parameter.parameter_name_); +} + +/*---------------------------------------------------------------------------*/ + +unsigned long operator+= (unsigned long& ul, + const FAPI::Acyclic::IPC::Parameter::Parameters &p) +{ + ul += ACE_CDR::LONG_SIZE; + + for (size_t i = 0; i < p.size (); i++) + { + ul += p[i]; + } + + return ul += ACE_CDR::MAX_ALIGNMENT; +} + +/*---------------------------------------------------------------------------*/ + +int operator<< (ACE_OutputCDR &cdr, + const FAPI::Acyclic::IPC::Parameter::Parameters ¶meters) +{ + ACE_CDR::ULong parameter_count = parameters.size (); + + // insert all elements of the parameter vector into the output CDR stream + cdr << parameter_count; + + for (size_t parameter_index = 0; + parameter_index < parameter_count; + parameter_index++) + { + cdr << parameters[parameter_index]; + } + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +int operator>> (ACE_InputCDR &cdr, + FAPI::Acyclic::IPC::Parameter::Parameters ¶meters) +{ + ACE_CDR::ULong parameter_count; + + // extract all elements from the input CDR stream to the parameter vector + if (cdr >> parameter_count) + { + FAPI::Acyclic::IPC::Parameter::Parameter parameter; + for (size_t parameter_index = 0; + parameter_index < parameter_count; + parameter_index++) + { + if (cdr >> parameter) + { + parameters.push_back (parameter); + } + else break; + } + } + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +unsigned long operator+= (unsigned long &ul, + const FAPI::Acyclic::IPC::Parameter::Communication &c) +{ + // transaction id + boolean + strlen field + ul += c.communication_error_; + return ul += ACE_CDR::LONG_SIZE * 4 + + c.logical_object_name_.length () + 1 + //+ string + c.source_physical_object_name_.length () + 1 + //+ string + ACE_CDR::MAX_ALIGNMENT; +} + +/*---------------------------------------------------------------------------*/ + +int operator<< (ACE_OutputCDR &cdr, + const FAPI::Acyclic::IPC::Parameter::Communication &comm) +{ + // insert the fields into the output CDR stream + + cdr << ACE_CDR::ULong (comm.transaction_id_); + + ACE_OutputCDR::from_boolean send_reply_fb(comm.send_reply_); + cdr << send_reply_fb; + + cdr.write_string (comm.logical_object_name_); + cdr.write_string (comm.source_physical_object_name_); + + cdr << comm.communication_error_; + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +int operator>> (ACE_InputCDR &cdr, + FAPI::Acyclic::IPC::Parameter::Communication &comm) +{ + // extract all fields from the input CDR stream into . + + ACE_CDR::ULong transaction_id; + ACE_CDR::Boolean send_reply; + ACE_InputCDR::to_boolean send_reply_tb(send_reply); + + if ((cdr >> transaction_id) && (cdr >> send_reply_tb) && + (cdr.read_string (comm.logical_object_name_)) && + (cdr.read_string (comm.source_physical_object_name_)) && + (cdr >> comm.communication_error_)) + { + comm.transaction_id_ = transaction_id; + comm.send_reply_ = (send_reply ? true : false); + } + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +unsigned long operator+= (unsigned long &ul, + const FAPI::Acyclic::IPC::Parameter::Value &v) +{ + return ul += ACE_CDR::LONG_SIZE * 2 + + v.data_len () + 1 + + ACE_CDR::OCTET_ALIGN; +} + +/*---------------------------------------------------------------------------*/ + + +int operator<< (ACE_OutputCDR &cdr, + const FAPI::Acyclic::IPC::Parameter::Value &value) +{ + size_t data_len = value.data_len (); + + // insert the fields into the output CDR stream + cdr << ACE_CDR::ULong (value.data_type_); + cdr << ACE_CDR::ULong (data_len); + + cdr.write_octet_array (ACE_static_cast (const ACE_CDR::Octet*, + value.data_value () ), + data_len); + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +int operator>> (ACE_InputCDR &cdr, + FAPI::Acyclic::IPC::Parameter::Value &value) +{ + ACE_CDR::ULong data_type; + ACE_CDR::ULong data_len; + ACE_CDR::Octet* data_value; + + // extract all fields from the input CDR stream into . + if ((cdr >> data_type) && + (cdr >> data_len) ) + { + ACE_NEW_RETURN (data_value, ACE_CDR::Octet[data_len], 0); + + if (cdr.read_octet_array (data_value, data_len)) + { + value.data_type_ = ACE_static_cast (FAPIADataType, data_type); + value.data_value (data_value, data_len); + } + + delete[] data_value; + } + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +unsigned long operator+= (unsigned long &ul, + const FAPI::Acyclic::IPC::Parameter::Values &v) +{ + ul += ACE_CDR::LONG_SIZE; + + for (size_t i = 0; i < v.size (); i++) + { + ul += v[i]; + } + + return ul += ACE_CDR::MAX_ALIGNMENT; +} + +/*---------------------------------------------------------------------------*/ + +int operator<< (ACE_OutputCDR &cdr, + const FAPI::Acyclic::IPC::Parameter::Values &values) +{ + ACE_CDR::ULong value_count = values.size (); + + // insert all elements of the value vector into the output CDR stream + cdr << value_count; + + for (size_t value_index = 0; + value_index < value_count; + value_index++) + { + cdr << values[value_index]; + } + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +int operator>> (ACE_InputCDR &cdr, + FAPI::Acyclic::IPC::Parameter::Values &values) +{ + ACE_CDR::ULong value_count; + + // extract all elements from the input CDR stream to the value vector + if (cdr >> value_count) + { + FAPI::Acyclic::IPC::Parameter::Value value; + for (size_t value_index = 0; + value_index < value_count; + value_index++) + { + if (cdr >> value) + { + values.push_back (value); + } + else break; + } + } + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +unsigned long operator+= (unsigned long &ul, + const FAPI::Acyclic::IPC::Parameter::Info &v) +{ + return ul += ACE_CDR::LONG_SIZE + + ACE_CDR::LONG_SIZE + + v.data_len_ + 1 + ACE_CDR::OCTET_ALIGN + + v.data_len_ + 1 + ACE_CDR::OCTET_ALIGN + + ACE_CDR::LONG_SIZE + + ACE_CDR::LONG_SIZE + v.unit_.length () + 1 + + ACE_CDR::LONG_SIZE + + ACE_CDR::LONG_SIZE + + ACE_CDR::LONG_SIZE + v.description_.length () + 1 + + ACE_CDR::MAX_ALIGNMENT; +} + +/*---------------------------------------------------------------------------*/ + + +int operator<< (ACE_OutputCDR &cdr, + const FAPI::Acyclic::IPC::Parameter::Info &info) +{ + // insert the fields into the output CDR stream + cdr << ACE_CDR::ULong (info.data_type_); + cdr << ACE_CDR::ULong (info.data_len_); + if (info.min_value_) + { + cdr << ACE_CDR::ULong (info.data_len_); + cdr.write_octet_array (ACE_static_cast (const ACE_CDR::Octet*, + info.min_value_), + info.data_len_); + } + else + { + cdr << ACE_CDR::ULong (0); + } + if (info.max_value_) + { + cdr << ACE_CDR::ULong (info.data_len_); + cdr.write_octet_array (ACE_static_cast (const ACE_CDR::Octet*, + info.max_value_), + info.data_len_); + } + else + { + cdr << ACE_CDR::ULong (0); + } + cdr << ACE_CDR::ULong (info.access_rights_); + cdr.write_string (info.unit_); + cdr << ACE_CDR::Long (info.exponent_); + cdr << ACE_CDR::Long (info.factor_); + cdr.write_string (info.description_); + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +int operator>> (ACE_InputCDR &cdr, + FAPI::Acyclic::IPC::Parameter::Info &info) +{ + ACE_CDR::ULong data_type; + ACE_CDR::ULong data_len; + ACE_CDR::ULong min_value_len; + ACE_CDR::ULong max_value_len; + ACE_CDR::Octet* min_value = 0; + ACE_CDR::Octet* max_value = 0; + ACE_CDR::ULong access_rights; + ACE_CDR::Long exponent; + ACE_CDR::Long factor; + + bool data_read = true; + + // extract all fields from the input CDR stream into . + cdr >> data_type; + cdr >> data_len; + cdr >> min_value_len; + if (min_value_len > 0) + { + ACE_NEW_RETURN (min_value, ACE_CDR::Octet[min_value_len], 0); + + if (!cdr.read_octet_array (min_value, min_value_len)) + { + data_read = false; + } + if (min_value_len != data_len) + { + data_read = false; + } + + ACE_NEW_RETURN (info.min_value_, char [min_value_len], 0); + ACE_OS::memcpy (info.min_value_, min_value, min_value_len); + + delete[] min_value; + min_value = 0; + } + else + { + info.min_value_ = 0; + } + cdr >> max_value_len; + if (max_value_len > 0) + { + ACE_NEW_RETURN (max_value, ACE_CDR::Octet[max_value_len], 0); + + if (!cdr.read_octet_array (max_value, max_value_len)) + { + data_read = false; + } + if (max_value_len != data_len) + { + data_read = false; + } + + ACE_NEW_RETURN (info.max_value_, char [max_value_len], 0); + ACE_OS::memcpy (info.max_value_, max_value, max_value_len); + + delete[] max_value; + max_value = 0; + } + else + { + info.max_value_ = 0; + } + cdr >> access_rights; + cdr.read_string (info.unit_); + cdr >> exponent; + cdr >> factor; + cdr.read_string (info.description_); + + if (!data_read) + { + return 0; + } + + info.data_type_ = ACE_static_cast (FAPIADataType, data_type); + info.data_len_ = data_len; + info.access_rights_ = ACE_static_cast (FAPIAAccessRights, access_rights); + info.exponent_ = exponent; + info.factor_ = factor; + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +unsigned long operator+= (unsigned long &ul, + const FAPI::Acyclic::IPC::Parameter::Infos &v) +{ + ul += ACE_CDR::LONG_SIZE; + + for (size_t i = 0; i < v.size (); i++) + { + ul += v[i]; + } + + return ul += ACE_CDR::MAX_ALIGNMENT; +} + +/*---------------------------------------------------------------------------*/ + +int operator<< (ACE_OutputCDR &cdr, + const FAPI::Acyclic::IPC::Parameter::Infos &infos) +{ + ACE_CDR::ULong info_count = infos.size (); + + // insert all elements of the info vector into the output CDR stream + cdr << info_count; + + for (size_t info_index = 0; + info_index < info_count; + info_index++) + { + cdr << infos[info_index]; + } + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +int operator>> (ACE_InputCDR &cdr, + FAPI::Acyclic::IPC::Parameter::Infos &infos) +{ + ACE_CDR::ULong info_count; + + // extract all elements from the input CDR stream to the info vector + if (cdr >> info_count) + { + FAPI::Acyclic::IPC::Parameter::Info info; + for (size_t info_index = 0; + info_index < info_count; + info_index++) + { + if (cdr >> info) + { + infos.push_back (info); + } + else break; + } + } + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +unsigned long operator+= (unsigned long &ul, + const FAPI::Acyclic::IPC::Parameter::Error &e) +{ + return ul += ACE_CDR::LONG_SIZE + + ACE_CDR::LONG_SIZE + e.reason_.length () +1; +} + +/*---------------------------------------------------------------------------*/ + +int operator<< (ACE_OutputCDR &cdr, + const FAPI::Acyclic::IPC::Parameter::Error &error) +{ + // insert the fields into the output CDR stream + + cdr << ACE_CDR::ULong (error.error_code_); + cdr.write_string (error.reason_); + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +int operator>> (ACE_InputCDR &cdr, + FAPI::Acyclic::IPC::Parameter::Error &error) +{ + ACE_CDR::ULong error_code; + + // extract all fields from the input CDR stream into . + if ((cdr >> error_code) && (cdr.read_string (error.reason_))) + { + error.error_code_ = ACE_static_cast (FAPIAErrorCode, error_code); + } + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +unsigned long operator+= (unsigned long &ul, + const FAPI::Acyclic::IPC::Parameter::Errors &e) +{ + ul += ACE_CDR::LONG_SIZE; + + for (size_t i = 0; i < e.size (); i++) + { + ul += e[i]; + } + + return ul += ACE_CDR::MAX_ALIGNMENT; +} + +/*---------------------------------------------------------------------------*/ + +int operator<< (ACE_OutputCDR &cdr, + const FAPI::Acyclic::IPC::Parameter::Errors &errors) +{ + ACE_CDR::ULong error_count = errors.size (); + + // insert all elements of the error vector into the output CDR stream + cdr << error_count; + + for (size_t error_index = 0; + error_index < error_count; + error_index++) + { + cdr << errors[error_index]; + } + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +int operator>> (ACE_InputCDR &cdr, + FAPI::Acyclic::IPC::Parameter::Errors &errors) +{ + ACE_CDR::ULong error_count; + + // extract all elements from the input CDR stream to the error vector + if (cdr >> error_count) + { + FAPI::Acyclic::IPC::Parameter::Error error; + for (size_t error_index = 0; + error_index < error_count; + error_index++) + { + if (cdr >> error) + { + errors.push_back (error); + } + else break; + } + } + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +unsigned long operator+= (unsigned long &ul, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestReadRequest &rr) +{ + ul += rr.parameters_; + ul += rr.communication_; + return ul += ACE_CDR::LONG_SIZE + + ACE_CDR::LONG_SIZE + rr.destination_physical_object_address_.length () + +1; +} + +/*---------------------------------------------------------------------------*/ + +int operator<< (ACE_OutputCDR &cdr, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestReadRequest &read_request) +{ + // insert the fields into the output CDR stream + + cdr.write_string (read_request.destination_physical_object_address_); + cdr << ACE_CDR::ULong (read_request.priority ()); + cdr << read_request.communication_; + cdr << read_request.parameters_; + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +int operator>> (ACE_InputCDR &cdr, + FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestReadRequest &read_request) +{ + ACE_CDR::ULong priority; + + // extract all fields from the input CDR stream into . + if ((cdr.read_string (read_request.destination_physical_object_address_)) && + (cdr >> priority) && (cdr >> read_request.communication_) && + (cdr >> read_request.parameters_)) + { + read_request.priority (priority); + } + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +unsigned long operator+= (unsigned long &ul, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestReadResponse &rr) +{ + ul += rr.communication_; + ul += rr.parameters_; + ul += rr.values_; + ul += rr.errors_; + return ul += ACE_CDR::LONG_SIZE + + ACE_CDR::LONG_SIZE + rr.destination_physical_object_address_.length () + 1; +} + +/*---------------------------------------------------------------------------*/ + +int operator<< (ACE_OutputCDR &cdr, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestReadResponse &read_response) +{ + // insert the fields into the output CDR stream + + cdr.write_string (read_response.destination_physical_object_address_); + cdr << ACE_CDR::ULong (read_response.priority ()); + cdr << read_response.communication_; + cdr << read_response.parameters_; + cdr << read_response.values_; + cdr << read_response.errors_; + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +int operator>> (ACE_InputCDR &cdr, + FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestReadResponse &read_response) +{ + ACE_CDR::ULong priority; + + // extract all fields from the input CDR stream into . + if ((cdr.read_string (read_response.destination_physical_object_address_)) && + (cdr >> priority) && (cdr >> read_response.communication_) && + (cdr >> read_response.parameters_) && + (cdr >> read_response.values_) && + (cdr >> read_response.errors_)) + { + read_response.priority (priority); + } + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +unsigned long operator+= (unsigned long &ul, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestWriteRequest &wr) +{ + ul += wr.communication_; + ul += wr.parameters_; + ul += wr.values_; + return ul += ACE_CDR::LONG_SIZE + + ACE_CDR::LONG_SIZE + + wr.destination_physical_object_address_.length () + 1; +} + +/*---------------------------------------------------------------------------*/ + +int operator<< (ACE_OutputCDR &cdr, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestWriteRequest &write_request) +{ + // insert the fields into the output CDR stream + + cdr.write_string (write_request.destination_physical_object_address_); + cdr << ACE_CDR::ULong (write_request.priority ()); + cdr << write_request.communication_; + cdr << write_request.parameters_; + cdr << write_request.values_; + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +int operator>> (ACE_InputCDR &cdr, + FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestWriteRequest &write_request) +{ + ACE_CDR::ULong priority; + + // extract all fields from the input CDR stream into . + if ((cdr.read_string (write_request.destination_physical_object_address_)) && + (cdr >> priority) && (cdr >> write_request.communication_) && + (cdr >> write_request.parameters_) && + (cdr >> write_request.values_)) + { + write_request.priority (priority); + } + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +unsigned long operator+= (unsigned long& ul, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestWriteResponse &wr) +{ + ul += wr.communication_; + ul += wr.parameters_; + ul += wr.errors_; + return ul += ACE_CDR::LONG_SIZE + + ACE_CDR::LONG_SIZE + + wr.destination_physical_object_address_.length () + 1; +} + +/*---------------------------------------------------------------------------*/ + +int operator<< (ACE_OutputCDR &cdr, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestWriteResponse &write_response) +{ + // insert the fields into the output CDR stream + + cdr.write_string (write_response.destination_physical_object_address_); + cdr << ACE_CDR::ULong (write_response.priority ()); + cdr << write_response.communication_; + cdr << write_response.parameters_; + cdr << write_response.errors_; + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +int operator>> (ACE_InputCDR &cdr, + FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestWriteResponse &write_response) +{ + ACE_CDR::ULong priority; + + // extract all fields from the input CDR stream into . + if ((cdr.read_string (write_response.destination_physical_object_address_)) + && (cdr >> priority) && + (cdr >> write_response.communication_) && + (cdr >> write_response.parameters_) && + (cdr >> write_response.errors_)) + { + write_response.priority (priority); + } + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +unsigned long operator+= (unsigned long &ul, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestInfoRequest &wr) +{ + ul += wr.communication_; + ul += wr.parameters_; + return ul += ACE_CDR::LONG_SIZE + + ACE_CDR::LONG_SIZE + + wr.destination_physical_object_address_.length () + 1; +} + +/*---------------------------------------------------------------------------*/ + +int operator<< (ACE_OutputCDR &cdr, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestInfoRequest &info_request) +{ + // insert the fields into the output CDR stream + + cdr.write_string (info_request.destination_physical_object_address_); + cdr << ACE_CDR::ULong (info_request.priority ()); + cdr << info_request.communication_; + cdr << info_request.parameters_; + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +int operator>> (ACE_InputCDR &cdr, + FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestInfoRequest &info_request) +{ + ACE_CDR::ULong priority; + + // extract all fields from the input CDR stream into . + if ((cdr.read_string (info_request.destination_physical_object_address_)) && + (cdr >> priority) && (cdr >> info_request.communication_) && + (cdr >> info_request.parameters_)) + { + info_request.priority (priority); + } + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +unsigned long operator+= (unsigned long& ul, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestInfoResponse &wr) +{ + ul += wr.communication_; + ul += wr.parameters_; + ul += wr.infos_; + ul += wr.errors_; + return ul += ACE_CDR::LONG_SIZE + + ACE_CDR::LONG_SIZE + + wr.destination_physical_object_address_.length () + 1; +} + +/*---------------------------------------------------------------------------*/ + +int operator<< (ACE_OutputCDR &cdr, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestInfoResponse &info_response) +{ + // insert the fields into the output CDR stream + + cdr.write_string (info_response.destination_physical_object_address_); + cdr << ACE_CDR::ULong (info_response.priority ()); + cdr << info_response.communication_; + cdr << info_response.parameters_; + cdr << info_response.infos_; + cdr << info_response.errors_; + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ + +int operator>> (ACE_InputCDR &cdr, + FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestInfoResponse &info_response) +{ + ACE_CDR::ULong priority; + + // extract all fields from the input CDR stream into . + if ((cdr.read_string (info_response.destination_physical_object_address_)) + && (cdr >> priority) && + (cdr >> info_response.communication_) && + (cdr >> info_response.parameters_) && + (cdr >> info_response.infos_) && + (cdr >> info_response.errors_)) + { + info_response.priority (priority); + } + + return cdr.good_bit (); +} + +/*---------------------------------------------------------------------------*/ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMarshalling.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMarshalling.h Thu Jul 19 07:15:27 2007 @@ -0,0 +1,376 @@ +/* -*- C -*- */ + +//============================================================================= +/** + * @file FAPIAMarshalling.h + * + * $Id$ + * + * @author Friedhelm Wolf + */ +//============================================================================= + + +#ifndef _FAPI_ACYCLIC_PARAMETER_MARSHALLING_H_ +#define _FAPI_ACYCLIC_PARAMETER_MARSHALLING_H_ + + +#include +#include +#include +#include +#include + +#include \ + +#include \ + +#include \ + +#include \ + + +#include \ + +#include \ + + +// forward declarations + +class ACE_OutputCDR; +class ACE_InputCDR; + +// size of an internal FAPIA socket data header +#define FAPIA_HEADER_SIZE 12 + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + /** + * @brief existing types of method requests + */ + enum MethodRequestType + { + FAPIA_UNKNOWN_REQUEST =0, + FAPIA_READ_REQUEST = 1, + FAPIA_READ_RESPONSE = 2, + FAPIA_WRITE_REQUEST = 3, + FAPIA_WRITE_RESPONSE = 4, + FAPIA_INFO_REQUEST = 5, + FAPIA_INFO_RESPONSE = 6 + }; + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +/** + * @brief evaluates the size of the content of a Parameter class + */ +unsigned long operator+= (unsigned long&, + const FAPI::Acyclic::IPC::Parameter::Parameter &); + +/** + * @brief ACE CDR extraction operator for the Parameter class + */ +int operator<< (ACE_OutputCDR &, + const FAPI::Acyclic::IPC::Parameter::Parameter &); + +/** + * @brief ACE CDR insertion operator for the Parameter class + */ +int operator>> (ACE_InputCDR &, + FAPI::Acyclic::IPC::Parameter::Parameter &); + + +/** + * @brief evaluates the size of the content of a Parameters vector + */ +unsigned long operator+= (unsigned long&, + const FAPI::Acyclic::IPC::Parameter::Parameters &); + +/** + * @brief ACE CDR extraction operator for the Parameters vector + */ +int operator<< (ACE_OutputCDR &, + const FAPI::Acyclic::IPC::Parameter::Parameters &); + +/** + * @brief ACE CDR insertion operator for the Parameters vector + */ +int operator>> (ACE_InputCDR &, + FAPI::Acyclic::IPC::Parameter::Parameters &); + + +/** + * @brief evaluates the size of the content of a Communication class + */ +unsigned long operator+= (unsigned long&, + const FAPI::Acyclic::IPC::Parameter::Communication &); + +/** + * @brief ACE CDR extraction operator for the Communication class + */ +int operator<< (ACE_OutputCDR &, + const FAPI::Acyclic::IPC::Parameter::Communication &); + +/** + * @brief ACE CDR insertion operator for the Communication class + */ +int operator>> (ACE_InputCDR &, + FAPI::Acyclic::IPC::Parameter::Communication &); + + +/** + * @brief evaluates the size of the content of a Value class + */ +unsigned long operator+= (unsigned long&, + const FAPI::Acyclic::IPC::Parameter::Value &); + +/** + * @brief ACE CDR extraction operator for the Value class + */ +int operator<< (ACE_OutputCDR &, + const FAPI::Acyclic::IPC::Parameter::Value &); + +/** + * @brief ACE CDR insertion operator for the Value class + */ +int operator>> (ACE_InputCDR &, + FAPI::Acyclic::IPC::Parameter::Value &); + + +/** + * @brief evaluates the size of the content of a Values vector + */ +unsigned long operator+= (unsigned long&, + const FAPI::Acyclic::IPC::Parameter::Values &); + +/** + * @brief ACE CDR extraction operator for the Value class + */ +int operator<< (ACE_OutputCDR &, + const FAPI::Acyclic::IPC::Parameter::Values &); + +/** + * @brief ACE CDR insertion operator for the Value class + */ +int operator>> (ACE_InputCDR &, + FAPI::Acyclic::IPC::Parameter::Values &); + + +/** + * @brief evaluates the size of the content of a Info class + */ +unsigned long operator+= (unsigned long&, + const FAPI::Acyclic::IPC::Parameter::Info &); + +/** + * @brief ACE CDR extraction operator for the Info class + */ +int operator<< (ACE_OutputCDR &, + const FAPI::Acyclic::IPC::Parameter::Info &); + +/** + * @brief ACE CDR insertion operator for the Info class + */ +int operator>> (ACE_InputCDR &, + FAPI::Acyclic::IPC::Parameter::Info &); + + +/** + * @brief evaluates the size of the content of a Infos vector + */ +unsigned long operator+= (unsigned long&, + const FAPI::Acyclic::IPC::Parameter::Infos &); + +/** + * @brief ACE CDR extraction operator for the Info class + */ +int operator<< (ACE_OutputCDR &, + const FAPI::Acyclic::IPC::Parameter::Infos &); + +/** + * @brief ACE CDR insertion operator for the Info class + */ +int operator>> (ACE_InputCDR &, + FAPI::Acyclic::IPC::Parameter::Infos &); + + +/** + * @brief evaluates the size of the content of a Error class + */ +unsigned long operator+= (unsigned long&, + const FAPI::Acyclic::IPC::Parameter::Error &); + +/** + * @brief ACE CDR extraction operator for the Error class + */ +int operator<< (ACE_OutputCDR &, + const FAPI::Acyclic::IPC::Parameter::Error &); + +/** + * @brief ACE CDR insertion operator for the Error class + */ +int operator>> (ACE_InputCDR &, + FAPI::Acyclic::IPC::Parameter::Error &); + + +/** + * @brief evaluates the size of the content of a Errors vector + */ +unsigned long operator+= (unsigned long&, + const FAPI::Acyclic::IPC::Parameter::Errors &); + +/** + * @brief ACE CDR extraction operator for the Error class + */ +int operator<< (ACE_OutputCDR &, + const FAPI::Acyclic::IPC::Parameter::Errors &); + +/** + * @brief ACE CDR insertion operator for the Error class + */ +int operator>> (ACE_InputCDR &, + FAPI::Acyclic::IPC::Parameter::Errors &); + + +/** + * @brief evaluates the size of the content of a MethodRequestReadRequest + * class + */ +unsigned long operator+= (unsigned long&, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestReadRequest &); + +/** + * @brief ACE CDR extraction operator for the MethodRequestReadRequest class + */ +int operator<< (ACE_OutputCDR &, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestReadRequest &); + +/** + * @brief ACE CDR insertion operator for the MethodRequestReadRequest class + */ +int operator>> (ACE_InputCDR &, + FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestReadRequest &); + + +/** + * @brief evaluates the size of the content of a MethodRequestReadResponse + * class + */ +unsigned long operator+= (unsigned long&, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestReadResponse &); + +/** + * @brief ACE CDR extraction operator for the MethodRequestReadResponse class + */ +int operator<< (ACE_OutputCDR &, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestReadResponse &); + +/** + * @brief ACE CDR insertion operator for the MethodRequestReadResponse class + */ +int operator>> (ACE_InputCDR &, + FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestReadResponse &); + + +/** + * @brief evaluates the size of the content of a MethodRequestWriteRequest + * class + */ +unsigned long operator+= (unsigned long&, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestWriteRequest &); + +/** + * @brief ACE CDR extraction operator for the MethodRequestWriteRequest class + */ +int operator<< (ACE_OutputCDR &, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestWriteRequest &); + +/** + * @brief ACE CDR insertion operator for the MethodRequestWriteRequest class + */ +int operator>> (ACE_InputCDR &, + FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestWriteRequest &); + +/** + * @brief evaluates the size of the content of a MethodRequestWriteResponse + * class + */ +unsigned long operator+= (unsigned long&, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestWriteResponse &); + +/** + * @brief ACE CDR extraction operator for the MethodRequestWriteResponse class. + */ +int operator<< (ACE_OutputCDR &, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestWriteResponse &); + +/** + * @brief ACE CDR insertion operator for the MethodRequestWriteResponse class. + */ +int operator>> (ACE_InputCDR &, + FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestWriteResponse &); + +/** + * @brief evaluates the size of the content of a MethodRequestInfoRequest + * class + */ +unsigned long operator+= (unsigned long&, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestInfoRequest &); + +/** + * @brief ACE CDR extraction operator for the MethodRequestInfoRequest class + */ +int operator<< (ACE_OutputCDR &, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestInfoRequest &); + +/** + * @brief ACE CDR insertion operator for the MethodRequestInfoRequest class + */ +int operator>> (ACE_InputCDR &, + FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestInfoRequest &); + +/** + * @brief evaluates the size of the content of a MethodRequestInfoResponse + * class + */ +unsigned long operator+= (unsigned long&, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestInfoResponse &); + +/** + * @brief ACE CDR extraction operator for the MethodRequestInfoResponse class. + */ +int operator<< (ACE_OutputCDR &, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestInfoResponse &); + +/** + * @brief ACE CDR insertion operator for the MethodRequestInfoResponse class. + */ +int operator>> (ACE_InputCDR &, + FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestInfoResponse &); +#endif /* _FAPI_ACYCLIC_PARAMETER_MARSHALLING_H_ */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequest.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequest.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,33 @@ +// $Id$ + + +#include "FAPIAIPCParameterMethodRequest.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + +/*---------------------------------------------------------------------------*/ + + MethodRequest::MethodRequest (unsigned long priority) + : ACE_Method_Request (priority) + { + } + +/*---------------------------------------------------------------------------*/ + + MethodRequest::~MethodRequest (void) + { + } + +/*---------------------------------------------------------------------------*/ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestFinish.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestFinish.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,56 @@ +// $Id$ + + +#include "FAPIAIPCParameterMethodRequestFinish.h" + + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + +/*---------------------------------------------------------------------------*/ + + MethodRequestFinish::MethodRequestFinish (void) + : MethodRequest (FAPIA_COMMUNICATION_PRIORITY_MAX) + { + } + +/*---------------------------------------------------------------------------*/ + + MethodRequestFinish::~MethodRequestFinish (void) + { + } + +/*---------------------------------------------------------------------------*/ + + int MethodRequestFinish::call (void) + { + return -1; + } + +/*---------------------------------------------------------------------------*/ + + MethodRequestFinish::MethodRequestFinish ( \ + const MethodRequestFinish&) + { + } + +/*---------------------------------------------------------------------------*/ + + const MethodRequestFinish& MethodRequestFinish \ + ::operator= (const MethodRequestFinish&) + { + return *this; + } + +/*---------------------------------------------------------------------------*/ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestFinish.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestFinish.h Thu Jul 19 07:15:27 2007 @@ -0,0 +1,86 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterMethodRequestFinish.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_FINISH_H_ +#define _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_FINISH_H_ + +#include "FAPIAIPCParameterMethodRequest.h" + + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + /** + * @class MethodRequestFinish + * + * @brief The MethodRequestFinish is the class for a read + * operation request. + * + */ + class MethodRequestFinish : + public FAPI::Acyclic::IPC::Parameter::MethodRequest + { + + public: + /** + * @brief Constructor of MethodRequestFinish. + * + */ + MethodRequestFinish (void); + + /** + * @brief Destructor of MethodRequestFinish. + * + */ + virtual ~MethodRequestFinish (void); + + /** + * @brief Invoked when the MethodRequestFinish is + * scheduled to run. + * + * If it returns -1 the receiving thread of this message + * must shut down. + * + */ + virtual int call (void); + + protected: + + private: + /** + * @brief Copy Constructor is private, so this object + * cannot be copied. + * + */ + MethodRequestFinish (const MethodRequestFinish&); + + /** + * @brief Assignment operator is private, so this object + * cannot be copied. + * + */ + const MethodRequestFinish& operator= ( \ + const MethodRequestFinish&); + + }; /* class MethodRequestFinish */ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_PARAMETER_METHOD_REQUEST_FINISH_H_ */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestInfoRequest.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestInfoRequest.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,69 @@ +// $Id$ + + +#include "FAPIAIPCParameterMethodRequestInfoRequest.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + +/*---------------------------------------------------------------------------*/ + + MethodRequestInfoRequest::MethodRequestInfoRequest (void) + { + } + +/*---------------------------------------------------------------------------*/ + + MethodRequestInfoRequest::~MethodRequestInfoRequest (void) + { + } + +/*---------------------------------------------------------------------------*/ + + bool MethodRequestInfoRequest::operator!= ( + const MethodRequestInfoRequest& request) const + { + return ((this->priority_ != request.priority_) || + (this->communication_ != request.communication_) || + (this->parameters_ != request.parameters_) || + (this->destination_physical_object_address_. \ + compare ( + request.destination_physical_object_address_ + ) != 0) + ); + } + +/*---------------------------------------------------------------------------*/ + + int MethodRequestInfoRequest::call (void) + { + return 0; + } + +/*---------------------------------------------------------------------------*/ + + MethodRequestInfoRequest::MethodRequestInfoRequest ( \ + const MethodRequestInfoRequest&) + { + } + +/*---------------------------------------------------------------------------*/ + + const MethodRequestInfoRequest& MethodRequestInfoRequest \ + ::operator= (const MethodRequestInfoRequest&) + { + return *this; + } + +/*---------------------------------------------------------------------------*/ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestInfoResponse.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestInfoResponse.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,71 @@ +// $Id$ + + +#include "FAPIAIPCParameterMethodRequestInfoResponse.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + +/*---------------------------------------------------------------------------*/ + + MethodRequestInfoResponse::MethodRequestInfoResponse (void) + { + } + +/*---------------------------------------------------------------------------*/ + + MethodRequestInfoResponse::~MethodRequestInfoResponse (void) + { + } + +/*---------------------------------------------------------------------------*/ + + bool MethodRequestInfoResponse::operator!= ( + const MethodRequestInfoResponse& resp) const + { + return ((this->priority_ != resp.priority_) || + (this->communication_ != resp.communication_) || + (this->parameters_ != resp.parameters_) || + (this->infos_ != resp.infos_) || + (this->errors_ != resp.errors_) || + (this->destination_physical_object_address_. \ + compare ( + resp.destination_physical_object_address_ + ) != 0) + ); + } + +/*---------------------------------------------------------------------------*/ + + int MethodRequestInfoResponse::call (void) + { + return 0; + } + +/*---------------------------------------------------------------------------*/ + + MethodRequestInfoResponse::MethodRequestInfoResponse ( \ + const MethodRequestInfoResponse&) + { + } + +/*---------------------------------------------------------------------------*/ + + const MethodRequestInfoResponse& MethodRequestInfoResponse \ + ::operator= (const MethodRequestInfoResponse&) + { + return *this; + } + +/*---------------------------------------------------------------------------*/ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestReadRequest.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestReadRequest.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,69 @@ +// $Id$ + + +#include "FAPIAIPCParameterMethodRequestReadRequest.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + +/*---------------------------------------------------------------------------*/ + + MethodRequestReadRequest::MethodRequestReadRequest (void) + { + } + +/*---------------------------------------------------------------------------*/ + + MethodRequestReadRequest::~MethodRequestReadRequest (void) + { + } + +/*---------------------------------------------------------------------------*/ + + bool MethodRequestReadRequest::operator!= ( + const MethodRequestReadRequest& request) const + { + return ((this->priority_ != request.priority_) || + (this->communication_ != request.communication_) || + (this->parameters_ != request.parameters_) || + (this->destination_physical_object_address_. \ + compare ( + request.destination_physical_object_address_ + ) != 0) + ); + } + +/*---------------------------------------------------------------------------*/ + + int MethodRequestReadRequest::call (void) + { + return 0; + } + +/*---------------------------------------------------------------------------*/ + + MethodRequestReadRequest::MethodRequestReadRequest ( \ + const MethodRequestReadRequest&) + { + } + +/*---------------------------------------------------------------------------*/ + + const MethodRequestReadRequest& MethodRequestReadRequest \ + ::operator= (const MethodRequestReadRequest&) + { + return *this; + } + +/*---------------------------------------------------------------------------*/ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestReadResponse.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestReadResponse.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,71 @@ +// $Id$ + + +#include "FAPIAIPCParameterMethodRequestReadResponse.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + +/*---------------------------------------------------------------------------*/ + + MethodRequestReadResponse::MethodRequestReadResponse (void) + { + } + +/*---------------------------------------------------------------------------*/ + + MethodRequestReadResponse::~MethodRequestReadResponse (void) + { + } + +/*---------------------------------------------------------------------------*/ + + bool MethodRequestReadResponse::operator!= ( + const MethodRequestReadResponse& resp) const + { + return ((this->priority_ != resp.priority_) || + (this->communication_ != resp.communication_) || + (this->parameters_ != resp.parameters_) || + (this->values_ != resp.values_) || + (this->errors_ != resp.errors_) || + (this->destination_physical_object_address_. \ + compare ( + resp.destination_physical_object_address_ + ) != 0) + ); + } + +/*---------------------------------------------------------------------------*/ + + int MethodRequestReadResponse::call (void) + { + return 0; + } + +/*---------------------------------------------------------------------------*/ + + MethodRequestReadResponse::MethodRequestReadResponse ( \ + const MethodRequestReadResponse&) + { + } + +/*---------------------------------------------------------------------------*/ + + const MethodRequestReadResponse& MethodRequestReadResponse \ + ::operator= (const MethodRequestReadResponse&) + { + return *this; + } + +/*---------------------------------------------------------------------------*/ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestWriteRequest.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestWriteRequest.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,70 @@ +// $Id$ + + +#include "FAPIAIPCParameterMethodRequestWriteRequest.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + +/*---------------------------------------------------------------------------*/ + + MethodRequestWriteRequest::MethodRequestWriteRequest (void) + { + } + +/*---------------------------------------------------------------------------*/ + + MethodRequestWriteRequest::~MethodRequestWriteRequest (void) + { + } + +/*---------------------------------------------------------------------------*/ + + bool MethodRequestWriteRequest::operator!= ( + const MethodRequestWriteRequest& request) const + { + return ((this->priority_ != request.priority_) || + (this->communication_ != request.communication_) || + (this->parameters_ != request.parameters_) || + (this->values_ != request.values_) || + (this->destination_physical_object_address_. \ + compare ( + request.destination_physical_object_address_ + ) != 0) + ); + } + +/*---------------------------------------------------------------------------*/ + + int MethodRequestWriteRequest::call (void) + { + return 0; + } + +/*---------------------------------------------------------------------------*/ + + MethodRequestWriteRequest::MethodRequestWriteRequest ( \ + const MethodRequestWriteRequest&) + { + } + +/*---------------------------------------------------------------------------*/ + + const MethodRequestWriteRequest& MethodRequestWriteRequest \ + ::operator= (const MethodRequestWriteRequest&) + { + return *this; + } + +/*---------------------------------------------------------------------------*/ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestWriteResponse.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterMethodRequestWriteResponse.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,70 @@ +// $Id$ + + +#include "FAPIAIPCParameterMethodRequestWriteResponse.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + +/*---------------------------------------------------------------------------*/ + + MethodRequestWriteResponse::MethodRequestWriteResponse (void) + { + } + +/*---------------------------------------------------------------------------*/ + + MethodRequestWriteResponse::~MethodRequestWriteResponse (void) + { + } + +/*---------------------------------------------------------------------------*/ + + bool MethodRequestWriteResponse::operator!= ( + const MethodRequestWriteResponse& resp) const + { + return ((this->priority_ != resp.priority_) || + (this->communication_ != resp.communication_) || + (this->parameters_ != resp.parameters_) || + (this->errors_ != resp.errors_) || + (this->destination_physical_object_address_. \ + compare ( + resp.destination_physical_object_address_ + ) != 0) + ); + } + +/*---------------------------------------------------------------------------*/ + + int MethodRequestWriteResponse::call (void) + { + return 0; + } + +/*---------------------------------------------------------------------------*/ + + MethodRequestWriteResponse::MethodRequestWriteResponse ( \ + const MethodRequestWriteResponse&) + { + } + +/*---------------------------------------------------------------------------*/ + + const MethodRequestWriteResponse& MethodRequestWriteResponse \ + ::operator= (const MethodRequestWriteResponse&) + { + return *this; + } + +/*---------------------------------------------------------------------------*/ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterParameter.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterParameter.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,83 @@ +// $Id$ + + +#include "FAPIAIPCParameterParameter.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + +/*---------------------------------------------------------------------------*/ + + Parameter::Parameter (void) + { + open (); + } + +/*---------------------------------------------------------------------------*/ + + Parameter::Parameter (const Parameter& parameter) + { + open (); + copy (parameter); + } + +/*---------------------------------------------------------------------------*/ + + const Parameter& Parameter::operator= (const Parameter& parameter) + { + if (this != ¶meter) + { + copy (parameter); + } + + return *this; + } + +/*---------------------------------------------------------------------------*/ + + Parameter::~Parameter (void) + { + close (); + } + +/*---------------------------------------------------------------------------*/ + + bool Parameter::operator!= (const Parameter& parameter) const + { + return ((this->parameter_name_.compare ( + parameter.parameter_name_) != 0) + ); + } + +/*---------------------------------------------------------------------------*/ + + void Parameter::open (void) + { + this->parameter_name_ = ACE_CString (); + } + +/*---------------------------------------------------------------------------*/ + + void Parameter::copy (const Parameter& parameter) + { + this->parameter_name_ = parameter.parameter_name_; + } + +/*---------------------------------------------------------------------------*/ + + void Parameter::close (void) + { + } + +/*---------------------------------------------------------------------------*/ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverAcceptor.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverAcceptor.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,76 @@ +// $Id$ + + +#include "FAPIAIPCParameterReceiverAcceptor.h" + +#include /**/ +#include /**/ + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + +/*---------------------------------------------------------------------------*/ + + ReceiverAcceptor::ReceiverAcceptor (ACE_Activation_Queue* q) + : queue_ (q) + { + } + +/*---------------------------------------------------------------------------*/ + + ReceiverAcceptor::~ReceiverAcceptor (void) + { + } + +/*---------------------------------------------------------------------------*/ + + int ReceiverAcceptor::close (void) + { + // close all open connections + for (size_t i = 0; i < this->receivers_.size (); i++) + { + this->receivers_[i]->close (); + } + return this->handle_close (); + } + +/*---------------------------------------------------------------------------*/ + + int ReceiverAcceptor::accept_svc_handler (ReceiverService* h) + { + h->queue (this->queue_); + + int reset_new_handle = + this->reactor ()->uses_event_associations (); + + if (this->acceptor ().accept (h->peer (), // stream + 0, // remote address + 0, // timeout + 1, // restart + reset_new_handle // reset + ) == -1) + { + // Close down handler to avoid memory leaks. + h->close (0); + + return -1; + } + else + { + this->receivers_.push_back (h); + return 0; + } + } + +/*---------------------------------------------------------------------------*/ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverAcceptor.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverAcceptor.h Thu Jul 19 07:15:27 2007 @@ -0,0 +1,88 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterReceiverAcceptor.h + * + * $Id$ + * + * @author Friedhelm Wolf + */ +//============================================================================= + +#ifndef _FAPIA_IPC_PARAMETER_RECEIVER_ACCEPTOR_H_ +#define _FAPIA_IPC_PARAMETER_RECEIVER_ACCEPTOR_H_ + +#include "FAPIAIPCParameterReceiverService.h" +#include /**/ +#include /**/ +#include /**/ + +#include "FAPIAIPCParameterSocket.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + + typedef ACE_Strong_Bound_Ptr + ReceiverService_Ptr; + + typedef ACE_Vector Receiver_Vector; + + /** + * @class ReceiverAcceptor + * + * @brief Acceptor class which delegates socket communication + * to the ReceiverService. + * @sa ReceiverService + */ + class ReceiverAcceptor : + public ACE_Acceptor + { + public: + + /** + * @brief constructor + * @param queue to which the ReceiverService will + * pass the received MethodRequests + */ + ReceiverAcceptor (ACE_Activation_Queue*); + + /** + * @brief standard destructor + */ + virtual ~ReceiverAcceptor (); + + /** + * @brief closes all open connections + */ + virtual int close (void); + + /** + * @brief implementation of the ACE_Acceptor template + * method for activating the service handler. + * It will pass the queue to the ReceiverService + * besides the standard behaviour + */ + virtual int accept_svc_handler (ReceiverService*); + + private: + /// input queue which will be passed to the ReceiverService + ACE_Activation_Queue* queue_; + + Receiver_Vector receivers_; + }; + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + + +#endif /* _FAPIA_IPC_PARAMETER_RECEIVER_ACCEPTOR_H_ */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverService.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverService.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,355 @@ +// $Id$ + + +#include "FAPIAIPCParameterReceiverService.h" + +#include "FAPIATrace.h" +#include "FAPIAIPCParameterMarshalling.h" +#include "FAPIAIPCParameterStreaming.h" + +#include /**/ +#include /**/ +#include /**/ + +#include + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + +/*---------------------------------------------------------------------------*/ + +ReceiverService::ReceiverService (void) +: queue_ (NULL) +{ +} + +/*---------------------------------------------------------------------------*/ + +ReceiverService::~ReceiverService (void) +{ + FAPIA_TRACE; +} + +/*---------------------------------------------------------------------------*/ + +void ReceiverService::queue (ACE_Activation_Queue* q) +{ + this->queue_ = q; +} + +/*---------------------------------------------------------------------------*/ + +int ReceiverService::open (void *) +{ + FAPIA_TRACE; + + if (this->queue_ == NULL) + { + FAPIA_DEBUG (LM_ERROR, "queue not initialized."); + return -1; + } + + if (this->reactor ()->register_handler (this, + ACE_Svc_Handler::READ_MASK) == 1) + { + FAPIA_DEBUG (LM_ERROR, "could not register receiver handler"); + return -1; + } + + return 0; +} + +/*---------------------------------------------------------------------------*/ + +int ReceiverService::handle_input (ACE_HANDLE) +{ + FAPIA_TRACE; + + // allocate memory for the fixed size header containing the necessary + // data to demarshal the following method request + ACE_Strong_Bound_Ptr header_data ( + new ACE_Message_Block (ACE_DEFAULT_CDR_BUFSIZE)); + ACE_CDR::mb_align (header_data.get ()); + + // read the data and check for correct header size + if (this->peer ().recv_n (header_data->wr_ptr (), FAPIA_HEADER_SIZE) == + FAPIA_HEADER_SIZE) + { + // set write pointer according to read in length + header_data->wr_ptr (FAPIA_HEADER_SIZE); + + // create a ACE CDR object to demarshall data + ACE_InputCDR header_cdr (header_data.get ()); + + // find out byte order + ACE_CDR::Boolean byte_order; + header_cdr >> ACE_InputCDR::to_boolean (byte_order); + header_cdr.reset_byte_order (byte_order); + + // find out the length of the following data block + ACE_CDR::ULong data_length; + header_cdr >> data_length; + + // find out exact type of the received method request + ACE_CDR::ULong method_request_val; + header_cdr >> method_request_val; + FAPI::Acyclic::IPC::Parameter::MethodRequestType method_request_type = + ACE_static_cast (FAPI::Acyclic::IPC::Parameter::MethodRequestType, + method_request_val); + + // allocate data for the data part of the received telegramm + ACE_Strong_Bound_Ptr request_data ( + new ACE_Message_Block (data_length)); + ACE_CDR::mb_align (request_data.get ()); + + // read the socket buffer + if (this->peer ().recv_n (request_data->wr_ptr (), data_length) == + (long)data_length) + { + // prepare demarshalling + request_data->wr_ptr (data_length); + ACE_InputCDR request_cdr (request_data.get ()); + + // ditinguish between the different kinds of method requests + switch (method_request_type) + { + case FAPIA_READ_REQUEST: + { + // allocate new object to be filled with the data + FAPI::Acyclic::IPC::Parameter::MethodRequestReadRequest* + read_request = new FAPI::Acyclic::IPC::Parameter:: + MethodRequestReadRequest; + + // demarshall request + if (request_cdr >> *read_request) + { + std::stringstream ss; + if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) & + LM_DEBUG) + { + ss << *read_request; + } + // enqueue request into Activation_Queue + if (queue_->enqueue (read_request) != -1) + { + FAPIA_DEBUG (LM_DEBUG, "enqueued %s", ss.str ().c_str ()); + } + else // error when enqueuing + { + FAPIA_DEBUG (LM_ERROR, "error when enqueueing ReadRequest"); + return -1; + } + } + else // error of demarshalling + { + FAPIA_DEBUG (LM_ERROR, "ReadRequest was not received correctly"); + return -1; + } + + break; + } // end case FAPIA_READ_REQUEST + case FAPIA_READ_RESPONSE: + { + // allocate new object to be filled with the data + FAPI::Acyclic::IPC::Parameter::MethodRequestReadResponse* + read_response = new FAPI::Acyclic::IPC::Parameter:: + MethodRequestReadResponse; + + // demarshall request + if (request_cdr >> *read_response) + { + std::stringstream ss; + if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) & + LM_DEBUG) + { + ss << *read_response; + } + // enqueue request into Activation_Queue + if (queue_->enqueue (read_response) != -1) + { + FAPIA_DEBUG (LM_DEBUG, "enqueued %s", ss.str ().c_str ()); + } + else // error when enqueuing + { + FAPIA_DEBUG (LM_ERROR, "error when enqueueing ReadResponse"); + return -1; + } + } + else // error of demarshalling + { + FAPIA_DEBUG (LM_ERROR, "ReadResponse was not received correctly"); + return -1; + } + + break; + } // end case FAPIA_READ_RESPONSE + case FAPIA_WRITE_REQUEST: + { + // allocate new object to be filled with the data + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteRequest* + write_request = new FAPI::Acyclic::IPC::Parameter:: + MethodRequestWriteRequest; + + // demarshall request + if (request_cdr >> *write_request) + { + std::stringstream ss; + if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) & + LM_DEBUG) + { + ss << *write_request; + } + // enqueue request into Activation_Queue + if (queue_->enqueue (write_request) != -1) + { + FAPIA_DEBUG (LM_DEBUG, "enqueued %s", ss.str ().c_str ()); + } + else // error when enqueuing + { + FAPIA_DEBUG (LM_ERROR, "error when enqueueing WriteRequest"); + return -1; + } + } + else // error of demarshalling + { + FAPIA_DEBUG (LM_ERROR, "WriteRequest was not received correctly"); + return -1; + } + + break; + } // end case FAPIA_WRITE_REQUEST + case FAPIA_WRITE_RESPONSE: + { + // allocate new object to be filled with the data + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteResponse* + write_response = new FAPI::Acyclic::IPC::Parameter:: + MethodRequestWriteResponse; + + // demarshall request + if (request_cdr >> *write_response) + { + std::stringstream ss; + if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) & + LM_DEBUG) + { + ss << *write_response; + } + // enqueue request into Activation_Queue + if (queue_->enqueue (write_response) != -1) + { + FAPIA_DEBUG (LM_DEBUG, "enqueued %s", ss.str ().c_str ()); + } + else // error when enqueuing + { + FAPIA_DEBUG (LM_ERROR, "error when enqueueing WriteResponse"); + return -1; + } + } + else // error of demarshalling + { + FAPIA_DEBUG (LM_ERROR, "WriteResponse was not received correctly"); + return -1; + } + } // end case FAPIA_WRITE_RESPONSE + + break; + case FAPIA_INFO_REQUEST: + { + // allocate new object to be filled with the data + FAPI::Acyclic::IPC::Parameter::MethodRequestInfoRequest* + info_request = new FAPI::Acyclic::IPC::Parameter:: + MethodRequestInfoRequest; + + // demarshall request + if (request_cdr >> *info_request) + { + std::stringstream ss; + if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) & + LM_DEBUG) + { + ss << *info_request; + } + // enqueue request into Activation_Queue + if (queue_->enqueue (info_request) != -1) + { + FAPIA_DEBUG (LM_DEBUG, "enqueued %s", ss.str ().c_str ()); + } + else // error when enqueuing + { + FAPIA_DEBUG (LM_ERROR, "error when enqueueing InfoRequest"); + return -1; + } + } + else // error of demarshalling + { + FAPIA_DEBUG (LM_ERROR, "InfoRequest was not received correctly"); + return -1; + } + + break; + } // end case FAPIA_INFO_REQUEST + case FAPIA_INFO_RESPONSE: + { + // allocate new object to be filled with the data + FAPI::Acyclic::IPC::Parameter::MethodRequestInfoResponse* + info_response = new FAPI::Acyclic::IPC::Parameter:: + MethodRequestInfoResponse; + + // demarshall request + if (request_cdr >> *info_response) + { + std::stringstream ss; + if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) & + LM_DEBUG) + { + ss << *info_response; + } + // enqueue request into Activation_Queue + if (queue_->enqueue (info_response) != -1) + { + FAPIA_DEBUG (LM_DEBUG, "enqueued %s", ss.str ().c_str ()); + } + else // error when enqueuing + { + FAPIA_DEBUG (LM_ERROR, "error when enqueueing InfoResponse"); + return -1; + } + } + else // error of demarshalling + { + FAPIA_DEBUG (LM_ERROR, "InfoResponse was not received correctly"); + return -1; + } + + break; + } // end case FAPIA_INFO_RESPONSE + default: + { + // could not recognize method request, so just return and print a + // warning + FAPIA_DEBUG (LM_WARNING, "unkown method request type revieved."); + return 0; + } + } // end swith (method_request_type) + + // if everything went well, return number of received bytes + return 0; //data_length + FAPIA_HEADER_SIZE; + } + } // end if header was received correctly + + // do nothing, if no correct header was sent + return 0; +} + +/*---------------------------------------------------------------------------*/ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverService.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverService.h Thu Jul 19 07:15:27 2007 @@ -0,0 +1,95 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterReceiverService.h + * + * $Id$ + * + * @author Friedhelm Wolf + */ +//============================================================================= + +#ifndef _FAPIA_IPC_PARAMETER_RECEIVER_SERVICE_H_ +#define _FAPIA_IPC_PARAMETER_RECEIVER_SERVICE_H_ + +#include + +#include "FAPIAIPCParameterSocket.h" + +// forward declaration +class ACE_Activation_Queue; + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + + /** + * @class ReceiverService + * + * @brief A service using the ACE_Svc_Handler technique + * to implement the receiver part of FAPIA socket + * communication. It receives MethodRequests from + * a socket connection and enqueues them into an + * ACE_Activation_Queue for further processing by + * the Controller. + */ + class ReceiverService : + public ACE_Svc_Handler + { + public: + + /** + * @brief standard constructor + */ + ReceiverService (void); + + /** + * @brief standard destructor + */ + virtual ~ReceiverService (void); + + /** + * @brief initialization method to set the queue + * from which the requests are read + */ + void queue (ACE_Activation_Queue*); + + /** + * @brief implementation of the ACE_Svc_Handler open + * method, which is responsible for service + * initialization. In this case especially the + * registration of the socket connection within + * the reactor framework + * @return 0 if successful, -1 otherwise + * @sa ACE_Svc_Handler + */ + virtual int open (void *); + + /** + * @brief implementation of the event handler method + * of the ACE_Svc_Handler, which is responsible + * for socket events + * @sa ACE_Svc_Handler + */ + virtual int handle_input (ACE_HANDLE); + + private: + + /// input queue into which requests will be enqueued + ACE_Activation_Queue* queue_; + + }; + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + + +#endif /* _FAPIA_IPC_PARAMETER_RECEIVER_SERVICE_H_ */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverTask.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverTask.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,136 @@ +// $Id$ + + +#include "FAPIAIPCParameterReceiverTask.h" +#include "FAPIAIPCParameterReceiverAcceptor.h" +#include "FAPIATrace.h" + +#include /**/ + +using namespace FAPI::Acyclic::IPC::Parameter; + +/*---------------------------------------------------------------------------*/ + +ReceiverTask::ReceiverTask (ACE_Activation_Queue *q) +: queue_ (q), connection_semaphore_ (0) +{ + receiver_acceptor_ = new ReceiverAcceptor(q); +} + +/*---------------------------------------------------------------------------*/ + +ReceiverTask::~ReceiverTask (void) +{ + delete receiver_acceptor_; +} + +/*---------------------------------------------------------------------------*/ + +ACE_CString ReceiverTask::listen_addr () +{ + + // wait until semaphore is released + connection_semaphore_.acquire (); + connection_semaphore_.release (); + + return listen_addr_; +} + +/*---------------------------------------------------------------------------*/ + +int ReceiverTask::shutdown (void) +{ + FAPIA_TRACE; + + receiver_acceptor_->close (); + if (ACE_Reactor::instance()->end_reactor_event_loop() == 0) + { + return this->wait (); + } + + return -1; +} + +/*---------------------------------------------------------------------------*/ + +int ReceiverTask::svc (void) +{ + FAPIA_TRACE; +/* + // Create an adapter to end the event loop. + ACE_Sig_Adapter sa ((ACE_Sig_Handler_Ex) ACE_Reactor::end_event_loop); + + ACE_Sig_Set sig_set; + sig_set.sig_add (SIGINT); + sig_set.sig_add (SIGQUIT); + + // Register ourselves to receive SIGINT and SIGQUIT so we can shut + // down gracefully via signals. + if (ACE_Reactor::instance ()->register_handler (sig_set, + &sa) == -1) + { + FAPIA_DEBUG (LM_ERROR, "could not register signal handler.\n"); + return -1; + } +*/ + FAPIA_Addr addr; + +#ifdef FAPIA_HAS_NETWORK_SOCKETS + addr.set (ACE_sap_any_cast (const FAPIA_Addr &)); +#else + ACE_CString rendevous_point = "/tmp/fapia.cp."; + char pid[10]; + sprintf (pid, "%d", ACE_OS::getpid ()); + rendevous_point += pid; + ACE_OS::unlink (rendevous_point.c_str ()); + addr.set (rendevous_point.c_str ()); +#endif + + if (receiver_acceptor_->open (addr, + ACE_Reactor::instance ()) == -1) + { + if (errno == EADDRINUSE) + { + FAPIA_DEBUG (LM_ERROR, "address already in use\n"); + } + + receiver_acceptor_->acceptor ().get_local_addr (addr); + ACE_TCHAR str_addr[255]; + addr.addr_to_string (str_addr, 255); + FAPIA_DEBUG (LM_ERROR, "could not open new port %s for listening\n", str_addr); + return -1; + } + + // store address + receiver_acceptor_->acceptor ().get_local_addr (addr); + + // if we have TCP/IP sockets we have to enter the hostname as well +#ifdef FAPIA_HAS_NETWORK_SOCKETS + char hostname[255]; + addr.set (addr.get_port_number (), + ACE_OS::hostname (hostname, 255) ? "localhost" : hostname); +#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ + + ACE_TCHAR str_addr[255]; + addr.addr_to_string (str_addr, 255); + listen_addr_ = str_addr; + + // make address information accessible via this::listen_addr () + connection_semaphore_.release (); + + FAPIA_DEBUG (LM_NOTICE, "waiting for requests on %s ...", listen_addr_.c_str ()); + + // we need these settings to be able to rerun the event loop + // after a deinit, init sequence + ACE_Reactor::instance()->owner (ACE_OS::thr_self ()); + ACE_Reactor::instance()->reset_event_loop (); + + // run the Reactor to wait for socket connections + int result = ACE_Reactor::instance()->run_reactor_event_loop(); + + FAPIA_DEBUG (LM_NOTICE, "receiver task is shutting down (%d) ...", result); + + return result; +} + +/*---------------------------------------------------------------------------*/ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverTask.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterReceiverTask.h Thu Jul 19 07:15:27 2007 @@ -0,0 +1,102 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterReceiverTask.h + * + * $Id$ + * + * @author Friedhelm Wolf + */ +//============================================================================= + +#ifndef _FAPIA_IPC_PARAMETER_RECEIVER_TASK_H_ +#define _FAPIA_IPC_PARAMETER_RECEIVER_TASK_H_ + +#include +#include + +// forward declaration +class ACE_Activation_Queue; + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + + // forward declaration + class ReceiverAcceptor; + + /** + * @brief this class encapsulates initialisation of + * a socket acceptor, receiving method requests + * and runs the reactor event loop in it's svc + * routine. + */ + class ReceiverTask : public ACE_Task + { + public: + + /** + * @brief constructor + * @param queue to which received request should be + * passed + */ + ReceiverTask (ACE_Activation_Queue*); + + /** + * @brief default destructor + */ + virtual ~ReceiverTask (void); + + /** + * @brief terminates the thread.and performs + * a blocking wait on thread cancellation + * @return 0 if successful, -1 otherwise + */ + int shutdown (void); + + /** + * @brief operation which will block until the + * socket is initialized to listen for incoming + * requests. Therefore it can also be used as a + * synchronization point during initialization. + * @result stringified socket listen address of the form + * : + */ + ACE_CString listen_addr (); + + protected: + + /** + * @break thread execution routine + * @return 0 on success, negative value otherwise + */ + virtual int svc (void); + + private: + + /// this queue is passed to the internal ReceiverService + ACE_Activation_Queue* queue_; + + /// acceptor used to establish connections + ReceiverAcceptor* receiver_acceptor_; + + /// will block until connection is initialized. + ACE_Semaphore connection_semaphore_; + + /// socket address on which to wait for connections + ACE_CString listen_addr_; + }; + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + + +#endif /* _FAPIA_IPC_PARAMETER_RECEIVER_TASK_H_ */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterSenderService.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterSenderService.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,565 @@ +// $Id$ + + +#include "FAPIAIPCParameterSenderService.h" + +#include "FAPIAIPCParameterMethodRequestFinish.h" +#include "FAPIAIPCParameterMarshalling.h" +#include "FAPIAIPCParameterStreaming.h" +#include "FAPIATrace.h" + +#include /**/ +#include /**/ + +#include + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + +/*---------------------------------------------------------------------------*/ + +SenderService::SenderService (void) +: send_queue_ (NULL), receive_queue_ (NULL) +{ +} + +/*---------------------------------------------------------------------------*/ + +SenderService::~SenderService (void) +{ +} + +/*---------------------------------------------------------------------------*/ + +int SenderService::close (u_long flags) +{ + FAPIA_TRACE; + + ACE_UNUSED_ARG (flags); + int result = 0; + + // close all connections + for (StreamMap::iterator stream = connections_.begin (); + stream != connections_.end (); + stream++) + { + result += (*stream).int_id_->close (); + } +/* + result += + ACE_Svc_Handler ::close (flags); +*/ + return result; +} + +/*---------------------------------------------------------------------------*/ + +void SenderService::send_queue (ACE_Activation_Queue* q) +{ + this->send_queue_ = q; +} + +/*---------------------------------------------------------------------------*/ + +void SenderService::receive_queue (ACE_Activation_Queue* q) +{ + this->receive_queue_ = q; +} + +/*---------------------------------------------------------------------------*/ + +int SenderService::svc (void) +{ + //FAPIA_TRACE; + + bool shutdown_flag = false; + + // check if queue is available + if (send_queue_ == NULL) + { + FAPIA_DEBUG (LM_ERROR, "SenderService queue was not initialized"); + return -1; + } + + FAPI::Acyclic::IPC::Parameter::MethodRequestType request_type = + FAPIA_UNKNOWN_REQUEST; + + do + { + // dequeue method request from the queue + ACE_Strong_Bound_Ptr + request(ACE_dynamic_cast (MethodRequest*, + this->send_queue_->dequeue ()) + ); + + // check for abort request + if ((!request.null ()) && (request->call () == 0)) + { + // find out the type of the call + MethodRequestReadRequest* rreq= NULL; + MethodRequestReadResponse* rres = NULL; + MethodRequestWriteRequest* wreq = NULL; + MethodRequestWriteResponse* wres = NULL; + MethodRequestInfoRequest* ireq = NULL; + MethodRequestInfoResponse* ires = NULL; + + // is the request a read request? + rreq = ACE_dynamic_cast (MethodRequestReadRequest*, + request.get ()); + if (rreq == NULL) + { + // is the request a read response? + rres = ACE_dynamic_cast (MethodRequestReadResponse*, + request.get ()); + if (rres == NULL) + { + // is the request a write request? + wreq = ACE_dynamic_cast (MethodRequestWriteRequest*, + request.get ()); + if (wreq == NULL) + { + // is the request a write response? + wres = ACE_dynamic_cast (MethodRequestWriteResponse*, + request.get ()); + if (wres == NULL) + { + // is the request an info request? + ireq = ACE_dynamic_cast (MethodRequestInfoRequest*, + request.get ()); + if (ireq == NULL) + { + // is the request an info response? + ires = ACE_dynamic_cast (MethodRequestInfoResponse*, + request.get ()); + if (ires == NULL) + { + // Type of request is unknown. + request_type = FAPIA_UNKNOWN_REQUEST; + } + else + { + request_type = FAPIA_INFO_RESPONSE; + } // is the request an info response? + } + else + { + request_type = FAPIA_INFO_REQUEST; + } // is the request an info request? + } + else + { + request_type = FAPIA_WRITE_RESPONSE; + } // end if is the request a write response? + } + else + { + request_type = FAPIA_WRITE_REQUEST; + } // end if is the request a write request? + } + else + { + request_type = FAPIA_READ_RESPONSE; + } // end if is the request a read response? + } + else + { + request_type = FAPIA_READ_REQUEST; + } // end if is the request a read request? + + //prepare data structures for marshalling + ACE_OutputCDR header_cdr (ACE_CDR::MAX_ALIGNMENT + + FAPIA_HEADER_SIZE); + header_cdr << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER); + + ACE_Strong_Bound_Ptr request_cdr; + + // process request + switch (request_type) + { + case FAPIA_READ_REQUEST: + { + std::stringstream ss; + if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) & + LM_DEBUG) + { + ss << *rreq; + } + FAPIA_DEBUG (LM_DEBUG, "sending %s", ss.str ().c_str ()); + + // calculate data block size + unsigned long request_size = 0; + request_size += *rreq; + request_cdr.reset (new ACE_OutputCDR (request_size)); + + // linearize data + *request_cdr << *rreq; + + // add length and type information to the header + header_cdr << ACE_CDR::ULong (request_cdr->total_length ()); + header_cdr << ACE_CDR::ULong (request_type); + + break; + } // end case FAPIA_READ_REQUEST + case FAPIA_READ_RESPONSE: + { + std::stringstream ss; + if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) & LM_DEBUG) + { + ss << *rres; + } + FAPIA_DEBUG (LM_DEBUG, "sending %s", ss.str ().c_str ()); + + // calculate data block size + unsigned long request_size = 0; + request_size += *rres; + request_cdr.reset (new ACE_OutputCDR (request_size)); + + // linearize data + *request_cdr << *rres; + + // add length and type information to the header + header_cdr << ACE_CDR::ULong (request_cdr->total_length ()); + header_cdr << ACE_CDR::ULong (request_type); + + break; + } // end case FAPIA_READ_RESPONSE + case FAPIA_WRITE_REQUEST: + { + std::stringstream ss; + if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) & + LM_DEBUG) + { + ss << *wreq; + } + FAPIA_DEBUG (LM_DEBUG, "sending %s", ss.str ().c_str ()); + + // calculate data block size + unsigned long request_size = 0; + request_size += *wreq; + request_cdr.reset (new ACE_OutputCDR (request_size)); + + // linearize data + *request_cdr << *wreq; + + // add length and type information to the header + header_cdr << ACE_CDR::ULong (request_cdr->total_length ()); + header_cdr << ACE_CDR::ULong (request_type); + + break; + } // end case FAPIA_WRITE_REQUEST + case FAPIA_WRITE_RESPONSE: + { + std::stringstream ss; + if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) & + LM_DEBUG) + { + ss << *wres; + } + FAPIA_DEBUG (LM_DEBUG, "sending %s", ss.str ().c_str ()); + + // calculate data block size + unsigned long request_size = 0; + request_size += *wres; + request_cdr.reset (new ACE_OutputCDR (request_size)); + + // linearize data + *request_cdr << *wres; + + // add length and type information to the header + header_cdr << ACE_CDR::ULong (request_cdr->total_length ()); + header_cdr << ACE_CDR::ULong (request_type); + + break; + } // end case FAPIA_WRITE_RESPONSE + case FAPIA_INFO_REQUEST: + { + std::stringstream ss; + if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) & + LM_DEBUG) + { + ss << *ireq; + } + FAPIA_DEBUG (LM_DEBUG, "sending %s", ss.str ().c_str ()); + + // calculate data block size + unsigned long request_size = 0; + request_size += *ireq; + request_cdr.reset (new ACE_OutputCDR (request_size)); + + // linearize data + *request_cdr << *ireq; + + // add length and type information to the header + header_cdr << ACE_CDR::ULong (request_cdr->total_length ()); + header_cdr << ACE_CDR::ULong (request_type); + + break; + } // end case FAPIA_INFO_REQUEST + case FAPIA_INFO_RESPONSE: + { + std::stringstream ss; + if (ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS) & + LM_DEBUG) + { + ss << *ires; + } + FAPIA_DEBUG (LM_DEBUG, "sending %s", ss.str ().c_str ()); + + // calculate data block size + unsigned long request_size = 0; + request_size += *ires; + request_cdr.reset (new ACE_OutputCDR (request_size)); + + // linearize data + *request_cdr << *ires; + + // add length and type information to the header + header_cdr << ACE_CDR::ULong (request_cdr->total_length ()); + header_cdr << ACE_CDR::ULong (request_type); + + break; + } // end case FAPIA_INFO_RESPONSE + case FAPIA_UNKNOWN_REQUEST: + default: + { + FAPIA_DEBUG (LM_WARNING, "unkown request received."); + continue; + } // end of default case + } // end switch (request_type) + + // Determine amount of message blocks. + unsigned long i = 0; + const ACE_Message_Block *mb = request_cdr->begin (); + while (mb != request_cdr->end ()) + { + mb = mb->cont(); + ++i; + } + + // fill buffers for a scatter + iovec* iov = 0; + ACE_NEW_NORETURN (iov, iovec[1 + i]); + if (iov == 0) + { + FAPIA_DEBUG (LM_EMERGENCY, "Error allocating memory."); + continue; + } + + iov[0].iov_base = header_cdr.begin ()->rd_ptr (); + iov[0].iov_len = FAPIA_HEADER_SIZE; + + mb = request_cdr->begin (); + i = 1; + while (mb != request_cdr->end ()) + { + iov[i].iov_base = mb->rd_ptr (); + iov[i].iov_len = mb->length (); + mb = mb->cont(); + ++i; + } + + ACE_Hash_Map_Entry * map_entry; + + // find out, if connection to destination needs to be established + if (connections_.find (request->destination_physical_object_address_, + map_entry) != 0) + { + // make new connection + + ACE_Strong_Bound_Ptr stream ( + new FAPIA_Stream ()); + + FAPIA_Addr addr ( + request->destination_physical_object_address_.c_str ()); + + if (connector_.connect (*stream, addr) == 0) + { + // save stream into the connection map if connection was + // succesfully established + // and fill map entry with the correct value + if ( (connections_.bind ( + request->destination_physical_object_address_, + stream) != 0) + || (connections_.find ( + request->destination_physical_object_address_, + map_entry) != 0)) + { + FAPIA_DEBUG (LM_ERROR, + "could not add connection to map."); + delete [] iov; + iov = 0; + return -1; + } + } + else + { + ACE_TCHAR buffer[255]; + addr.addr_to_string (buffer, 255); + FAPIA_DEBUG (LM_WARNING, + "could not connect to address %s. I'll try to enqueue an error.", + buffer); + + if (request_type == FAPIA_READ_REQUEST) + { + if (queue_read_error (rreq->communication_, + buffer) != 0) + FAPIA_DEBUG (LM_WARNING, + "could not enqueue read response error"); + } + else if (request_type == FAPIA_WRITE_REQUEST) + { + if (queue_write_error (wreq->communication_, + buffer) != 0) + FAPIA_DEBUG (LM_WARNING, + "could not enqueue write response error"); + } + + delete [] iov; + iov = 0; + continue; + } + } + + // send data + if (map_entry->int_id_->sendv_n (iov, i) > 0) + { + FAPIA_DEBUG (LM_INFO, "request sent to %s", + request->destination_physical_object_address_.c_str ()); + delete [] iov; + iov = 0; + } + else + { + delete [] iov; + iov = 0; + FAPIA_DEBUG (LM_WARNING, + "could not send request to %s. I'll try to enqueue an error.", + request->destination_physical_object_address_.c_str ()); + StreamPtr useless_stream; + + // close the stream + if (connections_.unbind ( + request->destination_physical_object_address_, + useless_stream) == 0) + { + useless_stream->close (); + } + + if (request_type == FAPIA_READ_REQUEST) + { + if (queue_read_error (rreq->communication_, + request->destination_physical_object_address_) != 0) + FAPIA_DEBUG (LM_WARNING, + "could not enqueue read response error"); + } + else if (request_type == FAPIA_WRITE_REQUEST) + { + if (queue_write_error (wreq->communication_, + request->destination_physical_object_address_) != 0) + FAPIA_DEBUG (LM_WARNING, + "could not enqueue write response error"); + } + + continue; + } + + } // end if no shutdown request + else + { + FAPIA_DEBUG (LM_NOTICE, "SenderService received shutdown request"); + shutdown_flag = true; + } + + } while (!shutdown_flag); + +// return this->close (); + return 0; +} + +/*---------------------------------------------------------------------------*/ + +int SenderService::queue_write_error (const Communication &c, + const ACE_CString &addr) +{ + FAPIA_TRACE; + + // check if queue is available + if (receive_queue_ == NULL) + { + return -1; + } + + // generate response + MethodRequestWriteResponse* response = new MethodRequestWriteResponse (); + + response->communication_ = c; + response->communication_.communication_error_.error_code_ = + FAPIA_ERROR_DESTINATION_NOT_ONLINE; + response->communication_.communication_error_.reason_ = + "could not establish connection to "; + response->communication_.communication_error_.reason_ += addr; + + ACE_Time_Value tv = ACE_OS::gettimeofday () + + ACE_static_cast(ACE_Time_Value, 100); + + return receive_queue_->enqueue (response, &tv); +} + +/*---------------------------------------------------------------------------*/ + +int SenderService::queue_read_error (const Communication &c, + const ACE_CString &addr) +{ + FAPIA_TRACE; + + // check if queue is available + if (receive_queue_ == NULL) + { + return -1; + } + + // generate response + MethodRequestReadResponse* response = new MethodRequestReadResponse (); + + response->communication_ = c; + response->communication_.communication_error_.error_code_ = + FAPIA_ERROR_DESTINATION_NOT_ONLINE; + response->communication_.communication_error_.reason_ = + "could not establish connection to "; + response->communication_.communication_error_.reason_ += addr; + + ACE_Time_Value tv = ACE_OS::gettimeofday () + + ACE_static_cast(ACE_Time_Value, 100); + + return receive_queue_->enqueue (response, &tv); +} + +/*---------------------------------------------------------------------------*/ + +int SenderService::shutdown (void) +{ + FAPIA_TRACE; + + if (this->send_queue_ != NULL) + { + this->send_queue_->enqueue ( + new FAPI::Acyclic::IPC::Parameter::MethodRequestFinish ()); + + return this->wait (); + } + + return -1; +} + +/*---------------------------------------------------------------------------*/ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterSenderService.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterSenderService.h Thu Jul 19 07:15:27 2007 @@ -0,0 +1,160 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterSenderService.h + * + * $Id$ + * + * @author Friedhelm Wolf + */ +//============================================================================= + +#ifndef _FAPIA_IPC_PARAMETER_SENDER_SERVICE_H_ +#define _FAPIA_IPC_PARAMETER_SENDER_SERVICE_H_ + +#include +#include +#include +#include + +#include "FAPIAIPCParameterSocket.h" + +//forward declaration +class ACE_Activation_Queue; + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + + // forward declarations + class SenderService; + class Communication; + + /** + * @brief pointer to an ACE_SOCK_Stream + */ + + typedef ACE_Strong_Bound_Ptr + StreamPtr; + + /** + * @brief Map which associates socket addresses in + * in stringified form with ACE_SOCK_Streams + */ + typedef ACE_Hash_Map_Manager + StreamMap; + + /** + * @class SenderService + * + * @brief A service using the ACE_Svc_Handler technique + * to implement the sender part of FAPIA socket + * communication. It dequeues MethodRequests from + * an ACE_Activation_Queue filled by the Controller + * and sends them to a FAPIA server via a socket. + */ + class SenderService : + public ACE_Svc_Handler + { + public: + + /** + * @brief standard constructor + */ + SenderService (void); + + /** + * @brief standard destructor + */ + ~SenderService (void); + + /** + * @brief initialization method to set the queue + * from which the requests are read + */ + void send_queue (ACE_Activation_Queue*); + + /** + * @brief initialization method to set the queue + * which handles replies (loopback) + */ + void receive_queue (ACE_Activation_Queue*); + + /** + * @brief terminates the thread.and performs + * a blocking wait on thread cancellation + * @return 0 if successful, -1 otherwise + */ + int shutdown (void); + + /** + * @brief closes all connections + * @sa ACE_Svc_Handler + */ + virtual int close (u_long flags = 0); + + protected: + + /** + * @brief as the service is derived from ACE_Task, + * it has it's own thread of control + * @return 0 if successful, -1 otherwise + */ + virtual int svc (void); + + /** + * @brief bypasses socket communication and enqueues + * a MethodRequestWriteResponse with error code + * set to FAPIA_ERROR_DESTINATION_NOT_ONLINE + * into the receive queue of the process + * @param communication header of the request + * @param address of the destination + * @return 0 if successful, -1 otherwise + */ + int queue_write_error (const Communication &, + const ACE_CString &); + + /** + * @brief bypasses socket communication and enqueues + * a MethodRequestReadResponse with error code + * set to FAPIA_ERROR_DESTINATION_NOT_ONLINE + * into the receive queue of the process + * @param communication header of the request + * @param address of the destination + * @return 0 if successful, -1 otherwise + */ + int queue_read_error (const Communication &, + const ACE_CString &); + + private: + + /// ACE Connector to establish new connections + FAPIA_Connector connector_; + + /// map holding all open connections + StreamMap connections_; + + /// input queue which contains the requests + ACE_Activation_Queue* send_queue_; + + /// loopback queue to the own process + ACE_Activation_Queue* receive_queue_; + + }; + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + + +#endif /* _FAPIA_IPC_PARAMETER_SENDER_SERVICE_H_ */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterSocket.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterSocket.h Thu Jul 19 07:15:27 2007 @@ -0,0 +1,51 @@ +/* -*- C -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterSocket.h + * + * $Id$ + * + * @brief this header encapsulates internet and UNIX domain socket + * communication + * + * @author Friedhelm Wolf + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_PARAMETER_SOCKET_H_ +#define _FAPI_ACYCLIC_PARAMETER_SOCKET_H_ + +#include /**/ + +#ifdef ACE_LACKS_UNIX_DOMAIN_SOCKETS + +#include /**/ +#include /**/ + +#define FAPIA_HAS_NETWORK_SOCKETS + +#define FAPIA_STREAM ACE_SOCK_STREAM +#define FAPIA_ACCEPTOR ACE_SOCK_ACCEPTOR + +typedef ACE_INET_Addr FAPIA_Addr; +typedef ACE_SOCK_Stream FAPIA_Stream; +typedef ACE_SOCK_Acceptor FAPIA_Acceptor; +typedef ACE_SOCK_Connector FAPIA_Connector; + +#else + +#include /**/ +#include /**/ + +#define FAPIA_STREAM ACE_LSOCK_STREAM +#define FAPIA_ACCEPTOR ACE_LSOCK_ACCEPTOR + +typedef ACE_UNIX_Addr FAPIA_Addr; +typedef ACE_LSOCK_Stream FAPIA_Stream; +typedef ACE_LSOCK_Acceptor FAPIA_Acceptor; +typedef ACE_LSOCK_Connector FAPIA_Connector; + +#endif + +#endif /* _FAPI_ACYCLIC_PARAMETER_SOCKET_H_ */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterStreaming.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterStreaming.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,237 @@ +// $Id$ + +#include "FAPIAIPCParameterStreaming.h" + +/*---------------------------------------------------------------------------*/ + +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os, + const FAPI::Acyclic::IPC::Parameter::Parameter &p) +{ + return os << "parameter [" << p.parameter_name_.c_str () << "]"; +} + +/*---------------------------------------------------------------------------*/ + +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os, + const FAPI::Acyclic::IPC::Parameter::Parameters &p) +{ + os << "parameters ("; + for (size_t i = 0; i < p.size (); i++) + { + os << p[i] << ", "; + } + + return os << ")"; +} + +/*---------------------------------------------------------------------------*/ + +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os, + const FAPI::Acyclic::IPC::Parameter::Communication &c) +{ + return os << "communication [id=" << c.transaction_id_ + << ", logical_name=" << c.logical_object_name_.c_str () + << ", obj_name=" << c.source_physical_object_name_.c_str () + << ", send_reply=" << c.send_reply_ << "]"; +} + +/*---------------------------------------------------------------------------*/ + +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os, + const FAPI::Acyclic::IPC::Parameter::Value &v) +{ + os << "value [type=" << v.data_type_ << ", len=" << v.data_len (); + + if (v.data_len () > 0) + os << ", data=" << static_cast (v.data_value ())[0]; + + if (v.data_len () > 1) + os << static_cast (v.data_value ())[1]; + + if (v.data_len () > 2) + os << static_cast (v.data_value ())[2]; + + if (v.data_len () > 3) + os << static_cast (v.data_value ())[3]; + + return os << "]"; +} + +/*---------------------------------------------------------------------------*/ + +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os, + const FAPI::Acyclic::IPC::Parameter::Values &v) +{ + os << "values ("; + for (size_t i = 0; i < v.size (); i++) + { + os << v[i] << ", "; + } + + return os << ")"; +} + +/*---------------------------------------------------------------------------*/ + +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os, + const FAPI::Acyclic::IPC::Parameter::Info &v) +{ + os << "info [type=" << v.data_type_ << ", len=" << v.data_len_; + + if (v.unit_.length () > 0) + os << ", unit=" << v.unit_.c_str (); + + return os << "]"; +} + +/*---------------------------------------------------------------------------*/ + +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os, + const FAPI::Acyclic::IPC::Parameter::Infos &v) +{ + os << "infos ("; + for (size_t i = 0; i < v.size (); i++) + { + os << v[i] << ", "; + } + + return os << ")"; +} + +/*---------------------------------------------------------------------------*/ + +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os, + const FAPI::Acyclic::IPC::Parameter::Error &e) +{ + ACE_CString e_code; + + switch (e.error_code_) + { + case FAPIA_ERROR_OK: + e_code = "FAPIA_ERROR_OK"; break; + case FAPIA_ERROR_COMMUNICATION: + e_code = "FAPIA_ERROR_COMMUNICATION"; break; + case FAPIA_ERROR_OBJECT_NOT_FOUND: + e_code = "FAPIA_ERROR_OBJECT_NOT_FOUND"; break; + case FAPIA_ERROR_PARAMETER_NOT_FOUND: + e_code = "FAPIA_ERROR_PARAMETER_NOT_FOUND"; break; + case FAPIA_ERROR_CONFIG_PARSE_ERROR: + e_code = "FAPIA_ERROR_CONFIG_PARSE_ERROR"; break; + case FAPIA_ERROR_DESTINATION_NOT_ONLINE: + e_code = "FAPIA_ERROR_DESTINATION_NOT_ONLINE"; break; + case FAPIA_ERROR_CONFIG_HAS_WRONG_FORMAT: + e_code = "FAPIA_ERROR_CONFIG_HAS_WRONG_FORMAT"; break; + default: + e_code = "UNKOWN"; + } + + return os << "error [code=" << e_code.c_str () + << ", reason=" << e.reason_.c_str () + << "]"; +} + +/*---------------------------------------------------------------------------*/ + +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os, + const FAPI::Acyclic::IPC::Parameter::Errors &e) +{ + os << "errors ("; + for (size_t i = 0; i < e.size (); i++) + { + os << e[i] << ", "; + } + + return os << ")"; +} + +/*---------------------------------------------------------------------------*/ + +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestReadRequest &rr) +{ + return os << "ReadRequest {" << endl + << "\t" << "prio=" << rr.priority () << endl + << "\t" << "dest=" << rr.destination_physical_object_address_ + << endl << "\t" << rr.communication_ + << endl << "\t" << rr.parameters_ + << endl << "}" << endl; +} + +/*---------------------------------------------------------------------------*/ + +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestReadResponse &rr) +{ + return os << "ReadResponse {" << endl + << "\t" << "prio=" << rr.priority () << endl + << "\t" << "dest=" << rr.destination_physical_object_address_ + << endl << "\t" << rr.communication_ + << endl << "\t" << rr.parameters_ + << endl << "\t" << rr.values_ + << endl << "\t" << rr.errors_ + << endl << "}" << endl; +} + +/*---------------------------------------------------------------------------*/ + +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestWriteRequest &wr) +{ + return os << "WriteRequest {" << endl + << "\t" << "prio=" << wr.priority () << endl + << "\t" << "dest=" << wr.destination_physical_object_address_ + << endl << "\t" << wr.communication_ + << endl << "\t" << wr.parameters_ + << endl << "\t" << wr.values_ + << endl << "}" << endl; +} + +/*---------------------------------------------------------------------------*/ + +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestWriteResponse &wr) +{ + return os << "WriteResponse {" << endl + << "\t" << "prio=" << wr.priority () << endl + << "\t" << "dest=" << wr.destination_physical_object_address_ + << endl << "\t" << wr.communication_ + << endl << "\t" << wr.parameters_ + << endl << "\t" << wr.errors_ + << endl << "}" << endl; +} + +/*---------------------------------------------------------------------------*/ + +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestInfoRequest &wr) +{ + return os << "InfoRequest {" << endl + << "\t" << "prio=" << wr.priority () << endl + << "\t" << "dest=" << wr.destination_physical_object_address_ + << endl << "\t" << wr.communication_ + << endl << "\t" << wr.parameters_ + << endl << "}" << endl; +} + +/*---------------------------------------------------------------------------*/ + +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &os, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestInfoResponse &wr) +{ + return os << "InfoResponse {" << endl + << "\t" << "prio=" << wr.priority () << endl + << "\t" << "dest=" << wr.destination_physical_object_address_ + << endl << "\t" << wr.communication_ + << endl << "\t" << wr.parameters_ + << endl << "\t" << wr.infos_ + << endl << "\t" << wr.errors_ + << endl << "}" << endl; +} + +/*---------------------------------------------------------------------------*/ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterStreaming.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterStreaming.h Thu Jul 19 07:15:27 2007 @@ -0,0 +1,132 @@ +/* -*- C -*- */ + +//============================================================================= +/** + * @file FAPIAIPCParameterStreaming.h + * + * $Id$ + * + * @author Friedhelm Wolf + */ +//============================================================================= + + +#ifndef _FAPI_ACYCLIC_PARAMETER_STREAMING_H_ +#define _FAPI_ACYCLIC_PARAMETER_STREAMING_H_ + + +#include +#include +#include +#include + +#include \ + +#include \ + +#include \ + +#include \ + +#include \ + +#include \ + + +/** + * @brief output streaming operator for the Parameter class + */ +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &, + const FAPI::Acyclic::IPC::Parameter::Parameter &); + +/** + * @brief output streaming operator for the Parameters vector + */ +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &, + const FAPI::Acyclic::IPC::Parameter::Parameters &); + +/** + * @brief output streaming operator for the Communication class + */ +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &, + const FAPI::Acyclic::IPC::Parameter::Communication &); + +/** + * @brief output streaming operator for the Value class + */ +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &, + const FAPI::Acyclic::IPC::Parameter::Value &); + +/** + * @brief output streaming operator for the Value class + */ +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &, + const FAPI::Acyclic::IPC::Parameter::Values &); + +/** + * @brief output streaming operator for the Info class + */ +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &, + const FAPI::Acyclic::IPC::Parameter::Info &); + +/** + * @brief output streaming operator for the Info class + */ +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &, + const FAPI::Acyclic::IPC::Parameter::Infos &); + +/** + * @brief output streaming operator for the Error class + */ +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &, + const FAPI::Acyclic::IPC::Parameter::Error &); + +/** + * @brief output streaming operator for the Error class + */ +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &, + const FAPI::Acyclic::IPC::Parameter::Errors &); + +/** + * @brief output streaming operator for the MethodRequestReadRequest class + */ +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestReadRequest &); + +/** + * @brief output streaming operator for the MethodRequestReadResponse class + */ +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestReadResponse &); + +/** + * @brief output streaming operator for the MethodRequestWriteRequest class + */ +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestWriteRequest &); + +/** + * @brief output streaming operator for the MethodRequestWriteResponse class. + */ +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestWriteResponse &); + +/** + * @brief output streaming operator for the MethodRequestInfoRequest class + */ +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestInfoRequest &); + +/** + * @brief output streaming operator for the MethodRequestInfoResponse class. + */ +ACE_OSTREAM_TYPE &operator<< (ACE_OSTREAM_TYPE &, + const FAPI::Acyclic::IPC::Parameter:: \ + MethodRequestInfoResponse &); + +#endif /* _FAPI_ACYCLIC_PARAMETER_STREAMING_H_ */ Added: fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterValue.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/source/FAPIAIPCParameterValue.cpp Thu Jul 19 07:15:27 2007 @@ -0,0 +1,158 @@ +// $Id$ + + +#include "FAPIAIPCParameterValue.h" +#include "FAPIATrace.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + +/*---------------------------------------------------------------------------*/ + + Value::Value (void) + { + open (); + } + +/*---------------------------------------------------------------------------*/ + + Value::Value (const Value& value) + { + open (); + copy (value); + } + +/*---------------------------------------------------------------------------*/ + + const Value& Value::operator= (const Value& value) + { + if (this != &value) + { + close (); + copy (value); + } + + return *this; + } + +/*---------------------------------------------------------------------------*/ + + Value::~Value (void) + { + close (); + } + +/*---------------------------------------------------------------------------*/ + + bool Value::operator!= (const Value& value) const + { + return ((this->data_type_ != value.data_type_) || + (this->data_len_ != value.data_len_) || + (ACE_OS::memcmp (this->data_value_, + value.data_value_, + value.data_len_)) + ); + } + +/*---------------------------------------------------------------------------*/ + + unsigned long Value::data_len (void) const + { + return this->data_len_; + } + +/*---------------------------------------------------------------------------*/ + + const void* Value::data_value (void) const + { + return this->data_value_; + } + +/*---------------------------------------------------------------------------*/ + + long Value::data_value (const void* const value, + unsigned long len) + { + // delete previous value if necessary + if (this->data_value_ != NULL) + { + delete[] ACE_static_cast (u_char*, this->data_value_); + this->data_value_ = NULL; + this->data_len_ = 0; + } + + // allocate memory for the value. + ACE_NEW_NORETURN (this->data_value_, char[len]); + if (this->data_value_ == NULL) + { + FAPIA_DEBUG (LM_CRITICAL, + "insufficient memory for heap allocation"); + return -1; + } + + // copy content + ACE_OS::memcpy (this->data_value_, value, len); + + this->data_len_ = len; + + return 0; + } + +/*---------------------------------------------------------------------------*/ + + void Value::open (void) + { + this->data_type_ = FAPIA_DATA_TYPE_UNS08; + this->data_len_ = 0; + this->data_value_ = NULL; + } + +/*---------------------------------------------------------------------------*/ + + void Value::copy (const Value& value) + { + unsigned long len = value.data_len (); + + // allocate memory for the value. + ACE_NEW_NORETURN (this->data_value_, char[len]); + if (this->data_value_ == NULL) + { + FAPIA_DEBUG (LM_CRITICAL, + "insufficient memory for heap allocation"); + return; + } + + // copy content + ACE_OS::memcpy (this->data_value_, + value.data_value (), + len); + + this->data_len_ = len; + this->data_type_ = value.data_type_; + } + +/*---------------------------------------------------------------------------*/ + + void Value::close (void) + { + this->data_type_ = FAPIA_DATA_TYPE_UNS08; + this->data_len_ = 0; + if (this->data_value_ != NULL) + { + delete[] ACE_static_cast (u_char*, this->data_value_); + this->data_value_ = NULL; + } + } + +/*---------------------------------------------------------------------------*/ + + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:46:51 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:46:51 +0200 Subject: [OSADL-svn-commits] r87 - in fapia-trunk/FAPIAIPCParameter/test: . communication communication/make communication/make/MPC communication/source concepts concepts/make concepts/make/MPC concepts/source marshalling marshalling/make marshalling/make/MPC marshalling/source source Message-ID: <200710020946.l929kpBk021265@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:18:07 2007 New Revision: 87 Log: Added: fapia-trunk/FAPIAIPCParameter/test/ fapia-trunk/FAPIAIPCParameter/test/communication/ fapia-trunk/FAPIAIPCParameter/test/communication/make/ fapia-trunk/FAPIAIPCParameter/test/communication/make/MPC/ fapia-trunk/FAPIAIPCParameter/test/communication/make/MPC/testcommunication.mpc fapia-trunk/FAPIAIPCParameter/test/communication/make/MPC/testcommunication.mwc fapia-trunk/FAPIAIPCParameter/test/communication/make/makefile fapia-trunk/FAPIAIPCParameter/test/communication/makeall.bat fapia-trunk/FAPIAIPCParameter/test/communication/makefile fapia-trunk/FAPIAIPCParameter/test/communication/source/ fapia-trunk/FAPIAIPCParameter/test/communication/source/testcommunication.cpp fapia-trunk/FAPIAIPCParameter/test/concepts/ fapia-trunk/FAPIAIPCParameter/test/concepts/make/ fapia-trunk/FAPIAIPCParameter/test/concepts/make/MPC/ fapia-trunk/FAPIAIPCParameter/test/concepts/make/MPC/concepts.mpc fapia-trunk/FAPIAIPCParameter/test/concepts/make/MPC/concepts.mwc fapia-trunk/FAPIAIPCParameter/test/concepts/make/MPC/parameter_client.mpc fapia-trunk/FAPIAIPCParameter/test/concepts/make/MPC/parameter_server.mpc fapia-trunk/FAPIAIPCParameter/test/concepts/make/makefile fapia-trunk/FAPIAIPCParameter/test/concepts/makeall.bat fapia-trunk/FAPIAIPCParameter/test/concepts/makefile fapia-trunk/FAPIAIPCParameter/test/concepts/source/ fapia-trunk/FAPIAIPCParameter/test/concepts/source/parameter_client.cpp fapia-trunk/FAPIAIPCParameter/test/concepts/source/parameter_handler.cpp fapia-trunk/FAPIAIPCParameter/test/concepts/source/parameter_handler.h fapia-trunk/FAPIAIPCParameter/test/concepts/source/parameter_server.cpp fapia-trunk/FAPIAIPCParameter/test/concepts/source/reply_handler.cpp fapia-trunk/FAPIAIPCParameter/test/concepts/source/reply_handler.h fapia-trunk/FAPIAIPCParameter/test/marshalling/ fapia-trunk/FAPIAIPCParameter/test/marshalling/make/ fapia-trunk/FAPIAIPCParameter/test/marshalling/make/MPC/ fapia-trunk/FAPIAIPCParameter/test/marshalling/make/MPC/testmarshalling.mpc fapia-trunk/FAPIAIPCParameter/test/marshalling/make/MPC/testmarshalling.mwc fapia-trunk/FAPIAIPCParameter/test/marshalling/make/makefile fapia-trunk/FAPIAIPCParameter/test/marshalling/makeall.bat fapia-trunk/FAPIAIPCParameter/test/marshalling/makefile fapia-trunk/FAPIAIPCParameter/test/marshalling/source/ fapia-trunk/FAPIAIPCParameter/test/marshalling/source/marshallingtest.cpp fapia-trunk/FAPIAIPCParameter/test/marshalling/source/marshallingtest.h fapia-trunk/FAPIAIPCParameter/test/marshalling/source/testmarshalling.cpp fapia-trunk/FAPIAIPCParameter/test/source/ fapia-trunk/FAPIAIPCParameter/test/source/marshallingdata.cpp fapia-trunk/FAPIAIPCParameter/test/source/marshallingdata.h Added: fapia-trunk/FAPIAIPCParameter/test/communication/make/MPC/testcommunication.mpc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/communication/make/MPC/testcommunication.mpc Thu Jul 19 07:18:07 2007 @@ -0,0 +1,14 @@ +project (testcommunication) : FAPIAIPCParameterlocalcomponentsexe, cppunitcomponentsexe { + + exename = testcommunication + + includes += ../../../source ../../../../source + + source_files { + ../../source/testcommunication.cpp + } + + header_files { + } + +} \ No newline at end of file Added: fapia-trunk/FAPIAIPCParameter/test/communication/make/MPC/testcommunication.mwc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/communication/make/MPC/testcommunication.mwc Thu Jul 19 07:18:07 2007 @@ -0,0 +1,3 @@ +workspace (testcommunication) { + testcommunication.mpc +} \ No newline at end of file Added: fapia-trunk/FAPIAIPCParameter/test/communication/make/makefile ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/communication/make/makefile Thu Jul 19 07:18:07 2007 @@ -0,0 +1,24 @@ +MODULE=testcommunication + +TYPES:= VC8_STATIC Automake + +NMAKE_STATIC_CFG="Static_Multi_Unicode_Debug_StaticRTL" "Static_Multi_Unicode_Release_StaticRTL" +NMAKE_DLL_CFG= +GNU_LINUX_CFG = "Debug" "Release" + +MPC_DIRS := $(VIEW_ROOT)/DevTools_vob/cppunit/make/MPC/config $(VIEW_ROOT)/IOFramework_vob/FAPIA/make/MPC/config $(VIEW_ROOT)/ACE_Wrappers_vob/ACE_wrappers/make/MPC/config + +ALL: MPC BUILD + +BUILD: BUILD_ALL + +CLEAN: CLEAN_BUILD CLEAN_MPC + +REALCLEAN: REALCLEAN_BUILD CLEAN_MPC + +EXPORT: EXPORT_ALL + +%include <.homag_make_rules> +%include <.homag_mpc_make_rules> +%include <.homag_build_make_rules> +%include <.homag_export_make_rules> Added: fapia-trunk/FAPIAIPCParameter/test/communication/makeall.bat ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/communication/makeall.bat Thu Jul 19 07:18:07 2007 @@ -0,0 +1,2 @@ +set ARP_Tools=%cd%\..\..\..\..\..\DevTools_vob\ARP-Tools +ccperl %arp_tools%\mk.pl %* \ No newline at end of file Added: fapia-trunk/FAPIAIPCParameter/test/communication/makefile ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/communication/makefile Thu Jul 19 07:18:07 2007 @@ -0,0 +1,10 @@ +SPEC = * +MODULE_DIRS= $(SPEC,*D) +MODULE_DIRS = ./make + + +ALL: $(MODULE_DIRS) $(MAKETARGETS) + %echo ALL_SOURCES $(.SOURCES) + +%include <.homag_make_rules> +%include <.homag_release_make_rules> Added: fapia-trunk/FAPIAIPCParameter/test/communication/source/testcommunication.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/communication/source/testcommunication.cpp Thu Jul 19 07:18:07 2007 @@ -0,0 +1,87 @@ +#include "FAPIAIPCParameterSenderService.h" +#include "FAPIAIPCParameterReceiverTask.h" +#include "FAPIAIPCParameterMethodRequestReadRequest.h" +#include "FAPIAIPCParameterStreaming.h" +#include "FAPIATrace.h" + +#include +#include + +using namespace FAPI::Acyclic::IPC::Parameter; + +int main (int argc, char* argv[]) +{ + FAPIA_TRACE; + + ACE::init (); +#ifdef _DEBUG + ACE_LOG_MSG->priority_mask (LM_INFO|LM_DEBUG|LM_ERROR|LM_WARNING, + ACE_Log_Msg::PROCESS); +#else + ACE_LOG_MSG->priority_mask (LM_ERROR|LM_WARNING, ACE_Log_Msg::PROCESS); +#endif /* _DEBUG */ + + ACE_Activation_Queue send_queue; + ACE_Activation_Queue receive_queue; + + ReceiverTask receiver (&receive_queue); + receiver.activate (); + + SenderService sender; + sender.send_queue (&send_queue); + sender.receive_queue (&receive_queue); + + sender.activate (); + + // enqueue MethodRequest + Parameter p; + p.parameter_name_ = "special parameter"; + + MethodRequestReadRequest* request = new MethodRequestReadRequest (); + request->destination_physical_object_address_ = receiver.listen_addr (); + request->priority (2); + request->communication_.communication_error_.error_code_ = FAPIA_ERROR_OK; + request->communication_.send_reply_ = false; + request->communication_.logical_object_name_ = "testparameterobject"; + request->communication_.source_physical_object_name_ = "TestObject"; + request->communication_.transaction_id_ = 4398; + request->parameters_.push_back (p); + + std::stringstream ss; + ss << "request = " << *request << endl; + FAPIA_DEBUG (LM_DEBUG, "%s", ss.str ().c_str ()); + + clock_t end_ticks; + clock_t start_ticks = clock (); + send_queue.enqueue (request); + MethodRequestReadRequest* result = + ACE_dynamic_cast (MethodRequestReadRequest*, receive_queue.dequeue ()); + end_ticks = ::clock (); + + if (result == NULL) + { + FAPIA_DEBUG (LM_ERROR, + "Method request did not get into the receive queue correctly!"); + } + else + { + if (*request != *result) + { + FAPIA_DEBUG (LM_ERROR, + "data content was not delivered correctly!"); + + std::stringstream rss; + rss << "result = " << *result << endl; + FAPIA_DEBUG (LM_DEBUG, "%s", rss.str ().c_str ()); + } + } + + sender.shutdown (); + receiver.shutdown (); + + FAPIA_DEBUG (LM_INFO, "SENDTIME: %d ticks\n", start_ticks); + FAPIA_DEBUG (LM_INFO, "RECVTIME: %d ticks\n", end_ticks); + FAPIA_DEBUG (LM_INFO, "difference : %d ticks with %d ticks per second", end_ticks - start_ticks, CLOCKS_PER_SEC); + + return 0; +} Added: fapia-trunk/FAPIAIPCParameter/test/concepts/make/MPC/concepts.mpc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/concepts/make/MPC/concepts.mpc Thu Jul 19 07:18:07 2007 @@ -0,0 +1,15 @@ +project (concepts) : FAPIAIPCParameterlocalcomponentsexe { + + exename = testfapiaconcepts + + macros += ACE_NTRACE=0 + + source_files { + ../../source/test_fapia_concepts.cpp + ../../../source/marshallingdata.cpp + } + + header_files { + ../../../source/marshallingdata.h + } +} \ No newline at end of file Added: fapia-trunk/FAPIAIPCParameter/test/concepts/make/MPC/concepts.mwc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/concepts/make/MPC/concepts.mwc Thu Jul 19 07:18:07 2007 @@ -0,0 +1,5 @@ +workspace (concepts) { + //concepts.mpc + parameter_server.mpc + parameter_client.mpc +} \ No newline at end of file Added: fapia-trunk/FAPIAIPCParameter/test/concepts/make/MPC/parameter_client.mpc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/concepts/make/MPC/parameter_client.mpc Thu Jul 19 07:18:07 2007 @@ -0,0 +1,13 @@ +project (parameter_client) : FAPIAIPCParameterlocalcomponentsexe { + + exename = paramclient + + source_files { + ../../source/parameter_client.cpp + ../../../source/marshallingdata.cpp + } + + header_files { + ../../../source/marshallingdata.h + } +} \ No newline at end of file Added: fapia-trunk/FAPIAIPCParameter/test/concepts/make/MPC/parameter_server.mpc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/concepts/make/MPC/parameter_server.mpc Thu Jul 19 07:18:07 2007 @@ -0,0 +1,17 @@ +project (parameter_server) : FAPIAIPCParameterlocalcomponentsexe { + + exename = paramserv + + source_files { + ../../source/parameter_server.cpp + ../../source/parameter_handler.cpp + ../../source/reply_handler.cpp + ../../../source/marshallingdata.cpp + } + + header_files { + ../../source/parameter_handler.h + ../../source/reply_handler.h + ../../../source/marshallingdata.h + } +} \ No newline at end of file Added: fapia-trunk/FAPIAIPCParameter/test/concepts/make/makefile ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/concepts/make/makefile Thu Jul 19 07:18:07 2007 @@ -0,0 +1,24 @@ +MODULE=concepts + +TYPES:= VC8 VC8_STATIC Automake + +NMAKE_STATIC_CFG="Static_Multi_Unicode_Debug_StaticRTL" "Static_Multi_Unicode_Release_StaticRTL" +NMAKE_DLL_CFG= +GNU_LINUX_CFG = "Debug" "Release" + +MPC_DIRS := $(VIEW_ROOT)/IOFramework_vob/FAPIA/make/MPC/config $(VIEW_ROOT)/DevTools_vob/MPC/config $(VIEW_ROOT)/ACE_wrappers_vob/ACE_wrappers/make/MPC/config + +ALL: MPC BUILD + +BUILD: BUILD_ALL + +CLEAN: CLEAN_BUILD CLEAN_MPC + +REALCLEAN: REALCLEAN_BUILD CLEAN_MPC + +EXPORT: EXPORT_ALL + +%include <.homag_make_rules> +%include <.homag_mpc_make_rules> +%include <.homag_build_make_rules> +%include <.homag_export_make_rules> Added: fapia-trunk/FAPIAIPCParameter/test/concepts/makeall.bat ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/concepts/makeall.bat Thu Jul 19 07:18:07 2007 @@ -0,0 +1,2 @@ +set ARP_Tools=%cd%\..\..\..\..\..\DevTools_vob\ARP-Tools +ccperl %arp_tools%\mk.pl %* \ No newline at end of file Added: fapia-trunk/FAPIAIPCParameter/test/concepts/makefile ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/concepts/makefile Thu Jul 19 07:18:07 2007 @@ -0,0 +1,10 @@ +SPEC = * +MODULE_DIRS= $(SPEC,*D) +MODULE_DIRS = ./make + + +ALL: $(MODULE_DIRS) $(MAKETARGETS) + %echo ALL_SOURCES $(.SOURCES) + +%include <.homag_make_rules> +%include <.homag_release_make_rules> Added: fapia-trunk/FAPIAIPCParameter/test/concepts/source/parameter_client.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/concepts/source/parameter_client.cpp Thu Jul 19 07:18:07 2007 @@ -0,0 +1,173 @@ +#ifdef _DEBUG +//#define ACE_NTRACE 0 +#endif + +#include +#include +#include +#include +#include + +int main (int argc, char* argv[]) +{ + FAPIA_TRACE; + + const char *server_host = argc > 1 ? argv[1] : ACE_DEFAULT_SERVER_HOST; + int server_port = argc > 2 ? ACE_OS::atoi (argv[2]) : ACE_DEFAULT_SERVER_PORT; + + ACE_SOCK_Stream server; + ACE_SOCK_Connector connector; + ACE_INET_Addr addr (ACE_static_cast (u_short,server_port), + server_host); + + if (connector.connect (server, addr) == -1) + { + ACE_TCHAR buffer[255]; + addr.addr_to_string (buffer, 255); + FAPIA_DEBUG (LM_ERROR, "could not connect to address %s\n", buffer); + return -1; + } + + FAPI::Acyclic::IPC::Parameter::Test::init_data (); + + cout << "choose the request to send :\n\t[1] ReadRequest\n\t[2] ReadResponse" + << "\n\t[3] WriteRequest\n\t[4] WriteResponse\n\t[q] exit" << endl; + + char c; + while (cin >> c) + { + switch (c) + { + case '1': + { + cout << endl << "sending " << g_read_request << endl; + + // get necessary length for the buffer + unsigned long payload_size = 0; + payload_size += g_read_request; + ACE_OutputCDR payload (payload_size); + + // put data into the buffer + payload << g_read_request; + ACE_CDR::ULong length = payload.total_length (); + + ACE_OutputCDR header (ACE_CDR::MAX_ALIGNMENT + FAPIA_HEADER_SIZE); + header << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER); + header << ACE_CDR::ULong (length); + header << ACE_CDR::ULong (FAPI::Acyclic::IPC::Parameter::FAPIA_READ_REQUEST); + + iovec iov[2]; + iov[0].iov_base = header.begin ()->rd_ptr (); + iov[0].iov_len = FAPIA_HEADER_SIZE; + iov[1].iov_base = payload.begin ()->rd_ptr (); + iov[1].iov_len = length; + + if ( server.sendv_n (iov, 2) <= 0) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Could not send data!\n"))); + return 1; + } + break; + } + case '2': + { + cout << endl << "sending " << g_read_response << endl; + + // get necessary length for the buffer + unsigned long payload_size = 0; + payload_size += g_read_response; + ACE_OutputCDR payload (payload_size); + + // put data into the buffer + payload << g_read_response; + ACE_CDR::ULong length = payload.total_length (); + + ACE_OutputCDR header (ACE_CDR::MAX_ALIGNMENT + FAPIA_HEADER_SIZE); + header << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER); + header << ACE_CDR::ULong (length); + header << ACE_CDR::ULong (FAPI::Acyclic::IPC::Parameter::FAPIA_READ_RESPONSE); + + iovec iov[2]; + iov[0].iov_base = header.begin ()->rd_ptr (); + iov[0].iov_len = FAPIA_HEADER_SIZE; + iov[1].iov_base = payload.begin ()->rd_ptr (); + iov[1].iov_len = length; + + if ( server.sendv_n (iov, 2) <= 0) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Could not send data!\n"))); + return 1; + } + break; + } + case '3': + { + cout << endl << "sending " << g_write_request << endl; + + // get necessary length for the buffer + unsigned long payload_size = 0; + payload_size += g_write_request; + ACE_OutputCDR payload (payload_size); + + // put data into the buffer + payload << g_write_request; + ACE_CDR::ULong length = payload.total_length (); + + ACE_OutputCDR header (ACE_CDR::MAX_ALIGNMENT + FAPIA_HEADER_SIZE); + header << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER); + header << ACE_CDR::ULong (length); + header << ACE_CDR::ULong (FAPI::Acyclic::IPC::Parameter::FAPIA_WRITE_REQUEST); + + iovec iov[2]; + iov[0].iov_base = header.begin ()->rd_ptr (); + iov[0].iov_len = FAPIA_HEADER_SIZE; + iov[1].iov_base = payload.begin ()->rd_ptr (); + iov[1].iov_len = length; + + if ( server.sendv_n (iov, 2) <= 0) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Could not send data!\n"))); + return 1; + } + break; + } + case '4': + { + cout << endl << "sending " << g_write_response << endl; + + // get necessary length for the buffer + unsigned long payload_size = 0; + payload_size += g_write_response; + ACE_OutputCDR payload (payload_size); + + // put data into the buffer + payload << g_write_response; + ACE_CDR::ULong length = payload.total_length (); + + ACE_OutputCDR header (ACE_CDR::MAX_ALIGNMENT + FAPIA_HEADER_SIZE); + header << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER); + header << ACE_CDR::ULong (length); + header << ACE_CDR::ULong (FAPI::Acyclic::IPC::Parameter::FAPIA_WRITE_RESPONSE); + + iovec iov[2]; + iov[0].iov_base = header.begin ()->rd_ptr (); + iov[0].iov_len = FAPIA_HEADER_SIZE; + iov[1].iov_base = payload.begin ()->rd_ptr (); + iov[1].iov_len = length; + + if ( server.sendv_n (iov, 2) <= 0) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Could not send data!\n"))); + return 1; + } + break; + } + case 'q': + default: + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("finished.\n"))); + return 0; + } + } + + return 0; +} Added: fapia-trunk/FAPIAIPCParameter/test/concepts/source/parameter_handler.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/concepts/source/parameter_handler.cpp Thu Jul 19 07:18:07 2007 @@ -0,0 +1,271 @@ +#include "parameter_handler.h" + +#include "FAPIATrace.h" +#include +#include + +#include +#include + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + namespace Test + { + +/*---------------------------------------------------------------------------*/ + +ParameterHandler::ParameterHandler (void) +{ + FAPIA_TRACE; + queue_ = NULL; +} + +/*---------------------------------------------------------------------------*/ + +ParameterHandler::~ParameterHandler (void) +{ + FAPIA_TRACE; + + ACE_Reactor::end_event_loop (); +} + +/*---------------------------------------------------------------------------*/ + +int ParameterHandler::open (void *) +{ + FAPIA_TRACE; + + if (this->queue_ == NULL) + { + FAPIA_DEBUG (LM_ERROR, "parameter handler queue not initialized."); + return -1; + } + + if (this->reactor ()->register_handler (this, + ACE_Svc_Handler::READ_MASK) == 1) + { + FAPIA_DEBUG (LM_ERROR, "could not register parameter handler"); + return -1; + } + + return 0; +} + +/*---------------------------------------------------------------------------*/ + +int ParameterHandler::handle_input (ACE_HANDLE) +{ + FAPIA_TRACE; + + ACE_Message_Block *header_data = + new ACE_Message_Block (ACE_DEFAULT_CDR_BUFSIZE); + ACE_CDR::mb_align (header_data); + + if (this->peer ().recv_n (header_data->wr_ptr (), FAPIA_HEADER_SIZE) == + FAPIA_HEADER_SIZE) + { + header_data->wr_ptr (FAPIA_HEADER_SIZE); + + ACE_InputCDR header_cdr (header_data); + + ACE_CDR::Boolean byte_order; + header_cdr >> ACE_InputCDR::to_boolean (byte_order); + header_cdr.reset_byte_order (byte_order); + + ACE_CDR::ULong data_length; + header_cdr >> data_length; + + ACE_CDR::ULong method_request_val; + header_cdr >> method_request_val; + FAPI::Acyclic::IPC::Parameter::MethodRequestType method_request_type = + ACE_static_cast (FAPI::Acyclic::IPC::Parameter::MethodRequestType, + method_request_val); + + ACE_Message_Block *request_data = + new ACE_Message_Block (data_length); + ACE_CDR::mb_align (request_data); + + if (this->peer ().recv_n (request_data->wr_ptr (), data_length) == (long)data_length) + { + request_data->wr_ptr (data_length); + ACE_InputCDR request_cdr (request_data); + + switch (method_request_type) + { + case FAPIA_READ_REQUEST: + { + FAPI::Acyclic::IPC::Parameter::MethodRequestReadRequest* + read_request = new FAPI::Acyclic::IPC::Parameter:: + MethodRequestReadRequest; + + if ((request_cdr >> *read_request) && + !(*read_request != g_read_request)) + { + cout << "enqueue " << *read_request << endl; + queue_->enqueue (read_request); + } + else + { + ACE_ERROR ((LM_DEBUG, + ACE_TEXT("ReadRequest was not received correctly"))); + header_data->release (); + header_data = NULL; + request_data->release (); + request_data = NULL; + return -1; + } + + break; + } + case FAPIA_READ_RESPONSE: + { + FAPI::Acyclic::IPC::Parameter::MethodRequestReadResponse* + read_response = new FAPI::Acyclic::IPC::Parameter:: + MethodRequestReadResponse; + + if ((request_cdr >> *read_response) && + !(*read_response != g_read_response)) + { + cout << "enqueue " << *read_response << endl; + queue_->enqueue (read_response); + } + else + { + ACE_ERROR ((LM_DEBUG, + ACE_TEXT("ReadResponse was not received correctly"))); + header_data->release (); + header_data = NULL; + request_data->release (); + request_data = NULL; + return -1; + } + + break; + } + case FAPIA_WRITE_REQUEST: + { + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteRequest* + write_request = new FAPI::Acyclic::IPC::Parameter:: + MethodRequestWriteRequest; + + if ((request_cdr >> *write_request) && + !(*write_request != g_write_request)) + { + cout << "enqueue " << *write_request << endl; + queue_->enqueue (write_request); + } + else + { + ACE_ERROR ((LM_DEBUG, + ACE_TEXT("WriteRequest was not received correctly"))); + header_data->release (); + header_data = NULL; + request_data->release (); + request_data = NULL; + return -1; + } + + break; + } + case FAPIA_WRITE_RESPONSE: + { + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteResponse* + write_response = new FAPI::Acyclic::IPC::Parameter:: + MethodRequestWriteResponse; + + if ((request_cdr >> *write_response) && + !(*write_response != g_write_response)) + { + cout << "enqueue " << *write_response << endl; + queue_->enqueue (write_response); + } + else + { + ACE_ERROR ((LM_DEBUG, + ACE_TEXT("WriteResponse was not received correctly"))); + header_data->release (); + header_data = NULL; + request_data->release (); + request_data = NULL; + return -1; + } + + break; + } + default: + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT("unkown method request type revieved.\n"))); + header_data->release (); + header_data = NULL; + request_data->release (); + request_data = NULL; + return -1; + } + } + + header_data->release (); + header_data = NULL; + return data_length + FAPIA_HEADER_SIZE; + } + } + + header_data->release (); + header_data = NULL; + return 0; +} + +/*---------------------------------------------------------------------------*/ + +Parameter_Acceptor::Parameter_Acceptor (ACE_Activation_Queue* q) +: queue_ (q) +{ +} + +/*---------------------------------------------------------------------------*/ + +Parameter_Acceptor::~Parameter_Acceptor (void) +{ +} + +/*---------------------------------------------------------------------------*/ + +int Parameter_Acceptor::accept_svc_handler (ParameterHandler* svc_handler) +{ + svc_handler->queue (this->queue_); + + // Try to find out if the implementation of the reactor that we are + // using requires us to reset the event association for the newly + // created handle. This is because the newly created handle will + // inherit the properties of the listen handle, including its event + // associations. + int reset_new_handle = this->reactor ()->uses_event_associations (); + + if (this->acceptor ().accept (svc_handler->peer (), // stream + 0, // remote address + 0, // timeout + 1, // restart + reset_new_handle // reset new handler + ) == -1) + { + // Close down handler to avoid memory leaks. + svc_handler->close (0); + + return -1; + } + else + return 0; +} + +/*---------------------------------------------------------------------------*/ + + } /* namespace Test */ + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/test/concepts/source/parameter_handler.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/concepts/source/parameter_handler.h Thu Jul 19 07:18:07 2007 @@ -0,0 +1,71 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file parameter_handler.h + * + * $Id$ + * + * @author Friedhelm Wolf + */ +//============================================================================= + +#ifndef _FAPIA_IPC_PARAMETER_SOCKET_TEST_HANDLER_H_ +#define _FAPIA_IPC_PARAMETER_SOCKET_TEST_HANDLER_H_ + +#include +#include +#include +#include + +// forward declaration +class ACE_Activation_Queue; + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + namespace Test + { + + class ParameterHandler : + public ACE_Svc_Handler + { + public: + ParameterHandler (void); + ~ParameterHandler (void); + + virtual int open (void *); + virtual int handle_input (ACE_HANDLE); + + void queue (ACE_Activation_Queue* q) {this->queue_ = q;} + private: + ACE_Activation_Queue* queue_; + }; + + class Parameter_Acceptor : + public ACE_Acceptor + { + public: + Parameter_Acceptor (ACE_Activation_Queue* q); + virtual ~Parameter_Acceptor (); + + virtual int accept_svc_handler (ParameterHandler* svc_handler); + + private: + ACE_Activation_Queue* queue_; + }; + + } /* namespace Test */ + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + + + +#endif /* _FAPIA_IPC_PARAMETER_SOCKET_TEST_HANDLER_H_ */ Added: fapia-trunk/FAPIAIPCParameter/test/concepts/source/parameter_server.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/concepts/source/parameter_server.cpp Thu Jul 19 07:18:07 2007 @@ -0,0 +1,65 @@ +#ifdef _DEBUG +//#define ACE_NTRACE 0 +#endif + +#include +#include "reply_handler.h" +#include "parameter_handler.h" +#include +#include +#include + +int main (int argc, char* argv[]) + { + FAPIA_TRACE; + + FAPI::Acyclic::IPC::Parameter::Test::init_data (); + + // Create an adapter to end the event loop. + ACE_Sig_Adapter sa ((ACE_Sig_Handler_Ex) ACE_Reactor::end_event_loop); + + ACE_Sig_Set sig_set; + sig_set.sig_add (SIGINT); + sig_set.sig_add (SIGQUIT); + + // Register ourselves to receive SIGINT and SIGQUIT so we can shut + // down gracefully via signals. + if (ACE_Reactor::instance ()->register_handler (sig_set, + &sa) == -1) + { + FAPIA_DEBUG (LM_ERROR, "could not register signal handler.\n"); + return -1; + } + + ACE_Activation_Queue request_queue; + + FAPI::Acyclic::IPC::Parameter::Test::ReplyHandler reply_handler; + reply_handler.queue (&request_queue); + if (reply_handler.activate () == -1) + { + FAPIA_DEBUG (LM_ERROR, "could not start reply handler.\n"); + return -1; + } + + FAPI::Acyclic::IPC::Parameter::Test::Parameter_Acceptor param_acptr (&request_queue); + ACE_INET_Addr addr (argc > 1 ? (u_short)ACE_OS::atoi (argv[1]) : ACE_DEFAULT_SERVER_PORT); + + if (param_acptr.open (addr, ACE_Reactor::instance ()) == -1) + { + ACE_TCHAR buffer[255]; + addr.addr_to_string (buffer, 255); + FAPIA_DEBUG (LM_ERROR, "could not open address %s\n", buffer); + return -1; + } + + FAPIA_DEBUG (LM_NOTICE, "waiting for requests ...\n"); + + ACE_Reactor::run_event_loop (); + request_queue.enqueue (new FAPI::Acyclic::IPC::Parameter::MethodRequestFinish ()); + FAPIA_DEBUG (LM_NOTICE, "waiting for reply handler to finish ...\n"); + reply_handler.wait (); + + FAPIA_DEBUG (LM_NOTICE, "shutting down ...\n"); + + return 0; + } Added: fapia-trunk/FAPIAIPCParameter/test/concepts/source/reply_handler.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/concepts/source/reply_handler.cpp Thu Jul 19 07:18:07 2007 @@ -0,0 +1,121 @@ +#include "reply_handler.h" + +#include "FAPIATrace.h" +#include +#include + +#include +#include + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + namespace Test + { + +/*---------------------------------------------------------------------------*/ + +ReplyHandler::ReplyHandler (void) +: shutdown_ (false) +{ + queue_ = NULL; +} + +/*---------------------------------------------------------------------------*/ + +ReplyHandler::~ReplyHandler (void) +{ +} + +/*---------------------------------------------------------------------------*/ + +int ReplyHandler::svc () +{ + FAPIA_TRACE; + + do + { + if (queue_ == NULL) + { + ACE_DEBUG ((LM_WARNING, ACE_TEXT ("queue was not initialized"))); + shutdown_ = true; + } + + ACE_Strong_Bound_Ptr request(this->queue_->dequeue ()); + + if (!request.null ()) + { + + if (request->call () != 0) + { + shutdown_ = true; + } + else + { + FAPI::Acyclic::IPC::Parameter::MethodRequestReadRequest* rreq = + ACE_dynamic_cast ( + FAPI::Acyclic::IPC::Parameter::MethodRequestReadRequest*, + request.get ()); + if (rreq != NULL) + { + cout << "dequeued " << *rreq << endl; + } + else + { + FAPI::Acyclic::IPC::Parameter::MethodRequestReadResponse* rres = + ACE_dynamic_cast ( + FAPI::Acyclic::IPC::Parameter::MethodRequestReadResponse*, + request.get ()); + if (rres != NULL) + { + cout << "dequeued " << *rres << endl; + } + else + { + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteRequest* wreq = + ACE_dynamic_cast ( + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteRequest*, + request.get ()); + if (wreq != NULL) + { + cout << "dequeued " << *wreq << endl; + } + else + { + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteResponse* wres = + ACE_dynamic_cast ( + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteResponse*, + request.get ()); + if (wres != NULL) + { + cout << "dequeued " << *wres << endl; + } + } + } + } + } + } + else + { + ACE_DEBUG ((LM_WARNING, ACE_TEXT("could not read the enqueued request."))); + shutdown_ = true; + } + + } while (shutdown_ == false); + + FAPIA_DEBUG (LM_DEBUG, "closing reply handler."); + return 0; +} + +/*---------------------------------------------------------------------------*/ + + } /* namespace Test */ + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/test/concepts/source/reply_handler.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/concepts/source/reply_handler.h Thu Jul 19 07:18:07 2007 @@ -0,0 +1,59 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file reply_handler.h + * + * $Id$ + * + * @author Friedhelm Wolf + */ +//============================================================================= + +#ifndef _FAPIA_IPC_PARAMETER_QUEUE_REPLY_HANDLER_H_ +#define _FAPIA_IPC_PARAMETER_QUEUE_REPLY_HANDLER_H_ + +#include +#include +#include + +// forward declaration +class ACE_Activation_Queue; + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + namespace Test + { + + class ReplyHandler : + public ACE_Svc_Handler + { + public: + ReplyHandler (void); + ~ReplyHandler (void); + + virtual int svc (void); + + void shutdown () {shutdown_ = true;} + + void queue (ACE_Activation_Queue* q) {this->queue_ = q;} + private: + ACE_Activation_Queue* queue_; + bool shutdown_; + }; + + } /* namespace Test */ + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + + + +#endif /* _FAPIA_IPC_PARAMETER_QUEUE_REPLY_HANDLER_H_ */ Added: fapia-trunk/FAPIAIPCParameter/test/marshalling/make/MPC/testmarshalling.mpc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/marshalling/make/MPC/testmarshalling.mpc Thu Jul 19 07:18:07 2007 @@ -0,0 +1,18 @@ +project (testmarshalling) : FAPIAIPCParameterlocalcomponentsexe, cppunitcomponentsexe { + + exename = testmarshalling + + includes += ../../../source + + source_files { + ../../source/testmarshalling.cpp + ../../source/marshallingtest.cpp + ../../../source/marshallingdata.cpp + } + + header_files { + ../../source/marshallingtest.h + ../../../source/marshallingdata.h + } + +} \ No newline at end of file Added: fapia-trunk/FAPIAIPCParameter/test/marshalling/make/MPC/testmarshalling.mwc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/marshalling/make/MPC/testmarshalling.mwc Thu Jul 19 07:18:07 2007 @@ -0,0 +1,3 @@ +workspace (testmarshalling) { + testmarshalling.mpc +} \ No newline at end of file Added: fapia-trunk/FAPIAIPCParameter/test/marshalling/make/makefile ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/marshalling/make/makefile Thu Jul 19 07:18:07 2007 @@ -0,0 +1,24 @@ +MODULE=testmarshalling + +TYPES:= VC8 VC8_STATIC Automake + +NMAKE_STATIC_CFG="Static_Multi_Unicode_Debug_StaticRTL" "Static_Multi_Unicode_Release_StaticRTL" +NMAKE_DLL_CFG= +GNU_LINUX_CFG = "Debug" "Release" + +MPC_DIRS := $(VIEW_ROOT)/DevTools_vob/cppunit/make/MPC/config $(VIEW_ROOT)/IOFramework_vob/FAPIA/make/MPC/config $(VIEW_ROOT)/ACE_Wrappers_vob/ACE_wrappers/make/MPC/config + +ALL: MPC BUILD + +BUILD: BUILD_ALL + +CLEAN: CLEAN_BUILD CLEAN_MPC + +REALCLEAN: REALCLEAN_BUILD CLEAN_MPC + +EXPORT: EXPORT_ALL + +%include <.homag_make_rules> +%include <.homag_mpc_make_rules> +%include <.homag_build_make_rules> +%include <.homag_export_make_rules> Added: fapia-trunk/FAPIAIPCParameter/test/marshalling/makeall.bat ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/marshalling/makeall.bat Thu Jul 19 07:18:07 2007 @@ -0,0 +1,2 @@ +set ARP_Tools=%cd%\..\..\..\..\..\DevTools_vob\ARP-Tools +ccperl %arp_tools%\mk.pl %* \ No newline at end of file Added: fapia-trunk/FAPIAIPCParameter/test/marshalling/makefile ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/marshalling/makefile Thu Jul 19 07:18:07 2007 @@ -0,0 +1,10 @@ +SPEC = * +MODULE_DIRS= $(SPEC,*D) +MODULE_DIRS = ./make + + +ALL: $(MODULE_DIRS) $(MAKETARGETS) + %echo ALL_SOURCES $(.SOURCES) + +%include <.homag_make_rules> +%include <.homag_release_make_rules> Added: fapia-trunk/FAPIAIPCParameter/test/marshalling/source/marshallingtest.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/marshalling/source/marshallingtest.cpp Thu Jul 19 07:18:07 2007 @@ -0,0 +1,315 @@ +// $Id$ + + +#include "marshallingtest.h" +#include "marshallingdata.h" +#include "FAPIA\FAPIAIPCParameter\source\FAPIAIPCParameterStreaming.h" +#include + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + namespace Test + { + +CPPUNIT_TEST_SUITE_REGISTRATION (MarshallingTest); + +/*---------------------------------------------------------------------------*/ + +MarshallingTest::MarshallingTest() + { + } + +/*---------------------------------------------------------------------------*/ + +void MarshallingTest::setUp() + { + } + +/*---------------------------------------------------------------------------*/ + +void MarshallingTest::tearDown() + { + } + +/*---------------------------------------------------------------------------*/ + +void MarshallingTest::test_base_types () + { + std::cout << std::endl << __FUNCTION__ << std::endl; + + // test marshalling of FAPI::Acyclic::IPC::Parameter::Communication + + FAPI::Acyclic::IPC::Parameter::Communication recv_comm; + ACE_OutputCDR cdr_out; + CPPUNIT_ASSERT (cdr_out << g_communication); + ACE_InputCDR cdr_in (cdr_out.begin ()); + CPPUNIT_ASSERT (cdr_in >> recv_comm); + CPPUNIT_ASSERT (!(g_communication != recv_comm)); + + // test marshalling of FAPI::Acyclic::IPC::Parameter::Parameter + FAPI::Acyclic::IPC::Parameter::Parameter recv_param; + cdr_out.reset (); + CPPUNIT_ASSERT (cdr_out << g_parameters[0]); + cdr_in.reset (cdr_out.begin (), cdr_out.byte_order ()); + CPPUNIT_ASSERT (cdr_in >> recv_param); + CPPUNIT_ASSERT (!(g_parameters[0] != recv_param)); + + // test marshalling of FAPI::Acyclic::IPC::Parameter::Value + FAPI::Acyclic::IPC::Parameter::Value recv_value; + cdr_out.reset (); + CPPUNIT_ASSERT (cdr_out << g_values[0]); + cdr_in.reset (cdr_out.begin (), cdr_out.byte_order ()); + CPPUNIT_ASSERT (cdr_in >> recv_value); + CPPUNIT_ASSERT (!(g_values[0] != recv_value)); + + // test marshalling of FAPI::Acyclic::IPC::Parameter::Error + FAPI::Acyclic::IPC::Parameter::Error recv_error; + cdr_out.reset (); + CPPUNIT_ASSERT (cdr_out << g_errors[0]); + cdr_in.reset (cdr_out.begin (), cdr_out.byte_order ()); + CPPUNIT_ASSERT (cdr_in >> recv_error); + CPPUNIT_ASSERT (!(g_errors[0] != recv_error)); + } + +/*---------------------------------------------------------------------------*/ + +void MarshallingTest::test_vectors() + { + std::cout << std::endl << __FUNCTION__ << std::endl; + + // test marshalling of parameter vector + FAPI::Acyclic::IPC::Parameter::Parameters recv_params; + ACE_OutputCDR cdr_out; + CPPUNIT_ASSERT (cdr_out << g_parameters); + ACE_InputCDR cdr_in (cdr_out.begin ()); + CPPUNIT_ASSERT (cdr_in >> recv_params); + CPPUNIT_ASSERT (!(g_parameters != recv_params)); + + // test marshalling of value vector + FAPI::Acyclic::IPC::Parameter::Values recv_values; + cdr_out.reset (); + CPPUNIT_ASSERT (cdr_out << g_values); + cdr_in.reset (cdr_out.begin (), cdr_out.byte_order ()); + CPPUNIT_ASSERT (cdr_in >> recv_values); + CPPUNIT_ASSERT (!(g_values != recv_values)); + + // test marshalling of error vector + FAPI::Acyclic::IPC::Parameter::Errors recv_errors; + cdr_out.reset (); + CPPUNIT_ASSERT (cdr_out << g_errors); + cdr_in.reset (cdr_out.begin (), cdr_out.byte_order ()); + CPPUNIT_ASSERT (cdr_in >> recv_errors); + CPPUNIT_ASSERT (!(g_errors != recv_errors)); + } + +/*---------------------------------------------------------------------------*/ + +void MarshallingTest::test_method_requests() + { + std::cout << std::endl << __FUNCTION__ << std::endl; + + // test marshalling of MethodRequestReadRequest + FAPI::Acyclic::IPC::Parameter::MethodRequestReadRequest recv_rrequest; + ACE_OutputCDR cdr_out; + CPPUNIT_ASSERT (cdr_out << g_read_request); + ACE_InputCDR cdr_in (cdr_out.begin ()); + CPPUNIT_ASSERT (cdr_in >> recv_rrequest); + CPPUNIT_ASSERT (!(g_read_request != recv_rrequest)); + + // test marshalling of MethodRequestReadResponse + FAPI::Acyclic::IPC::Parameter::MethodRequestReadResponse recv_rresponse; + cdr_out.reset (); + CPPUNIT_ASSERT (cdr_out << g_read_response); + cdr_in.reset_contents (); // don't know why, but I have to delete contents + cdr_in.reset (cdr_out.begin (), cdr_out.byte_order ()); + CPPUNIT_ASSERT (cdr_in >> recv_rresponse); + CPPUNIT_ASSERT (!(g_read_response != recv_rresponse)); + + // test marshalling of MethodRequestWriteRequest + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteRequest recv_wrequest; + cdr_out.reset (); + CPPUNIT_ASSERT (cdr_out << g_write_request); + cdr_in.reset_contents (); // don't know why, but I have to delete contents + cdr_in.reset (cdr_out.begin (), cdr_out.byte_order ()); + CPPUNIT_ASSERT (cdr_in >> recv_wrequest); + CPPUNIT_ASSERT (!(g_write_request != recv_wrequest)); + + // test marshalling of MethodRequestWriteResponse + FAPI::Acyclic::IPC::Parameter::MethodRequestWriteResponse recv_wresponse; + cdr_out.reset (); + CPPUNIT_ASSERT (cdr_out << g_write_response); + cdr_in.reset_contents (); // don't know why, but I have to delete contents + cdr_in.reset (cdr_out.begin (), cdr_out.byte_order ()); + CPPUNIT_ASSERT (cdr_in >> recv_wresponse); + CPPUNIT_ASSERT (!(g_write_response != recv_wresponse)); + } + +/*---------------------------------------------------------------------------*/ + +void MarshallingTest::test_size_evaluation () +{ + std::cout << std::endl << __FUNCTION__ << std::endl; + + // test size of FAPI::Acyclic::IPC::Parameter::Communication + unsigned long comm_size = 0; + comm_size += g_communication; + ACE_OutputCDR cdr; + cdr << g_communication; + CPPUNIT_ASSERT (comm_size >= cdr.total_length ()); + + // test size of FAPI::Acyclic::IPC::Parameter::Parameter + unsigned long param_size = 0; + param_size += g_parameters[0]; + cdr.reset (); + cdr << g_parameters[0]; + CPPUNIT_ASSERT (param_size == cdr.total_length ()); + + // test size of parameter vector + unsigned long params_size = 0; + params_size += g_parameters; + cdr.reset (); + cdr << g_parameters; + CPPUNIT_ASSERT (params_size >= cdr.total_length ()); + + // test size of FAPI::Acyclic::IPC::Parameter::Value + unsigned long value_size = 0; + value_size += g_values[0]; + cdr.reset (); + cdr << g_values[0]; + CPPUNIT_ASSERT (value_size >= cdr.total_length ()); + + // test size of value vector + unsigned long values_size = 0; + values_size += g_values; + cdr.reset (); + cdr << g_values; + CPPUNIT_ASSERT (values_size >= cdr.total_length ()); + + // test size of FAPI::Acyclic::IPC::Parameter::Error + unsigned long error_size = 0; + error_size += g_errors[0]; + cdr.reset (); + cdr << g_errors[0]; + CPPUNIT_ASSERT (error_size >= cdr.total_length ()); + + // test size of error vector + unsigned long errors_size = 0; + errors_size += g_errors; + cdr.reset (); + cdr << g_errors; + CPPUNIT_ASSERT (errors_size >= cdr.total_length ()); + + // test size of MethodRequestReadRequest + unsigned long read_request_size = 0; + read_request_size += g_read_request; + cdr.reset (); + cdr << g_read_request; + CPPUNIT_ASSERT (read_request_size >= cdr.total_length ()); + + // test size of MethodRequestReadResponse + unsigned long read_response_size = 0; + read_response_size += g_read_response; + cdr.reset (); + cdr << g_read_response; + CPPUNIT_ASSERT (read_response_size >= cdr.total_length ()); + + // test size of MethodRequestWriteRequest + unsigned long write_request_size = 0; + write_request_size += g_write_request; + cdr.reset (); + cdr << g_write_request; + CPPUNIT_ASSERT (write_request_size >= cdr.total_length ()); + + // test size of MethodRequestWriteResponse + unsigned long write_response_size = 0; + write_response_size += g_write_response; + cdr.reset (); + cdr << g_write_response; + CPPUNIT_ASSERT (write_response_size >= cdr.total_length ()); +} + +/*---------------------------------------------------------------------------*/ + +void MarshallingTest::test_string_streaming () +{ + std::cout << std::endl << __FUNCTION__ << std::endl; + + std::stringstream rrqss, rrpss, wrqss, wrpss; + + std::string rrqstr = "ReadRequest {\n\tprio=99\n\tdest=192.0.0.4:9900\n\t"; + rrqstr += "communication [id=9876543, logical_name=my logical object, obj"; + rrqstr += "_name=my physical object name, send_reply=1]\n\tparameters (pa"; + rrqstr += "rameter [my first parameter], parameter [my second parameter],"; + rrqstr += " parameter [my third parameter], )\n}\n"; + + std::string rrpstr = "ReadResponse {\n\tprio=23\n\tdest=127.0.0.1:1212\n"; + rrpstr += "\tcommunication [id=9876543, logical_name=my logical object, "; + rrpstr += "obj_name=my physical object name, send_reply=1]\n\tparameters"; + rrpstr += " (parameter [my first parameter], parameter [my second parame"; + rrpstr += "ter], parameter [my third parameter], )\n\tvalues (value [typ"; + rrpstr += "e=7, len=26, data=Hamp], value [type=5, len=4, data=???"; + rrpstr += (char) 0x7f; + rrpstr += "], value [type=8, len="; + rrpstr += "8, data="; + rrpstr += (char) 0xec; + rrpstr += (char) 0x1e; + rrpstr += (char) 0x22; + rrpstr += (char) 0x82; + rrpstr += "], )\n\terrors (error [code=FAPIA_ERROR_OBJECT_N"; + rrpstr += "OT_FOUND, reason=My bonnie is over the ocean, my bonnie is ov"; + rrpstr += "er the sea.], error [code=FAPIA_ERROR_COMMUNICATION, reason=W"; + rrpstr += "hat did you say? I don't understand German!], error [code=FAP"; + rrpstr += "IA_ERROR_CONFIG_PARSE_ERROR, reason=asdf ?lkj hiks kisikss ?r"; + rrpstr += "ks], )\n}\n"; + + std::string wrqstr = "WriteRequest {\n\tprio=1\n\tdest=23.233.2.121:3000\n"; + wrqstr += "\tcommunication [id=9876543, logical_name=my logical object, ob"; + wrqstr += "j_name=my physical object name, send_reply=1]\n\tparameters (pa"; + wrqstr += "rameter [my first parameter], parameter [my second parameter], "; + wrqstr += "parameter [my third parameter], )\n\tvalues (value [type=7, len"; + wrqstr += "=26, data=Hamp], value [type=5, len=4, data=???"; + wrqstr += (char) 0x7f; + wrqstr += "], value [type=8, len=8, data="; + wrqstr += (char) 0xec; + wrqstr += (char) 0x1e; + wrqstr += (char) 0x22; + wrqstr += (char) 0x82; + wrqstr += "], )\n}\n"; + + std::string wrpstr = "WriteResponse {\n\tprio=87\n\tdest=1.2.3.4:5678\n\tco"; + wrpstr += "mmunication [id=9876543, logical_name=my logical object, obj_nam"; + wrpstr += "e=my physical object name, send_reply=1]\n\tparameters (paramete"; + wrpstr += "r [my first parameter], parameter [my second parameter], paramet"; + wrpstr += "er [my third parameter], )\n\terrors (error [code=FAPIA_ERROR_OB"; + wrpstr += "JECT_NOT_FOUND, reason=My bonnie is over the ocean, my bonnie is"; + wrpstr += " over the sea.], error [code=FAPIA_ERROR_COMMUNICATION, reason=W"; + wrpstr += "hat did you say? I don't understand German!], error [code=FAPIA_"; + wrpstr += "ERROR_CONFIG_PARSE_ERROR, reason=asdf ?lkj hiks kisikss ?rks], )"; + wrpstr += "\n}\n"; + + rrqss << g_read_request; + CPPUNIT_ASSERT (rrqstr.compare (rrqss.str ()) == 0); + + rrpss << g_read_response; + CPPUNIT_ASSERT (rrpstr.compare (rrpss.str ()) == 0); + + wrqss << g_write_request; + CPPUNIT_ASSERT (wrqstr.compare (wrqss.str ()) == 0); + + wrpss << g_write_response; + CPPUNIT_ASSERT (wrpstr.compare (wrpss.str ()) == 0); +} + +/*---------------------------------------------------------------------------*/ + + } /* namespace Test */ + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCParameter/test/marshalling/source/marshallingtest.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/marshalling/source/marshallingtest.h Thu Jul 19 07:18:07 2007 @@ -0,0 +1,64 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file marshallingtest.h + * + * $Id$ + * + * @author Friedhelm Wolf + */ +//============================================================================= + +#ifndef _FAPIA_IPC_PARAMETER_MARSHALLING_TEST_H_ +#define _FAPIA_IPC_PARAMETER_MARSHALLING_TEST_H_ + +#ifdef WIN32 +# pragma warning (disable : 4512) +#endif + +#include + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + namespace Test + { + class MarshallingTest : public CppUnit::TestFixture + { + public: + CPPUNIT_TEST_SUITE (MarshallingTest); + CPPUNIT_TEST (test_base_types); + CPPUNIT_TEST (test_vectors); + CPPUNIT_TEST (test_method_requests); + CPPUNIT_TEST (test_size_evaluation); + CPPUNIT_TEST (test_string_streaming); + CPPUNIT_TEST_SUITE_END (); + + private: + + public: + MarshallingTest (void); + + void setUp (void); + void tearDown (void); + + void test_base_types (void); + void test_vectors (void); + void test_method_requests (void); + void test_size_evaluation (void); + void test_string_streaming (void); + }; /* class MarshallingTest */ + + } /* namespace Test */ + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif // _FAPIA_IPC_PARAMETER_MARSHALLING_TEST_H_ Added: fapia-trunk/FAPIAIPCParameter/test/marshalling/source/testmarshalling.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/marshalling/source/testmarshalling.cpp Thu Jul 19 07:18:07 2007 @@ -0,0 +1,29 @@ +#include +#include + +#ifdef WIN32 +# pragma warning (disable : 4100) +# pragma warning (push) +#endif /* WIN32 */ + +#include +#include +#include +#include + +#include "marshallingdata.h" + +#ifdef WIN32 +# pragma warning (pop) +#endif /* WIN32 */ + +int main( int argc, char **argv) +{ + FAPI::Acyclic::IPC::Parameter::Test::init_data (); + + CppUnit::TextUi::TestRunner runner; + CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); + runner.addTest( registry.makeTest() ); + bool wasSuccessful = runner.run( "", false); + return wasSuccessful; +} Added: fapia-trunk/FAPIAIPCParameter/test/source/marshallingdata.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/source/marshallingdata.cpp Thu Jul 19 07:18:07 2007 @@ -0,0 +1,127 @@ +#include "marshallingdata.h" + +/*---------------------------------------------------------------------------*/ + +FAPI::Acyclic::IPC::Parameter::Communication g_communication; +FAPI::Acyclic::IPC::Parameter::Parameters g_parameters; +FAPI::Acyclic::IPC::Parameter::Values g_values; +FAPI::Acyclic::IPC::Parameter::Errors g_errors; +FAPI::Acyclic::IPC::Parameter::MethodRequestReadRequest g_read_request; +FAPI::Acyclic::IPC::Parameter::MethodRequestReadResponse g_read_response; +FAPI::Acyclic::IPC::Parameter::MethodRequestWriteRequest g_write_request; +FAPI::Acyclic::IPC::Parameter::MethodRequestWriteResponse g_write_response; + +/*---------------------------------------------------------------------------*/ + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + namespace Test + { + +/*---------------------------------------------------------------------------*/ + +void init_data (void) + { + // init communication + g_communication.send_reply_ = true; + g_communication.logical_object_name_ = "my logical object"; + g_communication.source_physical_object_name_ = + "my physical object name"; + g_communication.transaction_id_ = 9876543; + g_communication.communication_error_.error_code_ = + FAPIA_ERROR_DESTINATION_NOT_ONLINE; + g_communication.communication_error_.reason_ = "could not open port 0909"; + + // init parameters + Parameter param; + param.parameter_name_ = "my first parameter"; + g_parameters.push_back (param); + + param.parameter_name_ = "my second parameter"; + g_parameters.push_back (param); + + param.parameter_name_ = "my third parameter"; + g_parameters.push_back (param); + + // init values + char* test_data = new char[26]; + ACE_OS::strcpy (test_data, "Hamptidamti dumm di \n dei"); + Value val; + val.data_value (test_data, ACE_OS::strlen (test_data)+1); + val.data_type_ = FAPIA_DATA_TYPE_STRING; + g_values.push_back (val); + + long* long_data = new long; + *long_data = LONG_MAX; + val.data_value (long_data, sizeof (*long_data)); + val.data_type_ = FAPIA_DATA_TYPE_SGN32; + g_values.push_back (val); + + double* double_data = new double; + *double_data = 123e-12; + val.data_value (double_data, sizeof (*double_data)); + val.data_type_ = FAPIA_DATA_TYPE_REAL64; + g_values.push_back (val); + + delete[] test_data; + delete long_data; + delete double_data; + + // init errors + Error err; + err.error_code_ = FAPIA_ERROR_OBJECT_NOT_FOUND; + err.reason_ = "My bonnie is over the ocean, my bonnie is over the sea."; + g_errors.push_back (err); + + err.error_code_ = FAPIA_ERROR_COMMUNICATION; + err.reason_ = "What did you say? I don't understand German!"; + g_errors.push_back (err); + + err.error_code_ = FAPIA_ERROR_CONFIG_PARSE_ERROR; + err.reason_ = "asdf ?lkj hiks kisikss ?rks"; + g_errors.push_back (err); + + // init g_read_request + g_read_request.priority (99); + g_read_request.communication_ = g_communication; + g_read_request.parameters_ = g_parameters; + g_read_request.destination_physical_object_address_ = "192.0.0.4:9900"; + + // init g_read_response + g_read_response.priority (23); + g_read_response.communication_ = g_communication; + g_read_response.parameters_ = g_parameters; + g_read_response.values_ = g_values; + g_read_response.errors_ = g_errors; + g_read_response.destination_physical_object_address_ = "127.0.0.1:1212"; + + // init g_write_request + g_write_request.priority (1); + g_write_request.communication_ = g_communication; + g_write_request.parameters_ = g_parameters; + g_write_request.values_ = g_values; + g_write_request.destination_physical_object_address_ = "23.233.2.121:3000"; + + // init g_write_response + g_write_response.priority (87); + g_write_response.communication_ = g_communication; + g_write_response.parameters_ = g_parameters; + g_write_response.errors_ = g_errors; + g_write_response.destination_physical_object_address_ = "1.2.3.4:5678"; + } + +/*---------------------------------------------------------------------------*/ + + } /* namespace Test */ + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +/*---------------------------------------------------------------------------*/ Added: fapia-trunk/FAPIAIPCParameter/test/source/marshallingdata.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCParameter/test/source/marshallingdata.h Thu Jul 19 07:18:07 2007 @@ -0,0 +1,52 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file marshallingdata.h + * + * $Id$ + * + * @author Friedhelm Wolf + */ +//============================================================================= + +#ifndef _FAPIA_IPC_PARAMETER_MARSHALLING_DATA_H_ +#define _FAPIA_IPC_PARAMETER_MARSHALLING_DATA_H_ + +#include + +extern FAPI::Acyclic::IPC::Parameter::Communication g_communication; +extern FAPI::Acyclic::IPC::Parameter::Parameters g_parameters; +extern FAPI::Acyclic::IPC::Parameter::Values g_values; +extern FAPI::Acyclic::IPC::Parameter::Errors g_errors; + +extern FAPI::Acyclic::IPC::Parameter::MethodRequestReadRequest + g_read_request; + +extern FAPI::Acyclic::IPC::Parameter::MethodRequestReadResponse + g_read_response; + +extern FAPI::Acyclic::IPC::Parameter::MethodRequestWriteRequest + g_write_request; + +extern FAPI::Acyclic::IPC::Parameter::MethodRequestWriteResponse + g_write_response; + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Parameter + { + namespace Test + { + void init_data (void); + } /* namespace Test */ + } /* namespace Parameter */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPIA_IPC_PARAMETER_MARSHALLING_DATA_H_ */ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:46:56 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:46:56 +0200 Subject: [OSADL-svn-commits] r88 - in fapia-trunk/FAPIAIPCSynchronize: interface make make/MPC source test test/one_process test/one_process/make test/one_process/make/MPC test/one_process/source Message-ID: <200710020946.l929ku0H021329@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:20:10 2007 New Revision: 88 Log: Added: fapia-trunk/FAPIAIPCSynchronize/interface/ fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCISynchronize.h fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronize.h fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeError.h fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeError.i fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeInit.h fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeInit.i fapia-trunk/FAPIAIPCSynchronize/make/ fapia-trunk/FAPIAIPCSynchronize/make/MPC/ fapia-trunk/FAPIAIPCSynchronize/make/MPC/FAPIAIPCSynchronize.mpc fapia-trunk/FAPIAIPCSynchronize/make/MPC/FAPIAIPCSynchronize.mwc fapia-trunk/FAPIAIPCSynchronize/make/makeall.bat fapia-trunk/FAPIAIPCSynchronize/make/makefile fapia-trunk/FAPIAIPCSynchronize/source/ fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronize.cpp fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeError.cpp fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeInit.cpp fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeSharedMemoryStruct.h fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeWatchdog.cpp fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeWatchdog.h fapia-trunk/FAPIAIPCSynchronize/test/ fapia-trunk/FAPIAIPCSynchronize/test/one_process/ fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/ fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/MPC/ fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/MPC/one_process.mpc fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/MPC/one_process.mwc fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/makefile fapia-trunk/FAPIAIPCSynchronize/test/one_process/makeall.bat fapia-trunk/FAPIAIPCSynchronize/test/one_process/makefile fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/ fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/main.cpp fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/test_fapia_synchronize_one_process.cpp fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/test_fapia_synchronize_one_process.h Added: fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCISynchronize.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCISynchronize.h Thu Jul 19 07:20:10 2007 @@ -0,0 +1,89 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCISynchronize.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_ISYNCHRONIZE_H_ +#define _FAPI_ACYCLIC_IPC_ISYNCHRONIZE_H_ + +#include /**/ +#include "FAPIAIPCSynchronizeInit.h" +#include "FAPIAIPCSynchronizeError.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + /** + * @interface ISynchronize + * + * @brief The ISynchronize is the interface for the IPC::Synchronize + * module. + * + */ + class ISynchronize + { + + public: + /** + * @brief Initializes the IPC::Synchronize module. + * + * If it returns -1 there was an error. Look at the error object. + * + */ + virtual int init + ( + const FAPI::Acyclic::IPC::Synchronize::Init& init, + FAPI::Acyclic::IPC::Synchronize::Error& error + ) = 0; + + /** + * @brief Deinitializes the IPC::Synchronize module. + * + * If it returns -1 an error occured. + * + */ + virtual int deinit (void) = 0; + + /** + * @brief Retrieves the address for a given physical object. + * + * If it returns -1 an error occured. Then look at the error + * object. + * + */ + virtual int retrieve_physical_object_address + ( + const ACE_CString& physical_object_name, + ACE_CString& physical_object_address, + FAPI::Acyclic::IPC::Synchronize::Error& error + ) = 0; + + /** + * @brief Disables the physical object. + * + * If it returns -1 an error occured. + * + */ + virtual int disable_physical_object + ( + const ACE_CString& physical_object_address, + FAPI::Acyclic::IPC::Synchronize::Error& error + ) = 0; + + }; /* class ISynchronize */ + + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_ISYNCHRONIZE_H_ */ Added: fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronize.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronize.h Thu Jul 19 07:20:10 2007 @@ -0,0 +1,176 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCSynchronize.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_SYNCHRONIZE_SYNCHRONIZE_H_ +#define _FAPI_ACYCLIC_IPC_SYNCHRONIZE_SYNCHRONIZE_H_ + +#include "../interface/FAPIAIPCISynchronize.h" +#include "../source/FAPIAIPCSynchronizeSharedMemoryStruct.h" +#include +#include +#include + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Synchronize + { + + class Watchdog; + + /** + * @class Synchronize + * + * @brief This is the implementation of IPC::ISynchronize + * interface. + * + */ + class Synchronize : public FAPI::Acyclic::IPC::ISynchronize + { + public: + friend class Watchdog; + + /** + * @brief Constructor. + * + */ + Synchronize (void); + + /** + * @brief Destructor. + * + */ + virtual ~Synchronize (void); + + /** + * @brief Initializes the IPC::Synchronize module. + * + * If it returns -1 there was an error. Look at the error object. + * + */ + virtual int init + ( + const FAPI::Acyclic::IPC::Synchronize::Init& init, + FAPI::Acyclic::IPC::Synchronize::Error& error + ); + + /** + * @brief Deinitializes the IPC::Synchronize module. + * + * If it returns -1 an error occured. + * + */ + virtual int deinit (void); + + /** + * @brief Retrieves the address for a given physical object. + * + * If it returns -1 an error occured. Then look at the error + * object. + * + */ + virtual int retrieve_physical_object_address + ( + const ACE_CString& physical_object_name, + ACE_CString& physical_object_address, + FAPI::Acyclic::IPC::Synchronize::Error& error + ); + + /** + * @brief Disables the physical object. + * + * If it returns -1 an error occured. + * + */ + virtual int disable_physical_object + ( + const ACE_CString& physical_object_address, + FAPI::Acyclic::IPC::Synchronize::Error& error + ); + + protected: + + /** + * @enum State + * + * @brief State of the ipc synchronize module. + * + */ + enum State + { + INITIAL = 1, + RUNNING = 2 + }; + + /// State of the controller module. + State state_; + + /// Name of the shared memory to synchronize the fapia + /// subscribers. + ACE_CString fapia_synchronize_shared_memory_name_; + + /// Name of the process mutex to synchronize the fapia + /// shared memory. + ACE_CString fapia_synchronize_process_mutex_name_; + + /// Process mutex to synchronize the access to the shared + /// memory. + ACE_Process_Mutex fapia_synchronize_mutex_; + + /// Shared memory for syncronize the fapia subsrcibers. + ACE_Mem_Map fapia_shared_memory_; + + /// Own position within shared memory. + unsigned long own_shared_memory_pos_; + + /// Pointer to watchdog thread. + FAPI::Acyclic::IPC::Synchronize::Watchdog* synchronize_watchdog_; + + /** + * @brief Creates or read the shared memory. + * + * If it returns -1 an error occured. + * + */ + int create_or_read_shared_memory (void); + + /** + * @brief Creates a directory recursively. + * + * If it returns -1 an error occured. + * + */ + int mkdir_recursive (const char * const directory); + + private: + + /** + * Copy Constructor is private, so this object cannot be copied. + */ + Synchronize (const Synchronize&); + + /** + * Assignment operator is private, so this object cannot be copied. + */ + const Synchronize& operator= (const Synchronize&); + + }; /* class Synchronize */ + + } /* namespace Synchronize */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_SYNCHRONIZE_SYNCHRONIZE_H_ */ Added: fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeError.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeError.h Thu Jul 19 07:20:10 2007 @@ -0,0 +1,107 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCSynchronizeError.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_SYNCHRONIZE_ERROR_H_ +#define _FAPI_ACYCLIC_IPC_SYNCHRONIZE_ERROR_H_ + +#include /**/ +#include /**/ +#include "../../interface/FAPIA.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Synchronize + { + /** + * @class Error + * + * @brief The Error struct contains error information. + * + */ + class Error + { + + public: + /** + * @brief Constructor of Error. + * + */ + Error (void); + + /** + * @brief Copy Constructor. + * + */ + Error (const Error&); + + /** + * @brief Assignment operator. + * + */ + const Error& operator= (const Error&); + + /** + * @brief Destructor of Error. + * + */ + virtual ~Error (void); + + // The member variables are public. Therefore there is no need + // to implement get and set methods. This class is used as a + // structure with constructor, destructor, copy constructor and + // assignement operator. + public: + /// Error code. Maybe ok. + FAPIAErrorCode error_code_; + + /// Reason of failure. If error_ is ok the reason_ is an + /// empty string. + ACE_CString reason_; + + private: + /** + * @brief Initialize the values. + * + */ + void open (void); + + /** + * @brief Copying the values. + * + */ + void copy (const Error&); + + /** + * @brief Deinitialize the values. + * + */ + void close (void); + + }; /* class Error */ + + /// This typedef is a container for Errors. + typedef ACE_Vector Errors; + + } /* namespace Synchronize */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#if defined (__ACE_INLINE__) +#include "../interface/FAPIAIPCSynchronizeError.i" +#endif /* __ACE_INLINE__ */ + +#endif /* _FAPI_ACYCLIC_IPC_SYNCHRONIZE_ERROR_H_ */ Added: fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeError.i ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeError.i Thu Jul 19 07:20:10 2007 @@ -0,0 +1,42 @@ +// $Id$ + + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Synchronize + { + ACE_INLINE const Error& Error::operator= (const Error& init) + { + if (this != &init) + { + this->copy(init); + } + return *this; + } + + ACE_INLINE void Error::open (void) + { + error_code_ = FAPIA_ERROR_OK; + reason_ = ""; + } + + ACE_INLINE void Error::close (void) + { + error_code_ = FAPIA_ERROR_OK; + reason_ = ""; + } + + ACE_INLINE void Error::copy (const Error& init) + { + this->error_code_ = init.error_code_; + this->reason_ = init.reason_; + } + + }/* namespace Synchronize */ + }/* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeInit.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeInit.h Thu Jul 19 07:20:10 2007 @@ -0,0 +1,109 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCSynchronizeInit.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_SYNCHRONIZE_INIT_H_ +#define _FAPI_ACYCLIC_IPC_SYNCHRONIZE_INIT_H_ + +#include /**/ +#include + + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Synchronize + { + /** + * @class Init + * + * @brief The Init structure is used to initialize the + * IPC::Synchronize module. + * + */ + class Init + { + + public: + /** + * @brief Constructor of Init. + * + */ + Init (void); + + /** + * @brief Copy Constructor. + * + */ + Init (const Init&); + + /** + * @brief Assignment operator. + * + */ + const Init& operator= (const Init&); + + /** + * @brief Destructor of Init. + * + */ + virtual ~Init (void); + + // The member variables are public. Therefore there is no need + // to implement get and set methods. This class is used as a + // structure with constructor, destructor, copy constructor and + // assignement operator. + public: + /// Name of the file for the shared memory. + ACE_CString fapia_shared_memory_name_; + + /// Name of this physical object. + ACE_CString physical_object_name_; + + /// Address of this physical object. + ACE_CString physical_object_address_; + + + private: + /** + * @brief Initialize the values. + * + */ + void open (void); + + /** + * @brief Copying the values. + * + */ + void copy (const Init&); + + /** + * @brief Deinitialize the values. + * + */ + void close (void); + + }; /* class Init */ + + } /* namespace Synchronize */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + + +#if defined (__ACE_INLINE__) +#include "FAPIAIPCSynchronizeInit.i" +#endif /* __ACE_INLINE__ */ + +#endif /* _FAPI_ACYCLIC_IPC_SYNCHRONIZE_INIT_H_ */ Added: fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeInit.i ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeInit.i Thu Jul 19 07:20:10 2007 @@ -0,0 +1,45 @@ +// $Id$ + + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Synchronize + { + ACE_INLINE const Init& Init::operator= (const Init& init) + { + if (this != &init) + { + this->copy(init); + } + return *this; + } + + ACE_INLINE void Init::open (void) + { + fapia_shared_memory_name_ = ""; + physical_object_name_ = ""; + physical_object_address_ = ""; + } + + ACE_INLINE void Init::close (void) + { + fapia_shared_memory_name_ = ""; + physical_object_name_ = ""; + physical_object_address_ = ""; + } + + ACE_INLINE void Init::copy (const Init& init) + { + this->fapia_shared_memory_name_ = init.fapia_shared_memory_name_; + this->physical_object_name_ = init.physical_object_name_; + this->physical_object_address_ = init.physical_object_address_; + } + + }/* namespace Synchronize */ + }/* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCSynchronize/make/MPC/FAPIAIPCSynchronize.mpc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/make/MPC/FAPIAIPCSynchronize.mpc Thu Jul 19 07:20:10 2007 @@ -0,0 +1,3 @@ + +project : FAPIAIPCSynchronizesource { +} \ No newline at end of file Added: fapia-trunk/FAPIAIPCSynchronize/make/MPC/FAPIAIPCSynchronize.mwc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/make/MPC/FAPIAIPCSynchronize.mwc Thu Jul 19 07:20:10 2007 @@ -0,0 +1,3 @@ +workspace { + FAPIAIPCSynchronize.mpc +} \ No newline at end of file Added: fapia-trunk/FAPIAIPCSynchronize/make/makeall.bat ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/make/makeall.bat Thu Jul 19 07:20:10 2007 @@ -0,0 +1,2 @@ +set ARP_Tools=%cd%\..\..\..\..\DevTools_vob\ARP-Tools +ccperl %arp_tools%\mk.pl %* \ No newline at end of file Added: fapia-trunk/FAPIAIPCSynchronize/make/makefile ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/make/makefile Thu Jul 19 07:20:10 2007 @@ -0,0 +1,26 @@ +MODULE=FAPIAIPCSynchronize + +TYPES:= VC8_STATIC Automake + +NMAKE_STATIC_CFG="Static_Multi_Unicode_Debug_StaticRTL" "Static_Multi_Unicode_Release_StaticRTL" +NMAKE_DLL_CFG= + +MPC_DIRS := $(VIEW_ROOT)/IOFramework_vob/FAPIA/make/MPC/config $(VIEW_ROOT)/ACE_Wrappers_vob/ACE_wrappers/make/MPC/config + +ALL: MPC BUILD + +BUILD: BUILD_ALL + +CLEAN: CLEAN_BUILD CLEAN_MPC + +REALCLEAN: REALCLEAN_BUILD CLEAN_MPC + +EXPORT: EXPORT_ALL + +%include <.homag_make_rules> +%include <.homag_mpc_make_rules> +%include <.homag_build_make_rules> +%include <.homag_export_make_rules> + +MAKE_RUNDIR:= os9/run +AUTOMAKE_RUNDIR:= i686_linux32 Added: fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronize.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronize.cpp Thu Jul 19 07:20:10 2007 @@ -0,0 +1,779 @@ +// $Id$ + + +#include "../interface/FAPIAIPCSynchronize.h" +#include "../../interface/FAPIATrace.h" +#include "FAPIAIPCSynchronizeWatchdog.h" +#include + + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Synchronize + { + +/* ---------------------------------------------------------------------------*/ + + Synchronize::Synchronize (void) : + fapia_synchronize_process_mutex_name_ ( + "FAPI_ACYCLIC_IPC_SYNCHRONIZE_PROCESS_MUTEX"), + fapia_synchronize_mutex_ ( + fapia_synchronize_process_mutex_name_.c_str ()) + { + FAPIA_TRACE; + + state_ = FAPI::Acyclic::IPC::Synchronize::Synchronize::INITIAL; + fapia_synchronize_shared_memory_name_ = ""; + + own_shared_memory_pos_ = FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT; + synchronize_watchdog_ = 0; + } + +/* ---------------------------------------------------------------------------*/ + + Synchronize::~Synchronize (void) + { + FAPIA_TRACE; + + if (synchronize_watchdog_) + { + synchronize_watchdog_->shutdown (); + delete synchronize_watchdog_; + synchronize_watchdog_ = 0; + } + + fapia_shared_memory_.close (); + state_ = FAPI::Acyclic::IPC::Synchronize::Synchronize::INITIAL; + + } + +/* ---------------------------------------------------------------------------*/ + + int Synchronize::init ( + const FAPI::Acyclic::IPC::Synchronize::Init& init, + FAPI::Acyclic::IPC::Synchronize::Error& error) + { + FAPIA_TRACE; + + error.error_code_ = FAPIA_ERROR_OK; + error.reason_ = ""; + + // Check for valid state. + if (state_ != FAPI::Acyclic::IPC::Synchronize::Synchronize::INITIAL) + { + FAPIA_DEBUG ( + LM_ERROR, + "State is not INITIAL. Call deinit first\n"); + + error.error_code_ = + FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED; + error.reason_ = "State is not INITIAL. Call deinit first"; + return -1; + } + + + // Check for valid parameters. + if (init.physical_object_address_.length () > + FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_ADDRESS_MAX_SIZE -1 || + init.physical_object_address_.length () == 0) + + { + FAPIA_DEBUG ( + LM_ERROR, + "Maximum length of physical_object_address_ is %u.\n", + FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_ADDRESS_MAX_SIZE - 1); + + error.error_code_ = + FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED; + + char tmp_error[1024]; + ACE_OS::sprintf( + tmp_error, + "Maximum length of physical_object_address_ is %ld.", + FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_ADDRESS_MAX_SIZE - 1); + + error.reason_ = tmp_error; + return -1; + } + + if (init.physical_object_name_.length () > + FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_NAME_MAX_SIZE -1 || + init.physical_object_name_.length () == 0) + { + FAPIA_DEBUG ( + LM_ERROR, + "Maximum length of physical_object_name is %u.\n", + FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_NAME_MAX_SIZE - 1); + + error.error_code_ = + FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED; + + char tmp_error[1024]; + ACE_OS::sprintf( + tmp_error, + "Maximum length of physical_object_name is %ld.", + FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_NAME_MAX_SIZE - 1); + + error.reason_ = tmp_error; + return -1; + } + + if (init.fapia_shared_memory_name_.length () == 0) + { + FAPIA_DEBUG ( + LM_ERROR, + "Length of fapia_shared_memory_name_ is zero.\n"); + + error.error_code_ = + FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED; + + error.reason_ = + "Length of fapia_shared_memory_name_ is zero."; + return -1; + } + + + + + + + // Set the name of the shared memory + this->fapia_synchronize_shared_memory_name_ = + init.fapia_shared_memory_name_; + + { + ACE_Write_Guard lock ( + fapia_synchronize_mutex_); + + + // Read the shared memory. + if (this->create_or_read_shared_memory () == -1) + { + FAPIA_DEBUG ( + LM_ERROR, + "Shared memory %C could not be read.\n", + this->fapia_synchronize_shared_memory_name_.c_str ()); + + error.error_code_ = + FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED; + + char tmp_error[1024]; + if (this->fapia_synchronize_shared_memory_name_.length () < + sizeof (tmp_error) - 50) + { + ACE_OS::sprintf( + tmp_error, + "Shared memory %s could not be read.", + this->fapia_synchronize_shared_memory_name_.c_str ()); + } + else + { + ACE_OS::sprintf( + tmp_error, + "Shared memory could not be opened."); + } + + error.reason_ = tmp_error; + return -1; + } + + + + + // Search the free place for initializing. + unsigned long i = 0; + unsigned long free_pos = FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT; + SharedMemoryStruct* shared_memory_structs = + ACE_static_cast (SharedMemoryStruct*, + (void *)((char*)fapia_shared_memory_.addr () + FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN)); + + for (i = 0; i < FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT; ++i) + { + if (free_pos == FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT) + { + if (shared_memory_structs[i].physical_object_name[0] == '\0') + { + free_pos = i; + } + } + + // If this physical object already exists take this entry. + if (ACE_OS::strcmp ( + shared_memory_structs[i].physical_object_name, + init.physical_object_name_.c_str ()) == 0) + { + free_pos = i; + break; + } + } + + if (free_pos == FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT) + { + FAPIA_DEBUG ( + LM_ERROR, + "There are too much communication subscribers. The maximum is %u\n", + FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT); + + error.error_code_ = + FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED; + + char tmp_error[1024]; + ACE_OS::sprintf( + tmp_error, + "There are too much communication subscribers. The maximum is %ld\n", + FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT); + + error.reason_ = tmp_error; + fapia_shared_memory_.close (); + return -1; + } + + + + + // Put own values into shared memory. + ACE_OS::strcpy ( + shared_memory_structs[free_pos].physical_object_name, + init.physical_object_name_.c_str ()); + ACE_OS::strcpy ( + shared_memory_structs[free_pos].physical_object_address, + init.physical_object_address_.c_str ()); + shared_memory_structs[free_pos].physical_object_active = 1; + own_shared_memory_pos_ = free_pos; + } + + ACE_NEW_NORETURN ( + synchronize_watchdog_, + FAPI::Acyclic::IPC::Synchronize::Watchdog (this)); + if (synchronize_watchdog_ == 0) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error allocating FAPI::Acyclic::IPC::Synchronize::Watchdog.\n"); + + error.error_code_ = + FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED; + + error.reason_ = "Error allocating FAPI::Acyclic::IPC::Synchronize::Watchdog."; + fapia_shared_memory_.unmap (); + fapia_shared_memory_.close (); + return -1; + } + + // Start up the created thread; + if (synchronize_watchdog_->activate () == -1) + { + FAPIA_DEBUG ( + LM_ALERT, + "Error activating watchdog.\n"); + + error.error_code_ = + FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED; + + error.reason_ = "Error activating watchdog."; + fapia_shared_memory_.unmap (); + fapia_shared_memory_.close (); + delete synchronize_watchdog_; + synchronize_watchdog_ = 0; + return -1; + } + + ACE_Thread::yield (); + ACE_OS::sleep(1); + + state_ = FAPI::Acyclic::IPC::Synchronize::Synchronize::RUNNING; + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + int Synchronize::deinit (void) + { + FAPIA_TRACE; + + // Check for valid state. + if (state_ != FAPI::Acyclic::IPC::Synchronize::Synchronize::RUNNING) + { + FAPIA_DEBUG ( + LM_ERROR, + "State is not RUNNING. Call init first\n"); + return -1; + } + + if (synchronize_watchdog_) + { + synchronize_watchdog_->shutdown (); + delete synchronize_watchdog_; + synchronize_watchdog_ = 0; + } + + { + ACE_Write_Guard lock ( + fapia_synchronize_mutex_); + + SharedMemoryStruct* shared_memory_structs = + ACE_static_cast (SharedMemoryStruct*, + (void *)((char*)fapia_shared_memory_.addr () + FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN)); + + // Deactivate own physical object. + if (this->own_shared_memory_pos_ < + FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT) + { + shared_memory_structs[own_shared_memory_pos_].physical_object_active = 0; + } + + // Test if any physical object is still active. + bool any_physical_object_is_active = false; + unsigned long i = 0; + for (i = 0; i < FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT; ++i) + { + if (shared_memory_structs[i].physical_object_active != 0) + { + any_physical_object_is_active = true; + break; + } + } + + // Close shared memory. + fapia_shared_memory_.close (); + + // If no object is active any more delete shared memory file. + if (!any_physical_object_is_active) + { + ACE_OS::unlink (fapia_synchronize_shared_memory_name_.c_str ()); + } + } + + state_ = FAPI::Acyclic::IPC::Synchronize::Synchronize::INITIAL; + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + int Synchronize::retrieve_physical_object_address ( + const ACE_CString& physical_object_name, + ACE_CString& physical_object_address, + FAPI::Acyclic::IPC::Synchronize::Error& error) + { + FAPIA_TRACE; + + error.error_code_ = FAPIA_ERROR_OK; + error.reason_ = ""; + + // Check for valid state. + if (state_ != FAPI::Acyclic::IPC::Synchronize::Synchronize::RUNNING) + { + FAPIA_DEBUG ( + LM_ERROR, + "State is not RUNNING. Call init first\n"); + + error.error_code_ = + FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED; + error.reason_ = "State is not RUNNING. Call init first"; + return -1; + } + + // Search the free place for initializing. + bool physical_object_name_found = false; + + { + ACE_Read_Guard lock ( + fapia_synchronize_mutex_); + + SharedMemoryStruct* shared_memory_structs = + ACE_static_cast (SharedMemoryStruct*, + (void *)((char*)fapia_shared_memory_.addr () + FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN)); + + + unsigned long i = 0; + for (i = 0; i < FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT; ++i) + { + // If this physical object already exists take this entry. + if (ACE_OS::strcmp ( + shared_memory_structs[i].physical_object_name, + physical_object_name.c_str ()) == 0) + { + if (shared_memory_structs[i].physical_object_active) + { + physical_object_address = + shared_memory_structs[i].physical_object_address; + physical_object_name_found = true; + } + break; + } + } + } + + if (!physical_object_name_found) + { + FAPIA_DEBUG ( + LM_ERROR, + "The physical object %C could not be found.\n", + physical_object_name.c_str ()); + + error.error_code_ = FAPIA_ERROR_OBJECT_NOT_FOUND; + + char tmp_error[1024]; + if (this->fapia_synchronize_shared_memory_name_.length () < + sizeof (tmp_error) - 50) + { + ACE_OS::sprintf( + tmp_error, + "The physical object %s could not be found.", + physical_object_name.c_str ()); + } + else + { + ACE_OS::sprintf( + tmp_error, + "The physical object could not be found."); + } + + error.reason_ = tmp_error; + return -1; + } + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + int Synchronize::disable_physical_object ( + const ACE_CString& physical_object_address, + FAPI::Acyclic::IPC::Synchronize::Error& error) + + { + FAPIA_TRACE; + + error.error_code_ = FAPIA_ERROR_OK; + error.reason_ = ""; + + // Check for valid state. + if (state_ != FAPI::Acyclic::IPC::Synchronize::Synchronize::RUNNING) + { + FAPIA_DEBUG ( + LM_ERROR, + "State is not RUNNING. Call init first\n"); + + error.error_code_ = + FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED; + error.reason_ = "State is not RUNNING. Call init first"; + return -1; + } + + bool physical_object_address_found = false; + + { + ACE_Write_Guard lock ( + fapia_synchronize_mutex_); + // Search the free place for initializing. + + SharedMemoryStruct* shared_memory_structs = + ACE_static_cast (SharedMemoryStruct*, + (void *)((char*)fapia_shared_memory_.addr () + FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN)); + + unsigned long i = 0; + for (i = 0; i < FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT; ++i) + { + // If this physical object already exists take this entry. + if (ACE_OS::strcmp ( + shared_memory_structs[i].physical_object_address, + physical_object_address.c_str ()) == 0) + { + if (shared_memory_structs[i].physical_object_active) + { + shared_memory_structs[i].physical_object_active = 0; + } + physical_object_address_found = true; + break; + } + } + } + + if (!physical_object_address_found) + { + FAPIA_DEBUG ( + LM_DEBUG, + "The physical object address %C could not be found.\n", + physical_object_address.c_str ()); + + error.error_code_ = FAPIA_ERROR_OBJECT_NOT_FOUND; + + char tmp_error[1024]; + if (this->fapia_synchronize_shared_memory_name_.length () < + sizeof (tmp_error) - 50) + { + ACE_OS::sprintf( + tmp_error, + "The physical object address %s could not be found.", + physical_object_address.c_str ()); + } + else + { + ACE_OS::sprintf( + tmp_error, + "The physical object address could not be found."); + } + + error.reason_ = tmp_error; + return -1; + } + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + int Synchronize::create_or_read_shared_memory (void) + { + // Initialize shared memory. + unsigned long len = + FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN + + FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT * + sizeof (FAPI::Acyclic::IPC::Synchronize::SharedMemoryStruct); + + int rc = 0; + if (fapia_shared_memory_.handle () == ACE_INVALID_HANDLE) + { + // Test if it exists. + if (fapia_shared_memory_.open ( + this->fapia_synchronize_shared_memory_name_.c_str (), + O_RDWR) == -1) + { + + if (mkdir_recursive (fapia_synchronize_shared_memory_name_.c_str ()) == -1) + { + FAPIA_DEBUG ( + LM_ERROR, + "Directory %s could not be generated.\n", + fapia_synchronize_shared_memory_name_.c_str ()); + return -1; + } + + // Create a new file. + rc = fapia_shared_memory_.map ( + this->fapia_synchronize_shared_memory_name_.c_str (), + len, + O_RDWR | O_CREAT, + ACE_DEFAULT_FILE_PERMS, + PROT_RDWR, + MAP_SHARED, + 0, + 0, + 0); + // Initialize shared memory and write it to file. + if (rc == 0) + { + char* shared_memory_version = + ACE_static_cast (char*, + fapia_shared_memory_.addr ()); + + SharedMemoryStruct* shared_memory_structs = + ACE_static_cast (SharedMemoryStruct*, + (void *)((char*)fapia_shared_memory_.addr () + FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN)); + + ACE_OS::sprintf (shared_memory_version, "%010lu", FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION); + ACE_OS::memset (shared_memory_structs, 0, len - FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN); + fapia_shared_memory_.close (); + rc = fapia_shared_memory_.map ( + this->fapia_synchronize_shared_memory_name_.c_str (), + len, + O_RDWR, + ACE_DEFAULT_FILE_PERMS, + PROT_RDWR, + MAP_SHARED, + 0, + 0, + 0); + } + } + else + { + // Read the existing file + rc = fapia_shared_memory_.map ( + fapia_shared_memory_.handle (), + len, + PROT_RDWR, + MAP_SHARED, + 0, + 0, + 0); + } + if (rc == -1) + { + FAPIA_DEBUG ( + LM_ERROR, + "Shared memory %C could not be read or created.\n", + this->fapia_synchronize_shared_memory_name_.c_str ()); + return -1; + } + + // Get version number of shared memory and compare it. + if (len >= FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN) + { + char tmp [FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN + 1]; + + char* shared_memory_version = + ACE_static_cast (char*, + fapia_shared_memory_.addr ()); + ACE_OS::memcpy (tmp, shared_memory_version, FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN); + tmp[FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN] = '\0'; + + int shared_memory_version_number = ACE_OS::atoi (tmp); + + if (shared_memory_version_number != FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION) + { + FAPIA_DEBUG ( + LM_ERROR, + "Shared memory version number should be %u but it is %u.\n", + FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION, + shared_memory_version_number); + fapia_shared_memory_.close (); + return -1; + } + } + + if (len != fapia_shared_memory_.size ()) + { + FAPIA_DEBUG ( + LM_ERROR, + "Size of shared memory should be %u but it is %u.\n", + len, + fapia_shared_memory_.size ()); + fapia_shared_memory_.close (); + return -1; + } + + } + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + int Synchronize::mkdir_recursive (const char * const directory) + { + + // If length of directory is empty just return. + unsigned long directory_len = ACE_OS::strlen (directory); + if (directory_len == 0) + { + return 0; + } + + // Search first slash. + unsigned long i = 0; + bool slash_found = false; + for (i = 0; !slash_found && i < directory_len; ++i) + { + switch (directory[i]) + { + case '\\': + case '/': + slash_found = true; + --i; // Correct loop counter because after the + //loop it is increased. + break; + default: + break; + } + } + + // No slash inside. This means no directory must be created. + if (!slash_found) + { + return 0; + } + + // If a root slash is there look for the next slash. + if (i == 0 || (i == 2 && directory[1] == ':')) + { + ++i; + slash_found = false; + for (; !slash_found && i < directory_len; ++i) + { + switch (directory[i]) + { + case '\\': + case '/': + slash_found = true; + break; + default: + break; + } + } + + // No further slash inside. This means no directory + // must be created. + if (!slash_found) + { + return 0; + } + } + + + char* tmp_directory = 0; + ACE_NEW_NORETURN (tmp_directory, char[directory_len + 1]); + if (tmp_directory == 0) + { + FAPIA_DEBUG ( + LM_ERROR, + "Memory with len %u for tmp_directory could not be allocated.\n", + directory_len + 1); + return -1; + } + + // Make direcories recursively. + while (slash_found) + { + slash_found = false; + ACE_OS::memcpy (tmp_directory, directory, i - 1); + tmp_directory[i - 1] = '\0'; + + // If directory does not exist create it. + ACE_stat ace_stat; + if (ACE_OS::stat (tmp_directory, &ace_stat) == -1) + { + if (ACE_OS::mkdir (tmp_directory) == -1) + { + FAPIA_DEBUG ( + LM_ERROR, + "Directory %C could not be created.\n", + tmp_directory); + delete tmp_directory; + tmp_directory = 0; + return -1; + } + } + + for (; !slash_found && i < directory_len; ++i) + { + switch (directory[i]) + { + case '\\': + case '/': + slash_found = true; + break; + default: + break; + } + } + } + + delete tmp_directory; + tmp_directory = 0; + + return 0; + } + + + } /* namespace Synchronize */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeError.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeError.cpp Thu Jul 19 07:20:10 2007 @@ -0,0 +1,52 @@ +// $Id$ + + +#include "../interface/FAPIAIPCSynchronizeError.h" +#include "../../interface/FAPIATrace.h" + + +#if !defined (__ACE_INLINE__) +#include "../interface/FAPIAIPCSynchronizeError.i" +#endif /* __ACE_INLINE__ */ + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Synchronize + { + +/* ---------------------------------------------------------------------------*/ + + Error::Error (void) + { + FAPIA_TRACE; + open(); + } + +/* ---------------------------------------------------------------------------*/ + + Error::Error (const Error& init) + { + FAPIA_TRACE; + open(); + copy(init); + } + +/* ---------------------------------------------------------------------------*/ + + Error::~Error (void) + { + FAPIA_TRACE; + close(); + } + +/* ---------------------------------------------------------------------------*/ + + + }/* namespace Synchronize */ + }/* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeInit.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeInit.cpp Thu Jul 19 07:20:10 2007 @@ -0,0 +1,52 @@ +// $Id$ + + +#include "../interface/FAPIAIPCSynchronizeInit.h" +#include "../../interface/FAPIATrace.h" + + +#if !defined (__ACE_INLINE__) +#include "../interface/FAPIAIPCSynchronizeInit.i" +#endif /* __ACE_INLINE__ */ + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Synchronize + { + +/* ---------------------------------------------------------------------------*/ + + Init::Init (void) + { + FAPIA_TRACE; + open(); + } + +/* ---------------------------------------------------------------------------*/ + + Init::Init (const Init& init) + { + FAPIA_TRACE; + open(); + copy(init); + } + +/* ---------------------------------------------------------------------------*/ + + Init::~Init (void) + { + FAPIA_TRACE; + close(); + } + +/* ---------------------------------------------------------------------------*/ + + + }/* namespace Synchronize */ + }/* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeSharedMemoryStruct.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeSharedMemoryStruct.h Thu Jul 19 07:20:10 2007 @@ -0,0 +1,57 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCSynchronizeSharedMemoryStruct.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_SYNCHRONIZE_SHARED_MEMORY_STRUCT_H_ +#define _FAPI_ACYCLIC_IPC_SYNCHRONIZE_SHARED_MEMORY_STRUCT_H_ + +#define FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_NAME_MAX_SIZE 256 +#define FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_ADDRESS_MAX_SIZE 256 +#define FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT 1024 + +#define FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION 1 +#define FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN 10 + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Synchronize + { + + /** + * @struct Synchronize + * + * @brief This is the implementation of IPC::ISynchronize + * interface. + * + */ + struct SharedMemoryStruct + { + /// Name of the physical object. + char physical_object_name[FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_NAME_MAX_SIZE]; + + /// Address of the physical object. + char physical_object_address[FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_ADDRESS_MAX_SIZE]; + + /// If 0 the physical object is not active else it is. + char physical_object_active; + + }; /* struct SharedMemoryStruct */ + + } /* namespace Synchronize */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_SYNCHRONIZE_SHARED_MEMORY_STRUCT_H_ */ Added: fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeWatchdog.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeWatchdog.cpp Thu Jul 19 07:20:10 2007 @@ -0,0 +1,115 @@ +// $Id$ + + +#include "../interface/FAPIAIPCSynchronize.h" +#include "FAPIAIPCSynchronizeWatchdog.h" +#include "../../interface/FAPIATrace.h" +#include + + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Synchronize + { + +/* ---------------------------------------------------------------------------*/ + + Watchdog::Watchdog ( + FAPI::Acyclic::IPC::Synchronize::Synchronize* fapia_ipc_synchronize) : + fapia_ipc_synchronize_ (fapia_ipc_synchronize) + { + FAPIA_TRACE; + + shutdown_ = false; + } + +/* ---------------------------------------------------------------------------*/ + + Watchdog::~Watchdog (void) + { + FAPIA_TRACE; + } + +/* ---------------------------------------------------------------------------*/ + + int Watchdog::svc (void) + { + FAPIA_TRACE; + + while (!shutdown_) + { + ACE_OS::sleep (1); + + if (!shutdown_) + { + bool update_necessary = false; + + // Test if own module is deactivated. + { + ACE_Read_Guard lock ( + fapia_ipc_synchronize_->fapia_synchronize_mutex_); + + SharedMemoryStruct* shared_memory_structs = + ACE_static_cast ( + SharedMemoryStruct*, + (void *)((char*)fapia_ipc_synchronize_->fapia_shared_memory_.addr () + FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN)); + + if (!shared_memory_structs + [fapia_ipc_synchronize_->own_shared_memory_pos_].physical_object_active) + { + update_necessary = true; + } + } + + // If own module is deactivated reactivate it. + if (update_necessary) + { + ACE_Write_Guard lock ( + fapia_ipc_synchronize_->fapia_synchronize_mutex_); + + SharedMemoryStruct* shared_memory_structs = + ACE_static_cast ( + SharedMemoryStruct*, + (void *)((char*)fapia_ipc_synchronize_->fapia_shared_memory_.addr () + FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN)); + + if (!shared_memory_structs + [fapia_ipc_synchronize_->own_shared_memory_pos_].physical_object_active) + { + // Set own physical object to active. + shared_memory_structs + [fapia_ipc_synchronize_->own_shared_memory_pos_].physical_object_active = 1; + } + } + } + } + + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + int Watchdog::shutdown (void) + { + FAPIA_TRACE; + shutdown_ = true; + this->wait (); + return 0; + } + +/* ---------------------------------------------------------------------------*/ + + int Watchdog::close (u_long flags) + { + FAPIA_TRACE; + ACE_UNUSED_ARG (flags); + return 0; + } + + } /* namespace Synchronize */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ Added: fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeWatchdog.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeWatchdog.h Thu Jul 19 07:20:10 2007 @@ -0,0 +1,103 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FAPIAIPCSynchronizeWatchdog.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPI_ACYCLIC_IPC_SYNCHRONIZE_WATCHDOG_H_ +#define _FAPI_ACYCLIC_IPC_SYNCHRONIZE_WATCHDOG_H_ + +#include /**/ +#include /**/ +//#include "../../interface/FAPIA.h" +//#include "../../FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestWriteResponse.h" + + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Synchronize + { + + // Forward declaration. + class Synchronize; + + /** + * @class Watchdog + * + * @brief This command handler acts as a watchdog for the + * shared memory + * + */ + class Watchdog : public ::ACE_Task + + { + + public: + /** + * @brief Constructor. + * + */ + Watchdog ( + FAPI::Acyclic::IPC::Synchronize::Synchronize* fapia_ipc_synchronize); + + /** + * @brief Destructor. + * + */ + virtual ~Watchdog (void); + + /** + * Shutdowns the thread. + */ + int shutdown (void); + + /** + * Closes the command handler. + */ + virtual int close (u_long flags = 0); + + protected: + + /// Pointer to synchronize instance. + FAPI::Acyclic::IPC::Synchronize::Synchronize* fapia_ipc_synchronize_; + + /// Flag to shutdown. + bool shutdown_; + + /** + * Virtual function for receiving data. + */ + virtual int svc (void); + + private: + + /** + * Copy Constructor is private, so this object cannot be copied. + */ + Watchdog (const Watchdog&); + + /** + * Assignment operator is private, so this object cannot be copied. + */ + const Watchdog& operator= (const Watchdog&); + + + + }; /* class Watchdog */ + + } /* namespace Synchronize */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif /* _FAPI_ACYCLIC_IPC_SYNCHRONIZE_WATCHDOG_H_ */ Added: fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/MPC/one_process.mpc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/MPC/one_process.mpc Thu Jul 19 07:20:10 2007 @@ -0,0 +1,13 @@ +project : FAPIAIPCSynchronizepuresource, acecomponentsexe, taocomponentsexe, cppunitcomponentsexe { + + exename = test_fapia_synchronize_one_process + + header_files { + ../../source/*.h + } + + source_files { + ../../source/*.cpp + } + +} \ No newline at end of file Added: fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/MPC/one_process.mwc ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/MPC/one_process.mwc Thu Jul 19 07:20:10 2007 @@ -0,0 +1,3 @@ +workspace { + one_process.mpc +} \ No newline at end of file Added: fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/makefile ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/makefile Thu Jul 19 07:20:10 2007 @@ -0,0 +1,24 @@ +MODULE=one_process + +TYPES:= VC8_STATIC + +NMAKE_STATIC_CFG="Static_Multi_Ansi_Debug_DllRTL" "Static_Multi_Ansi_Release_DllRTL" +NMAKE_DLL_CFG= + + +MPC_DIRS := $(VIEW_ROOT)/IOFramework_vob/FAPIA/make/MPC/config $(VIEW_ROOT)/DevTools_vob/MPC/config $(VIEW_ROOT)/ACE_wrappers_vob/ACE_wrappers/make/MPC/config $(VIEW_ROOT)/DevTools_vob/cppunit/make/MPC/config + +ALL: MPC BUILD + +BUILD: BUILD_ALL + +CLEAN: CLEAN_BUILD CLEAN_MPC + +REALCLEAN: REALCLEAN_BUILD CLEAN_MPC + +EXPORT: EXPORT_ALL + +%include <.homag_make_rules> +%include <.homag_mpc_make_rules> +%include <.homag_build_make_rules> +%include <.homag_export_make_rules> Added: fapia-trunk/FAPIAIPCSynchronize/test/one_process/makeall.bat ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/test/one_process/makeall.bat Thu Jul 19 07:20:10 2007 @@ -0,0 +1,2 @@ +set ARP_Tools=%cd%\..\..\..\..\..\DevTools_vob\ARP-Tools +ccperl %arp_tools%\mk.pl %* \ No newline at end of file Added: fapia-trunk/FAPIAIPCSynchronize/test/one_process/makefile ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/test/one_process/makefile Thu Jul 19 07:20:10 2007 @@ -0,0 +1,10 @@ +SPEC = * +MODULE_DIRS= $(SPEC,*D) +MODULE_DIRS = ./make + + +ALL: $(MODULE_DIRS) $(MAKETARGETS) + %echo ALL_SOURCES $(.SOURCES) + +%include <.homag_make_rules> +%include <.homag_release_make_rules> Added: fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/main.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/main.cpp Thu Jul 19 07:20:10 2007 @@ -0,0 +1,21 @@ + +#include +#include +#include +#include +#include +#include + +#include /**/ + + +int main( int argc, char **argv) +{ + ACE::init (); + CppUnit::TextUi::TestRunner runner; + CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); + runner.addTest( registry.makeTest() ); + bool wasSuccessful = runner.run( "", false); + ACE::fini (); + return wasSuccessful; +} Added: fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/test_fapia_synchronize_one_process.cpp ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/test_fapia_synchronize_one_process.cpp Thu Jul 19 07:20:10 2007 @@ -0,0 +1,308 @@ +// $Id$ + + +#include "test_fapia_synchronize_one_process.h" +#include "../../../interface/FAPIAIPCSynchronize.h" + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Synchronize + { + namespace Test + { + + CPPUNIT_TEST_SUITE_REGISTRATION (OneProcessTest); + +/*---------------------------------------------------------------------------*/ + + OneProcessTest::OneProcessTest() + { + } + +/*---------------------------------------------------------------------------*/ + + void OneProcessTest::setUp() + { + } + +/*---------------------------------------------------------------------------*/ + + void OneProcessTest::tearDown() + { + } + +/*---------------------------------------------------------------------------*/ + + void OneProcessTest::test_init (void) + { + FAPI::Acyclic::IPC::Synchronize::Init init; + FAPI::Acyclic::IPC::Synchronize::Error error; + FAPI::Acyclic::IPC::Synchronize::Synchronize synchronize; + + init.physical_object_address_ = "127.0.0.0"; + init.physical_object_name_ = "one_process_test"; + + // Empty name. + init.fapia_shared_memory_name_ = ""; + int rc = synchronize.init (init, error); + + CPPUNIT_ASSERT (rc == -1); + CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED); + CPPUNIT_ASSERT (error.reason_.length () > 0); + + + + // Valid name. + init.fapia_shared_memory_name_ = "0123"; + // Delete file if it exists. + ACE_OS::unlink (init.fapia_shared_memory_name_.c_str ()); + rc = synchronize.init (init, error); + + CPPUNIT_ASSERT (rc == 0); + CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OK); + CPPUNIT_ASSERT (error.reason_.length () == 0); + + // Valid name, deinit was not called. + rc = synchronize.init (init, error); + + CPPUNIT_ASSERT (rc == -1); + CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED); + CPPUNIT_ASSERT (error.reason_.length () != 0); + + // Deinit. + rc = synchronize.deinit (); + CPPUNIT_ASSERT (rc == 0); + + // Deinit. Init was not done + rc = synchronize.deinit (); + CPPUNIT_ASSERT (rc == -1); + + // Valid name, file already exists. + rc = synchronize.init (init, error); + + CPPUNIT_ASSERT (rc == 0); + CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OK); + CPPUNIT_ASSERT (error.reason_.length () == 0); + + // Deinit. + rc = synchronize.deinit (); + CPPUNIT_ASSERT (rc == 0); + + // Delete file. + ACE_OS::unlink (init.fapia_shared_memory_name_.c_str ()); + + } + +/*---------------------------------------------------------------------------*/ + + + void OneProcessTest::test_non_existing_path (void) + { + + { + FAPI::Acyclic::IPC::Synchronize::Init init; + FAPI::Acyclic::IPC::Synchronize::Error error; + FAPI::Acyclic::IPC::Synchronize::Synchronize synchronize; + + init.physical_object_address_ = "127.0.0.0"; + init.physical_object_name_ = "one_process_test"; + + // Non existing pathname. + init.fapia_shared_memory_name_ = "C:\\FAPIA\\nonexistingpath\\nonexistingfile.fapia"; + int rc = synchronize.init (init, error); + + CPPUNIT_ASSERT (rc == 0); + CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OK); + CPPUNIT_ASSERT (error.reason_.length () == 0); + + // Deinit. + rc = synchronize.deinit (); + CPPUNIT_ASSERT (rc == 0); + + init.fapia_shared_memory_name_ = "C:\\FAPIA/nonexistingpath2\\nonexistingfile.fapia"; + rc = synchronize.init (init, error); + + CPPUNIT_ASSERT (rc == 0); + CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OK); + CPPUNIT_ASSERT (error.reason_.length () == 0); + + // Deinit. + rc = synchronize.deinit (); + CPPUNIT_ASSERT (rc == 0); + + } + + ACE_OS::unlink ("C:\\FAPIA\\nonexistingpath2\\nonexistingfile.fapia"); + ACE_OS::unlink ("C:\\FAPIA\\nonexistingpath\\nonexistingfile.fapia"); + ::rmdir ("C:\\FAPIA\\nonexistingpath2"); + ::rmdir ("C:\\FAPIA\\nonexistingpath"); + ::rmdir ("C:\\FAPIA"); + + } + +/*---------------------------------------------------------------------------*/ + + + void OneProcessTest::test_existing_invalid_file (void) + { + FAPI::Acyclic::IPC::Synchronize::Init init; + init.physical_object_address_ = "127.0.0.0"; + init.physical_object_name_ = "one_process_test"; + init.fapia_shared_memory_name_ = "0123"; + char tmp[FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN + 1]; + ACE_OS::sprintf (tmp, "%010lu", FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION); + + FILE* fp = ACE_OS::fopen ( + init.fapia_shared_memory_name_.c_str (), + "w+"); + + ACE_OS::fwrite ( + tmp, + FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN, + 1, + fp); + + ACE_OS::fwrite ( + init.physical_object_name_.c_str (), + init.physical_object_name_.length (), + 1, + fp); + + ACE_OS::fclose (fp); + + { + FAPI::Acyclic::IPC::Synchronize::Error error; + FAPI::Acyclic::IPC::Synchronize::Synchronize synchronize; + + // Non existing pathname. + int rc = synchronize.init (init, error); + + CPPUNIT_ASSERT (rc == 0); + CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OK); + CPPUNIT_ASSERT (error.reason_.length () == 0); + } + + ACE_OS::unlink (init.fapia_shared_memory_name_.c_str ()); + + } + +/*---------------------------------------------------------------------------*/ + + + void OneProcessTest::test_disable_retrieve_physical_object (void) + { + + /******************************************************/ + + FAPI::Acyclic::IPC::Synchronize::Init init; + FAPI::Acyclic::IPC::Synchronize::Error error; + FAPI::Acyclic::IPC::Synchronize::Synchronize synchronize; + + init.physical_object_address_ = "127.0.0.0"; + init.physical_object_name_ = "one_process_test"; + init.fapia_shared_memory_name_ = "0123"; + + /******************************************************/ + + ACE_CString physical_object_name (init.physical_object_name_); + ACE_CString physical_object_address; + int rc = synchronize.retrieve_physical_object_address ( + physical_object_name, + physical_object_address, + error); + + CPPUNIT_ASSERT (rc == -1); + CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED); + CPPUNIT_ASSERT (error.reason_.length () != 0); + + + /******************************************************/ + + rc = synchronize.disable_physical_object ( + physical_object_address, + error); + + CPPUNIT_ASSERT (rc == -1); + CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED); + CPPUNIT_ASSERT (error.reason_.length () != 0); + + + /******************************************************/ + + rc = synchronize.init (init, error); + CPPUNIT_ASSERT (rc == 0); + CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OK); + CPPUNIT_ASSERT (error.reason_.length () == 0); + + + /******************************************************/ + + rc = synchronize.retrieve_physical_object_address ( + physical_object_name, + physical_object_address, + error); + + CPPUNIT_ASSERT (rc == 0); + CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OK); + CPPUNIT_ASSERT (error.reason_.length () == 0); + CPPUNIT_ASSERT (ACE_OS::strcmp (physical_object_address.c_str (), init.physical_object_address_.c_str ()) == 0); + + + /******************************************************/ + + rc = synchronize.disable_physical_object ( + physical_object_address, + error); + + CPPUNIT_ASSERT (rc == 0); + CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OK); + CPPUNIT_ASSERT (error.reason_.length () == 0); + + /******************************************************/ + + rc = synchronize.disable_physical_object ( + physical_object_address, + error); + + CPPUNIT_ASSERT (rc == 0); + CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OK); + CPPUNIT_ASSERT (error.reason_.length () == 0); + + + /******************************************************/ + + rc = synchronize.retrieve_physical_object_address ( + physical_object_name, + physical_object_address, + error); + + CPPUNIT_ASSERT (rc == -1); + CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OBJECT_NOT_FOUND); + CPPUNIT_ASSERT (error.reason_.length () != 0); + + + /******************************************************/ + + // Deinit. + rc = synchronize.deinit (); + CPPUNIT_ASSERT (rc == 0); + + + /******************************************************/ + + + } + +/*---------------------------------------------------------------------------*/ + + + } /* namespace Test */ + } /* namespace Synchronize */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + Added: fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/test_fapia_synchronize_one_process.h ============================================================================== --- (empty file) +++ fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/test_fapia_synchronize_one_process.h Thu Jul 19 07:20:10 2007 @@ -0,0 +1,58 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file marshallingtest.h + * + * $Id$ + * + * @author Thomas Rothfuss + */ +//============================================================================= + +#ifndef _FAPIA_IPC_SYNCHRONIZE_ONE_PROCESS_TEST_H_ +#define _FAPIA_IPC_SYNCHRONIZE_ONE_PROCESS_TEST_H_ + +#include + +namespace FAPI + { + namespace Acyclic + { + namespace IPC + { + namespace Synchronize + { + namespace Test + { + class OneProcessTest : public CppUnit::TestFixture + { + public: + CPPUNIT_TEST_SUITE (OneProcessTest); + CPPUNIT_TEST (test_init); + CPPUNIT_TEST (test_non_existing_path); + CPPUNIT_TEST (test_existing_invalid_file); + CPPUNIT_TEST (test_disable_retrieve_physical_object); + CPPUNIT_TEST_SUITE_END (); + + private: + + public: + OneProcessTest (void); + + void setUp (void); + void tearDown (void); + + void test_init (void); + void test_non_existing_path (void); + void test_existing_invalid_file (void); + void test_disable_retrieve_physical_object (void); + }; /* class OneProcessTest */ + + } /* namespace Test */ + } /* namespace Synchronize */ + } /* namespace IPC */ + } /* namespace Acyclic */ + } /* namespace FAPI */ + +#endif // _FAPIA_IPC_SYNCHRONIZE_ONE_PROCESS_TEST_H_ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:47:00 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:47:00 +0200 Subject: [OSADL-svn-commits] r89 - in fapia-trunk/make/MPC: . config Message-ID: <200710020947.l929l0Ha021377@www.osadl.org> Author: tb10rts Date: Thu Jul 19 07:23:28 2007 New Revision: 89 Log: Added: fapia-trunk/make/MPC/ fapia-trunk/make/MPC/FAPIA.mpc fapia-trunk/make/MPC/FAPIA.mwc fapia-trunk/make/MPC/config/ fapia-trunk/make/MPC/config/FAPIAComponentsexe.mpb fapia-trunk/make/MPC/config/FAPIAConfigurationcomponentsexe.mpb fapia-trunk/make/MPC/config/FAPIAConfigurationdefaults.mpb fapia-trunk/make/MPC/config/FAPIAConfigurationdependencies.mpb fapia-trunk/make/MPC/config/FAPIAConfigurationexe.mpb fapia-trunk/make/MPC/config/FAPIAConfigurationlocalcomponents.mpb fapia-trunk/make/MPC/config/FAPIAConfigurationlocalcomponentsexe.mpb fapia-trunk/make/MPC/config/FAPIAConfigurationlocalexe.mpb fapia-trunk/make/MPC/config/FAPIAConfigurationpureexe.mpb fapia-trunk/make/MPC/config/FAPIAConfigurationpuresource.mpb fapia-trunk/make/MPC/config/FAPIAConfigurationsource.mpb fapia-trunk/make/MPC/config/FAPIAControllercomponentsexe.mpb fapia-trunk/make/MPC/config/FAPIAControllerdefaults.mpb fapia-trunk/make/MPC/config/FAPIAControllerdependencies.mpb fapia-trunk/make/MPC/config/FAPIAControllerexe.mpb fapia-trunk/make/MPC/config/FAPIAControllerlocalcomponents.mpb fapia-trunk/make/MPC/config/FAPIAControllerlocalcomponentsexe.mpb fapia-trunk/make/MPC/config/FAPIAControllerlocalexe.mpb fapia-trunk/make/MPC/config/FAPIAControllerpureexe.mpb fapia-trunk/make/MPC/config/FAPIAControllerpuresource.mpb fapia-trunk/make/MPC/config/FAPIAControllersource.mpb fapia-trunk/make/MPC/config/FAPIAIPCParametercomponentsexe.mpb fapia-trunk/make/MPC/config/FAPIAIPCParameterdefaults.mpb fapia-trunk/make/MPC/config/FAPIAIPCParameterdependencies.mpb fapia-trunk/make/MPC/config/FAPIAIPCParameterexe.mpb fapia-trunk/make/MPC/config/FAPIAIPCParameterlocalcomponents.mpb fapia-trunk/make/MPC/config/FAPIAIPCParameterlocalcomponentsexe.mpb fapia-trunk/make/MPC/config/FAPIAIPCParameterlocalexe.mpb fapia-trunk/make/MPC/config/FAPIAIPCParameterpureexe.mpb fapia-trunk/make/MPC/config/FAPIAIPCParameterpuresource.mpb fapia-trunk/make/MPC/config/FAPIAIPCParametersource.mpb fapia-trunk/make/MPC/config/FAPIAIPCSynchronizecomponentsexe.mpb fapia-trunk/make/MPC/config/FAPIAIPCSynchronizedefaults.mpb fapia-trunk/make/MPC/config/FAPIAIPCSynchronizedependencies.mpb fapia-trunk/make/MPC/config/FAPIAIPCSynchronizeexe.mpb fapia-trunk/make/MPC/config/FAPIAIPCSynchronizelocalcomponents.mpb fapia-trunk/make/MPC/config/FAPIAIPCSynchronizelocalcomponentsexe.mpb fapia-trunk/make/MPC/config/FAPIAIPCSynchronizelocalexe.mpb fapia-trunk/make/MPC/config/FAPIAIPCSynchronizepureexe.mpb fapia-trunk/make/MPC/config/FAPIAIPCSynchronizepuresource.mpb fapia-trunk/make/MPC/config/FAPIAIPCSynchronizesource.mpb fapia-trunk/make/MPC/config/FAPIAdefaults.mpb fapia-trunk/make/MPC/config/FAPIAdependencies.mpb Added: fapia-trunk/make/MPC/FAPIA.mpc ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/FAPIA.mpc Thu Jul 19 07:23:28 2007 @@ -0,0 +1,11 @@ + +project : FAPIAConfigurationpuresource, FAPIAControllerpuresource, FAPIAIPCParameterpuresource, FAPIAIPCSynchronizepuresource, acecomponentsexe, taocomponentsexe, xercescomponentsexe { + + specific (vc6, vc8, nmake) { + Static_Multi_Ansi_Debug_DllRTL::staticflags -= "ACE_AS_STATIC_LIBS" "TAO_AS_STATIC_LIBS" + Static_Multi_Ansi_Release_DllRTL::staticflags -= "ACE_AS_STATIC_LIBS" "TAO_AS_STATIC_LIBS" + Static_Multi_Unicode_Debug_DllRTL::staticflags -= "ACE_AS_STATIC_LIBS" "TAO_AS_STATIC_LIBS" + Static_Multi_Unicode_Release_DllRTL::staticflags -= "ACE_AS_STATIC_LIBS" "TAO_AS_STATIC_LIBS" + } + +} \ No newline at end of file Added: fapia-trunk/make/MPC/FAPIA.mwc ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/FAPIA.mwc Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ +workspace { + FAPIA.mpc +} \ No newline at end of file Added: fapia-trunk/make/MPC/config/FAPIAComponentsexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAComponentsexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,50 @@ +project : FAPIAdefaults, FAPIAConfigurationdependencies, FAPIAControllerdependencies, FAPIAIPCParameterdependencies, FAPIAIPCSynchronizedependencies { + after += FAPIA + + specific (vc6, nmake, vc8) { + Static_Multi_Ansi_Debug_DllRTL::libs += FAPIA + Static_Multi_Ansi_Release_DllRTL::libs += FAPIA + Static_Multi_Ansi_Debug_StaticRTL::libs += FAPIA + Static_Multi_Ansi_Release_StaticRTL::libs += FAPIA + Static_Multi_Unicode_Debug_DllRTL::libs += FAPIA + Static_Multi_Unicode_Release_DllRTL::libs += FAPIA + Static_Multi_Unicode_Debug_StaticRTL::libs += FAPIA + Static_Multi_Unicode_Release_StaticRTL::libs += FAPIA + Dll_Multi_Ansi_Debug_DllRTL::libs += FAPIAs + Dll_Multi_Ansi_Release_DllRTL::libs += FAPIAs + Dll_Multi_Ansi_Debug_StaticRTL::libs += FAPIAs + Dll_Multi_Ansi_Release_StaticRTL::libs += FAPIAs + Dll_Multi_Unicode_Debug_DllRTL::libs += FAPIAs + Dll_Multi_Unicode_Release_DllRTL::libs += FAPIAs + Dll_Multi_Unicode_Debug_StaticRTL::libs += FAPIAs + Dll_Multi_Unicode_Release_StaticRTL::libs += FAPIAs + } + + specific (automake) { + lit_libs += FAPIA + } + + specific (make) { + } + + specific (nmake) { + libpaths += $(FAPIA_ROOT)/release/nmake + } + + specific (vc6) { + libpaths += $(FAPIA_ROOT)/release/nmake + } + + specific (vc8) { + libpaths += $(FAPIA_ROOT)/release/vc8 + } + + specific (make) { + } + + specific (automake) { + linkflags += -L$(FAPIA_ROOT)/release/i686_linux32 + } + + +} Added: fapia-trunk/make/MPC/config/FAPIAConfigurationcomponentsexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAConfigurationcomponentsexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAConfigurationdependencies, FAPIAConfigurationexe { +} Added: fapia-trunk/make/MPC/config/FAPIAConfigurationdefaults.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAConfigurationdefaults.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAdefaults { +} Added: fapia-trunk/make/MPC/config/FAPIAConfigurationdependencies.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAConfigurationdependencies.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAdependencies, xercescomponentsexe { +} \ No newline at end of file Added: fapia-trunk/make/MPC/config/FAPIAConfigurationexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAConfigurationexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,24 @@ + +project : FAPIAConfigurationpureexe { + + specific (nmake) { + libpaths += $(FAPIA_ROOT)/FAPIAConfiguration/release/nmake + } + + specific (vc6) { + libpaths += $(FAPIA_ROOT)/FAPIAConfiguration/release/nmake + } + + specific (vc8) { + libpaths += $(FAPIA_ROOT)/FAPIAConfiguration/release/vc8 + } + + specific (make) { + libpaths += $(FAPIA_ROOT)/FAPIAConfiguration/release/os9 + } + + specific (automake) { + linkflags += -L$(FAPIA_ROOT)/FAPIAConfiguration/release/i686_linux32 + } + +} Added: fapia-trunk/make/MPC/config/FAPIAConfigurationlocalcomponents.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAConfigurationlocalcomponents.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAConfigurationdependencies { +} \ No newline at end of file Added: fapia-trunk/make/MPC/config/FAPIAConfigurationlocalcomponentsexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAConfigurationlocalcomponentsexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAConfigurationlocalexe, FAPIAConfigurationlocalcomponents { +} \ No newline at end of file Added: fapia-trunk/make/MPC/config/FAPIAConfigurationlocalexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAConfigurationlocalexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,24 @@ + +project : FAPIAConfigurationpureexe { + + specific (vc6) { + libpaths += $(FAPIA_ROOT)/FAPIAConfiguration/make/vc6/run + } + + specific (nmake) { + libpaths += $(FAPIA_ROOT)/FAPIAConfiguration/make/nmake/run + } + + specific (vc8) { + libpaths += $(FAPIA_ROOT)/FAPIAConfiguration/make/vc8/run + } + + specific (make) { + libpaths += $(FAPIA_ROOT)/FAPIAConfiguration/make/os9 + } + + specific (automake) { + linkflags += -L$(FAPIA_ROOT)/FAPIAConfiguration/make/i686_linux32/.libs + } + +} Added: fapia-trunk/make/MPC/config/FAPIAConfigurationpureexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAConfigurationpureexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,18 @@ + +project : FAPIAConfigurationdefaults { + + after += FAPIAConfiguration + + specific (vc6, nmake, vc8) { + libs += FAPIAConfiguration + } + + specific (automake) { + lit_libs += FAPIAConfiguration + } + + specific (make) { + libs += FAPIAConfiguration + } + +} Added: fapia-trunk/make/MPC/config/FAPIAConfigurationpuresource.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAConfigurationpuresource.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,27 @@ + +project : FAPIAConfigurationdefaults { + + source_files { + FAPIAConfiguration { + $(FAPIA_ROOT)/FAPIAConfiguration/source/*.cpp + } + } + + header_files { + FAPIAConfiguration_interface { + $(FAPIA_ROOT)/FAPIAConfiguration/interface/*.h + } + } + + header_files { + FAPIAConfiguration { + $(FAPIA_ROOT)/FAPIAConfiguration/source/*.h + } + } + + inline_files { + FAPIAConfiguration { + $(FAPIA_ROOT)/FAPIAConfiguration/interface/*.i + } + } +} Added: fapia-trunk/make/MPC/config/FAPIAConfigurationsource.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAConfigurationsource.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAConfigurationpuresource, FAPIAConfigurationlocalcomponents { +} Added: fapia-trunk/make/MPC/config/FAPIAControllercomponentsexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAControllercomponentsexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAControllerdependencies, FAPIAControllerexe { +} Added: fapia-trunk/make/MPC/config/FAPIAControllerdefaults.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAControllerdefaults.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAdefaults { +} Added: fapia-trunk/make/MPC/config/FAPIAControllerdependencies.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAControllerdependencies.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAdependencies { +} \ No newline at end of file Added: fapia-trunk/make/MPC/config/FAPIAControllerexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAControllerexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,24 @@ + +project : FAPIAControllerpureexe { + + specific (nmake) { + libpaths += $(FAPIA_ROOT)/FAPIAController/release/nmake + } + + specific (vc6) { + libpaths += $(FAPIA_ROOT)/FAPIAController/release/nmake + } + + specific (vc8) { + libpaths += $(FAPIA_ROOT)/FAPIAController/release/vc8 + } + + specific (make) { + libpaths += $(FAPIA_ROOT)/FAPIAController/release/os9 + } + + specific (automake) { + linkflags += -L$(FAPIA_ROOT)/FAPIAController/release/i686_linux32 + } + +} Added: fapia-trunk/make/MPC/config/FAPIAControllerlocalcomponents.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAControllerlocalcomponents.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAControllerdependencies, FAPIAConfigurationlocalcomponentsexe, FAPIAIPCParameterlocalcomponentsexe, FAPIAIPCSynchronizelocalcomponentsexe { +} \ No newline at end of file Added: fapia-trunk/make/MPC/config/FAPIAControllerlocalcomponentsexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAControllerlocalcomponentsexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAControllerlocalexe, FAPIAControllerlocalcomponents { +} \ No newline at end of file Added: fapia-trunk/make/MPC/config/FAPIAControllerlocalexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAControllerlocalexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,24 @@ + +project : FAPIAControllerpureexe { + + specific (vc6) { + libpaths += $(FAPIA_ROOT)/FAPIAController/make/vc6/run + } + + specific (nmake) { + libpaths += $(FAPIA_ROOT)/FAPIAController/make/nmake/run + } + + specific (vc8) { + libpaths += $(FAPIA_ROOT)/FAPIAController/make/vc8/run + } + + specific (make) { + libpaths += $(FAPIA_ROOT)/FAPIAController/make/os9 + } + + specific (automake) { + linkflags += -L$(FAPIA_ROOT)/FAPIAController/make/i686_linux32/.libs + } + +} Added: fapia-trunk/make/MPC/config/FAPIAControllerpureexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAControllerpureexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,18 @@ + +project : FAPIAControllerdefaults { + + after += FAPIAController + + specific (vc6, nmake, vc8) { + libs += FAPIAController + } + + specific (automake) { + lit_libs += FAPIAController + } + + specific (make) { + libs += FAPIAController + } + +} Added: fapia-trunk/make/MPC/config/FAPIAControllerpuresource.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAControllerpuresource.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,27 @@ + +project : FAPIAControllerdefaults { + + source_files { + FAPIAController { + $(FAPIA_ROOT)/FAPIAController/source/*.cpp + } + } + + header_files { + FAPIAController_interface { + $(FAPIA_ROOT)/FAPIAController/interface/*.h + } + } + + header_files { + FAPIAController { + $(FAPIA_ROOT)/FAPIAController/source/*.h + } + } + + inline_files { + FAPIAController { + $(FAPIA_ROOT)/FAPIAController/source/*.i + } + } +} Added: fapia-trunk/make/MPC/config/FAPIAControllersource.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAControllersource.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAControllerpuresource, FAPIAControllerlocalcomponents { +} Added: fapia-trunk/make/MPC/config/FAPIAIPCParametercomponentsexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCParametercomponentsexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAIPCParameterdependencies, FAPIAIPCParameterexe { +} Added: fapia-trunk/make/MPC/config/FAPIAIPCParameterdefaults.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCParameterdefaults.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,12 @@ + +project : FAPIAdefaults { + includes += $(FAPIA_ROOT)/FAPIAIPCParameter/interface + + specific (vc8) { + //Static_Multi_Unicode_Debug_StaticRTL::macros += ACE_NTRACE=0 + } + + specific (automake) { + //Debug::macros += ACE_NTRACE=0 + } +} Added: fapia-trunk/make/MPC/config/FAPIAIPCParameterdependencies.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCParameterdependencies.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAdependencies { +} \ No newline at end of file Added: fapia-trunk/make/MPC/config/FAPIAIPCParameterexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCParameterexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,24 @@ + +project : FAPIAIPCParameterpureexe { + + specific (nmake) { + libpaths += $(FAPIA_ROOT)/FAPIAIPCParameter/release/nmake + } + + specific (vc6) { + libpaths += $(FAPIA_ROOT)/FAPIAIPCParameter/release/nmake + } + + specific (vc8) { + libpaths += $(FAPIA_ROOT)/FAPIAIPCParameter/release/vc8 + } + + specific (make) { + libpaths += $(FAPIA_ROOT)/FAPIAIPCParameter/release/os9 + } + + specific (automake) { + linkflags += -L$(FAPIA_ROOT)/FAPIAIPCParameter/release/i686_linux32 + } + +} Added: fapia-trunk/make/MPC/config/FAPIAIPCParameterlocalcomponents.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCParameterlocalcomponents.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAIPCParameterdependencies { +} \ No newline at end of file Added: fapia-trunk/make/MPC/config/FAPIAIPCParameterlocalcomponentsexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCParameterlocalcomponentsexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAIPCParameterlocalexe, FAPIAIPCParameterlocalcomponents { +} \ No newline at end of file Added: fapia-trunk/make/MPC/config/FAPIAIPCParameterlocalexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCParameterlocalexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,24 @@ + +project : FAPIAIPCParameterpureexe { + + specific (vc6) { + libpaths += $(FAPIA_ROOT)/FAPIAIPCParameter/make/vc6/run + } + + specific (nmake) { + libpaths += $(FAPIA_ROOT)/FAPIAIPCParameter/make/nmake/run + } + + specific (vc8) { + libpaths += $(FAPIA_ROOT)/FAPIAIPCParameter/make/vc8/run + } + + specific (make) { + libpaths += $(FAPIA_ROOT)/FAPIAIPCParameter/make/os9 + } + + specific (automake) { + libpaths += $(FAPIA_ROOT)/FAPIAIPCParameter/make/i686_linux32/run + } + +} Added: fapia-trunk/make/MPC/config/FAPIAIPCParameterpureexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCParameterpureexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,18 @@ + +project : FAPIAIPCParameterdefaults { + + after += FAPIAIPCParameter + + specific (vc6, nmake, vc8) { + libs += FAPIAIPCParameter + } + + specific (automake) { + lit_libs += FAPIAIPCParameter + } + + specific (make) { + libs += FAPIAIPCParameter + } + +} Added: fapia-trunk/make/MPC/config/FAPIAIPCParameterpuresource.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCParameterpuresource.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,27 @@ + +project : FAPIAIPCParameterdefaults { + + source_files { + FAPIAIPCParameter { + $(FAPIA_ROOT)/FAPIAIPCParameter/source/*.cpp + } + } + + header_files { + FAPIAIPCParameter_interface { + $(FAPIA_ROOT)/FAPIAIPCParameter/interface/*.h + } + } + + header_files { + FAPIAIPCParameter { + $(FAPIA_ROOT)/FAPIAIPCParameter/source/*.h + } + } + + inline_files { + FAPIAIPCParameter { + $(FAPIA_ROOT)/FAPIAIPCParameter/source/*.i + } + } +} Added: fapia-trunk/make/MPC/config/FAPIAIPCParametersource.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCParametersource.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAIPCParameterpuresource, FAPIAIPCParameterlocalcomponents { +} Added: fapia-trunk/make/MPC/config/FAPIAIPCSynchronizecomponentsexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCSynchronizecomponentsexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAIPCSynchronizedependencies, FAPIAIPCSynchronizeexe { +} Added: fapia-trunk/make/MPC/config/FAPIAIPCSynchronizedefaults.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCSynchronizedefaults.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAdefaults { +} Added: fapia-trunk/make/MPC/config/FAPIAIPCSynchronizedependencies.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCSynchronizedependencies.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAdependencies { +} \ No newline at end of file Added: fapia-trunk/make/MPC/config/FAPIAIPCSynchronizeexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCSynchronizeexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,24 @@ + +project : FAPIAIPCSynchronizepureexe { + + specific (nmake) { + libpaths += $(FAPIA_ROOT)/FAPIAIPCSynchronize/release/nmake + } + + specific (vc6) { + libpaths += $(FAPIA_ROOT)/FAPIAIPCSynchronize/release/nmake + } + + specific (vc8) { + libpaths += $(FAPIA_ROOT)/FAPIAIPCSynchronize/release/vc8 + } + + specific (make) { + libpaths += $(FAPIA_ROOT)/FAPIAIPCSynchronize/release/os9 + } + + specific (automake) { + linkflags += -L$(FAPIA_ROOT)/FAPIAIPCSynchronize/release/i686_linux32 + } + +} Added: fapia-trunk/make/MPC/config/FAPIAIPCSynchronizelocalcomponents.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCSynchronizelocalcomponents.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAIPCSynchronizedependencies { +} \ No newline at end of file Added: fapia-trunk/make/MPC/config/FAPIAIPCSynchronizelocalcomponentsexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCSynchronizelocalcomponentsexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAIPCSynchronizelocalexe, FAPIAIPCSynchronizelocalcomponents { +} \ No newline at end of file Added: fapia-trunk/make/MPC/config/FAPIAIPCSynchronizelocalexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCSynchronizelocalexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,24 @@ + +project : FAPIAIPCSynchronizepureexe { + + specific (vc6) { + libpaths += $(FAPIA_ROOT)/FAPIAIPCSynchronize/make/vc6/run + } + + specific (nmake) { + libpaths += $(FAPIA_ROOT)/FAPIAIPCSynchronize/make/nmake/run + } + + specific (vc8) { + libpaths += $(FAPIA_ROOT)/FAPIAIPCSynchronize/make/vc8/run + } + + specific (make) { + libpaths += $(FAPIA_ROOT)/FAPIAIPCSynchronize/make/os9 + } + + specific (automake) { + linkflags += -L$(FAPIA_ROOT)/FAPIAIPCSynchronize/make/i686_linux32/.libs + } + +} Added: fapia-trunk/make/MPC/config/FAPIAIPCSynchronizepureexe.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCSynchronizepureexe.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,18 @@ + +project : FAPIAIPCSynchronizedefaults { + + after += FAPIAIPCSynchronize + + specific (vc6, nmake, vc8) { + libs += FAPIAIPCSynchronize + } + + specific (automake) { + lit_libs += FAPIAIPCSynchronize + } + + specific (make) { + libs += FAPIAIPCSynchronize + } + +} Added: fapia-trunk/make/MPC/config/FAPIAIPCSynchronizepuresource.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCSynchronizepuresource.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,27 @@ + +project : FAPIAIPCSynchronizedefaults { + + source_files { + FAPIAIPCSynchronize { + $(FAPIA_ROOT)/FAPIAIPCSynchronize/source/*.cpp + } + } + + header_files { + FAPIAIPCSynchronize_interface { + $(FAPIA_ROOT)/FAPIAIPCSynchronize/interface/*.h + } + } + + header_files { + FAPIAIPCSynchronize { + $(FAPIA_ROOT)/FAPIAIPCSynchronize/source/*.h + } + } + + inline_files { + FAPIAIPCSynchronize { + $(FAPIA_ROOT)/FAPIAIPCSynchronize/interface/*.i + } + } +} Added: fapia-trunk/make/MPC/config/FAPIAIPCSynchronizesource.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAIPCSynchronizesource.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,3 @@ + +project : FAPIAIPCSynchronizepuresource, FAPIAIPCSynchronizelocalcomponents { +} Added: fapia-trunk/make/MPC/config/FAPIAdefaults.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAdefaults.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,23 @@ + +project : homagdefaults { + +// version = 0.1.21 + + expand (IOFRAMEWORK_ROOT) { + $IOFRAMEWORK_ROOT + $VIEW_ROOT/IOFramework_vob + ../../../.. + } + + expand (FAPIA_ROOT) { + $FAPIA_ROOT + $IOFRAMEWORK_ROOT/FAPIA + $VIEW_ROOT/IOFramework_vob/FAPIA + ../../../.. + } + + includes += $(IOFRAMEWORK_ROOT) + includes += $(FAPIA_ROOT) + includes += $(FAPIA_ROOT)/interface + +} Added: fapia-trunk/make/MPC/config/FAPIAdependencies.mpb ============================================================================== --- (empty file) +++ fapia-trunk/make/MPC/config/FAPIAdependencies.mpb Thu Jul 19 07:23:28 2007 @@ -0,0 +1,11 @@ + +project : acecomponentsexe, taocomponentsexe { + + specific (vc6, vc8, nmake) { + Static_Multi_Ansi_Debug_DllRTL::staticflags -= "ACE_AS_STATIC_LIBS" "TAO_AS_STATIC_LIBS" + Static_Multi_Ansi_Release_DllRTL::staticflags -= "ACE_AS_STATIC_LIBS" "TAO_AS_STATIC_LIBS" + Static_Multi_Unicode_Debug_DllRTL::staticflags -= "ACE_AS_STATIC_LIBS" "TAO_AS_STATIC_LIBS" + Static_Multi_Unicode_Release_DllRTL::staticflags -= "ACE_AS_STATIC_LIBS" "TAO_AS_STATIC_LIBS" + } + +} \ No newline at end of file From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:47:04 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:47:04 +0200 Subject: [OSADL-svn-commits] r90 - fddi-20070618-1-trunk/busconfig/Pengutronix Message-ID: <200710020947.l929l4op021435@www.osadl.org> Author: robert Date: Thu Aug 9 12:31:45 2007 New Revision: 90 Log: new xml format Modified: fddi-20070618-1-trunk/busconfig/Pengutronix/modbus-example.xml Modified: fddi-20070618-1-trunk/busconfig/Pengutronix/modbus-example.xml ============================================================================== --- fddi-20070618-1-trunk/busconfig/Pengutronix/modbus-example.xml (original) +++ fddi-20070618-1-trunk/busconfig/Pengutronix/modbus-example.xml Thu Aug 9 12:31:45 2007 @@ -10,23 +10,20 @@ Controller PC - + + Ethernet - - - - - - - + + + + - + + - - master - - + master + @@ -34,22 +31,19 @@ Wago IO Box - + + Ethernet - - - - - - - + + + + - + + - - slave - + slave 1 @@ -76,7 +70,7 @@ - + From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:47:07 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:47:07 +0200 Subject: [OSADL-svn-commits] r91 - fddi-20070618-1-trunk/src Message-ID: <200710020947.l929l78i021448@www.osadl.org> Author: robert Date: Thu Aug 9 12:32:30 2007 New Revision: 91 Log: update Modified: fddi-20070618-1-trunk/src/libfddi_libmodbus.c Modified: fddi-20070618-1-trunk/src/libfddi_libmodbus.c ============================================================================== --- fddi-20070618-1-trunk/src/libfddi_libmodbus.c (original) +++ fddi-20070618-1-trunk/src/libfddi_libmodbus.c Thu Aug 9 12:32:30 2007 @@ -59,7 +59,7 @@ .name = NULL, .type = BOOL, .offset = 0, - .bit = 1, + .bit = 2, }; struct modbus_tpu { @@ -79,7 +79,7 @@ void _modbus_tpu_out(fddi_tpu_t *tpu) { - struct modbus_tpu *modbus_tpu = (struct modbus_tpu*)(tpu->priv); + struct modbus_tpu *modbus_tpu = (struct modbus_tpu*)(tpu->priv); /* application callback */ if (tpu->callback) @@ -113,7 +113,7 @@ return; } -/* +/* * fddi backend functions */ @@ -176,7 +176,7 @@ fprintf(stderr, "modbus_bind() failed\n"); return -1; } - + /* FIXME: modbus_dev must be put into the device, not iface! */ modbus_tpu1.modbus_dev = modbus_dev; From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:47:10 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:47:10 +0200 Subject: [OSADL-svn-commits] r92 - attic attic/fddi-20070502-1 attic/fddi-20070529-1 attic/fddi-20070618-1 attic/fddi-20070618-1-ptx1 attic/fddi-20070618-1-ptx2 attic/fddi-20070618-1-ptx3 fddi-20070502-1 fddi-20070529-1 fddi-20070618-1 fddi-20070618-1-ptx1 fddi-20070618-1-ptx2 fddi-20070618-1-ptx3 releases trunks Message-ID: <200710020947.l929lA1O021480@www.osadl.org> Author: robert Date: Thu Aug 9 12:36:37 2007 New Revision: 92 Log: tree restructuring Added: attic/ attic/fddi-20070502-1/ - copied from r41, /fddi-20070502-1/ attic/fddi-20070529-1/ - copied from r41, /fddi-20070529-1/ attic/fddi-20070618-1/ - copied from r41, /fddi-20070618-1/ attic/fddi-20070618-1-ptx1/ - copied from r41, /fddi-20070618-1-ptx1/ attic/fddi-20070618-1-ptx2/ - copied from r41, /fddi-20070618-1-ptx2/ attic/fddi-20070618-1-ptx3/ - copied from r41, /fddi-20070618-1-ptx3/ releases/ trunks/ Removed: fddi-20070502-1/ fddi-20070529-1/ fddi-20070618-1/ fddi-20070618-1-ptx1/ fddi-20070618-1-ptx2/ fddi-20070618-1-ptx3/ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:47:17 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:47:17 +0200 Subject: [OSADL-svn-commits] r93 - attic/fddi-20070618-1-trunk attic/fddi-20070618-1-trunk/busconfig attic/fddi-20070618-1-trunk/config attic/fddi-20070618-1-trunk/doc attic/fddi-20070618-1-trunk/include attic/fddi-20070618-1-trunk/src attic/fddi-20070618-1-trunk/tests attic/fddi-trunk attic/fddi-trunk/doc attic/fddi-trunk/src fddi-20070618-1-trunk fddi-trunk Message-ID: <200710020947.l929lHvM021509@www.osadl.org> Author: robert Date: Thu Aug 9 12:37:37 2007 New Revision: 93 Log: tree restructuring Added: attic/fddi-20070618-1-trunk/ - copied from r89, /fddi-20070618-1-trunk/ attic/fddi-20070618-1-trunk/AUTHORS - copied unchanged from r92, /fddi-20070618-1-trunk/AUTHORS attic/fddi-20070618-1-trunk/COPYING - copied unchanged from r92, /fddi-20070618-1-trunk/COPYING attic/fddi-20070618-1-trunk/ChangeLog - copied unchanged from r92, /fddi-20070618-1-trunk/ChangeLog attic/fddi-20070618-1-trunk/GNUmakefile.am - copied unchanged from r92, /fddi-20070618-1-trunk/GNUmakefile.am attic/fddi-20070618-1-trunk/README - copied unchanged from r92, /fddi-20070618-1-trunk/README attic/fddi-20070618-1-trunk/TODO - copied unchanged from r92, /fddi-20070618-1-trunk/TODO attic/fddi-20070618-1-trunk/autogen.sh - copied unchanged from r92, /fddi-20070618-1-trunk/autogen.sh attic/fddi-20070618-1-trunk/busconfig/ - copied from r92, /fddi-20070618-1-trunk/busconfig/ attic/fddi-20070618-1-trunk/config/ - copied from r92, /fddi-20070618-1-trunk/config/ attic/fddi-20070618-1-trunk/configure.ac - copied unchanged from r92, /fddi-20070618-1-trunk/configure.ac attic/fddi-20070618-1-trunk/doc/ - copied from r92, /fddi-20070618-1-trunk/doc/ attic/fddi-20070618-1-trunk/include/ - copied from r92, /fddi-20070618-1-trunk/include/ attic/fddi-20070618-1-trunk/src/ - copied from r92, /fddi-20070618-1-trunk/src/ attic/fddi-20070618-1-trunk/tests/ - copied from r92, /fddi-20070618-1-trunk/tests/ attic/fddi-trunk/ - copied from r41, /fddi-trunk/ attic/fddi-trunk/doc/ - copied from r92, /fddi-trunk/doc/ attic/fddi-trunk/src/ - copied from r92, /fddi-trunk/src/ Removed: fddi-20070618-1-trunk/ fddi-trunk/ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:47:22 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:47:22 +0200 Subject: [OSADL-svn-commits] r94 - trunks/fddi-trunk Message-ID: <200710020947.l929lMWO021532@www.osadl.org> Author: robert Date: Thu Aug 9 12:38:35 2007 New Revision: 94 Log: open trunk Added: trunks/fddi-trunk/ - copied from r93, /attic/fddi-20070618-1-trunk/ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:47:25 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:47:25 +0200 Subject: [OSADL-svn-commits] r95 - fapia-trunk trunks/fapia-trunk Message-ID: <200710020947.l929lPt8021559@www.osadl.org> Author: robert Date: Thu Aug 9 12:39:06 2007 New Revision: 95 Log: tree restructuring Added: trunks/fapia-trunk/ - copied from r94, /fapia-trunk/ Removed: fapia-trunk/ From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:47:27 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:47:27 +0200 Subject: [OSADL-svn-commits] r96 - in trunks/fddi-trunk: . config Message-ID: <200710020947.l929lRtc021584@www.osadl.org> Author: robert Date: Thu Aug 9 17:22:24 2007 New Revision: 96 Log: moved fddi.pc.in -> libfddi.pc.in Added: trunks/fddi-trunk/config/libfddi.pc.in - copied unchanged from r95, /trunks/fddi-trunk/config/fddi.pc.in Removed: trunks/fddi-trunk/config/fddi.pc.in Modified: trunks/fddi-trunk/config/GNUmakefile.am trunks/fddi-trunk/configure.ac Modified: trunks/fddi-trunk/config/GNUmakefile.am ============================================================================== --- trunks/fddi-trunk/config/GNUmakefile.am (original) +++ trunks/fddi-trunk/config/GNUmakefile.am Thu Aug 9 17:22:24 2007 @@ -1,7 +1,7 @@ -EXTRA_DIST = fddi.pc.in +EXTRA_DIST = libfddi.pc.in pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = fddi.pc +pkgconfig_DATA = libfddi.pc MAINTAINERCLEANFILES = \ GNUmakefile.in Modified: trunks/fddi-trunk/configure.ac ============================================================================== --- trunks/fddi-trunk/configure.ac (original) +++ trunks/fddi-trunk/configure.ac Thu Aug 9 17:22:24 2007 @@ -194,7 +194,7 @@ AC_CONFIG_FILES([ GNUmakefile - config/fddi.pc + config/libfddi.pc config/GNUmakefile include/GNUmakefile src/GNUmakefile From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:47:32 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:47:32 +0200 Subject: [OSADL-svn-commits] r97 - trunks/fddi-trunk/config Message-ID: <200710020947.l929lW1O021606@www.osadl.org> Author: robert Date: Thu Aug 9 17:23:38 2007 New Revision: 97 Log: add some description to pc file Modified: trunks/fddi-trunk/config/libfddi.pc.in Modified: trunks/fddi-trunk/config/libfddi.pc.in ============================================================================== --- trunks/fddi-trunk/config/libfddi.pc.in (original) +++ trunks/fddi-trunk/config/libfddi.pc.in Thu Aug 9 17:23:38 2007 @@ -3,8 +3,8 @@ libdir=@libdir@ includedir=@includedir@ -Name: -Description: +Name: libfddi +Description: FDDI is the OSADL Fieldbus Device Driver Interface Requires: @REQUIRES_LIBRN@ Version: @VERSION@ Libs: -L${libdir} -lfddi From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:47:35 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:47:35 +0200 Subject: [OSADL-svn-commits] r98 - trunks/fddi-trunk/config Message-ID: <200710020947.l929lZw2021629@www.osadl.org> Author: robert Date: Thu Aug 9 17:27:36 2007 New Revision: 98 Log: fix description and dependencies Modified: trunks/fddi-trunk/config/libfddi.pc.in Modified: trunks/fddi-trunk/config/libfddi.pc.in ============================================================================== --- trunks/fddi-trunk/config/libfddi.pc.in (original) +++ trunks/fddi-trunk/config/libfddi.pc.in Thu Aug 9 17:27:36 2007 @@ -4,8 +4,8 @@ includedir=@includedir@ Name: libfddi -Description: FDDI is the OSADL Fieldbus Device Driver Interface -Requires: @REQUIRES_LIBRN@ +Description: OSADL Fieldbus Device Driver Interface +Requires: Version: @VERSION@ Libs: -L${libdir} -lfddi #Libs.private: -lm -lpthread ...etc... From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:47:38 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:47:38 +0200 Subject: [OSADL-svn-commits] r99 - trunks/fddi-trunk/include/osadl Message-ID: <200710020947.l929lc7m021650@www.osadl.org> Author: robert Date: Thu Aug 9 18:02:21 2007 New Revision: 99 Log: added more types Modified: trunks/fddi-trunk/include/osadl/fddi_types.h Modified: trunks/fddi-trunk/include/osadl/fddi_types.h ============================================================================== --- trunks/fddi-trunk/include/osadl/fddi_types.h (original) +++ trunks/fddi-trunk/include/osadl/fddi_types.h Thu Aug 9 18:02:21 2007 @@ -48,6 +48,50 @@ typedef enum { + /* little endian */ + LE_UINT8, + LE_UINT16, + LE_UINT32, + LE_UINT64, + + LE_INT8, + LE_INT16, + LE_INT32, + LE_INT64, + + LE_FLOAT, + LE_DOUBLE, + + /* big endian */ + BE_UINT8, + BE_UINT16, + BE_UINT32, + BE_UINT64, + + BE_INT8, + BE_INT16, + BE_INT32, + BE_INT64, + + BE_FLOAT, + BE_DOUBLE, + + /* native endianess */ + UINT8, + UINT16, + UINT32, + UINT64, + + INT8, + INT16, + INT32, + INT64, + + FLOAT, + DOUBLE, + + /* FIXME does endianess matter for bool? */ + BOOL, } fddi_pv_type_enum_t; From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:47:41 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:47:41 +0200 Subject: [OSADL-svn-commits] r100 - in trunks/fddi-trunk: include/osadl src Message-ID: <200710020947.l929lfXv021681@www.osadl.org> Author: robert Date: Thu Aug 9 18:02:49 2007 New Revision: 100 Log: renamed postfix to suffix Modified: trunks/fddi-trunk/include/osadl/fddi_id.h trunks/fddi-trunk/src/libfddi.c trunks/fddi-trunk/src/libfddi_libmodbus.c Modified: trunks/fddi-trunk/include/osadl/fddi_id.h ============================================================================== --- trunks/fddi-trunk/include/osadl/fddi_id.h (original) +++ trunks/fddi-trunk/include/osadl/fddi_id.h Thu Aug 9 18:02:49 2007 @@ -31,7 +31,7 @@ /* private */ char *prefix; int index; - char *postfix; + char *suffix; char *id_as_string; size_t id_as_str_len; @@ -39,7 +39,7 @@ void *priv; }; -extern int fddi_id_init(fddi_id_t *fddi_id, const char *prefix, int index, const char *postfix); +extern int fddi_id_init(fddi_id_t *fddi_id, const char *prefix, int index, const char *suffix); extern int fddi_id_getid(fddi_id_t *fddi_id, char *id_string, size_t len); extern int fddi_id_destroy(fddi_id_t *fddi_id); Modified: trunks/fddi-trunk/src/libfddi.c ============================================================================== --- trunks/fddi-trunk/src/libfddi.c (original) +++ trunks/fddi-trunk/src/libfddi.c Thu Aug 9 18:02:49 2007 @@ -509,11 +509,11 @@ /* fddi_id_t */ -int fddi_id_init(fddi_id_t *fddi_id, const char *prefix, int index, const char *postfix) +int fddi_id_init(fddi_id_t *fddi_id, const char *prefix, int index, const char *suffix) { int prefix_len; int index_len; - int postfix_len; + int suffix_len; char index_as_string[30]; /* FIXME: find out max strlen of printf(int) */ memset(fddi_id, 0, sizeof(fddi_id_t)); @@ -530,16 +530,16 @@ } else prefix_len = 0; - if (postfix) { - postfix_len = strlen(postfix); - fddi_id->postfix = strdup(postfix); - if (!fddi_id->postfix) - goto postfix_err; + if (suffix) { + suffix_len = strlen(suffix); + fddi_id->suffix = strdup(suffix); + if (!fddi_id->suffix) + goto suffix_err; } else - postfix_len = 0; + suffix_len = 0; - fddi_id->id_as_str_len = prefix_len + index_len + postfix_len; + fddi_id->id_as_str_len = prefix_len + index_len + suffix_len; fddi_id->id_as_string = malloc(fddi_id->id_as_str_len + 1); if (!fddi_id->id_as_string) @@ -548,15 +548,15 @@ sprintf(fddi_id->id_as_string, "%s%s%s", fddi_id->prefix ? fddi_id->prefix : "", index_as_string ? index_as_string : "", - fddi_id->postfix ? fddi_id->postfix: ""); + fddi_id->suffix ? fddi_id->suffix: ""); return 0; id_as_str_err: fddi_id->id_as_str_len = 0; - free(fddi_id->postfix); - fddi_id->postfix = NULL; -postfix_err: + free(fddi_id->suffix); + fddi_id->suffix = NULL; +suffix_err: free(fddi_id->prefix); fddi_id->prefix = NULL; prefix_err: @@ -576,7 +576,7 @@ int fddi_id_destroy(fddi_id_t *fddi_id) { free(fddi_id->prefix); - free(fddi_id->postfix); + free(fddi_id->suffix); free(fddi_id->id_as_string); return 0; Modified: trunks/fddi-trunk/src/libfddi_libmodbus.c ============================================================================== --- trunks/fddi-trunk/src/libfddi_libmodbus.c (original) +++ trunks/fddi-trunk/src/libfddi_libmodbus.c Thu Aug 9 18:02:49 2007 @@ -17,7 +17,7 @@ .id = { .prefix = "dout", .index = -1, - .postfix = "", + .suffix = "", }, .direction = OUT, .cycletime = (10*1000*1000), @@ -27,7 +27,7 @@ .id = { .prefix = "signal_red", .index = -1, - .postfix = "", + .suffix = "", }, .param_list_head = NULL, .name = NULL, @@ -40,7 +40,7 @@ .id = { .prefix = "signal_yellow", .index = -1, - .postfix = "", + .suffix = "", }, .param_list_head = NULL, .name = NULL, @@ -53,7 +53,7 @@ .id = { .prefix = "signal_green", .index = -1, - .postfix = "", + .suffix = "", }, .param_list_head = NULL, .name = NULL, From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:47:44 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:47:44 +0200 Subject: [OSADL-svn-commits] r101 - trunks/fddi-trunk/include/osadl Message-ID: <200710020947.l929li0r021706@www.osadl.org> Author: robert Date: Thu Aug 9 22:15:49 2007 New Revision: 101 Log: need stdlib.h for size_t Modified: trunks/fddi-trunk/include/osadl/fddi_id.h Modified: trunks/fddi-trunk/include/osadl/fddi_id.h ============================================================================== --- trunks/fddi-trunk/include/osadl/fddi_id.h (original) +++ trunks/fddi-trunk/include/osadl/fddi_id.h Thu Aug 9 22:15:49 2007 @@ -22,6 +22,8 @@ #ifndef OSADL_FDDI_ID_H #define OSADL_FDDI_ID_H +#include + #include struct fddi_id { From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:47:47 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:47:47 +0200 Subject: [OSADL-svn-commits] r102 - trunks/fddi-trunk/tests Message-ID: <200710020947.l929llEA021734@www.osadl.org> Author: robert Date: Thu Aug 9 22:58:38 2007 New Revision: 102 Log: disable remaining entries for disabled test, in order to shutdown warning Modified: trunks/fddi-trunk/tests/GNUmakefile.am Modified: trunks/fddi-trunk/tests/GNUmakefile.am ============================================================================== --- trunks/fddi-trunk/tests/GNUmakefile.am (original) +++ trunks/fddi-trunk/tests/GNUmakefile.am Thu Aug 9 22:58:38 2007 @@ -67,11 +67,11 @@ test_examplebus1_LDADD = \ libexamplebus.la -test_fddi_examplebus1_SOURCES = \ - test_fddi_examplebus1.c - -test_fddi_examplebus1_LDADD = \ - $(top_builddir)/src/libfddi.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 From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:47:51 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:47:51 +0200 Subject: [OSADL-svn-commits] r103 - in trunks/fddi-trunk: . src Message-ID: <200710020947.l929lpOL021766@www.osadl.org> Author: robert Date: Thu Aug 9 22:59:35 2007 New Revision: 103 Log: add initial stubs for generic can backend Added: trunks/fddi-trunk/src/libfddi_can.c Modified: trunks/fddi-trunk/configure.ac trunks/fddi-trunk/src/GNUmakefile.am Modified: trunks/fddi-trunk/configure.ac ============================================================================== --- trunks/fddi-trunk/configure.ac (original) +++ trunks/fddi-trunk/configure.ac Thu Aug 9 22:59:35 2007 @@ -125,10 +125,10 @@ ) AC_MSG_RESULT([${CONFIG_DEBUG}]) if test "${CONFIG_DEBUG}" = "yes"; then - CFLAGS="${CFLAGS} -Werror -Wsign-compare -Wfloat-equal -Wformat-security -g -O1" + CFLAGS="${CFLAGS} -Wsign-compare -Wfloat-equal -Wformat-security -g -O1" AC_DEFINE(DEBUG, 1, [debugging]) else - CFLAGS="${CFLAGS} -O2" + CFLAGS="${CFLAGS} -Werror -O2" fi # @@ -192,6 +192,30 @@ fi +AC_MSG_CHECKING([whether to enable can backend]) +AC_ARG_ENABLE(backend-can, + AS_HELP_STRING([--enable-backend-can], [enable can backend @<:@default=no@:>@]), + [case "$enableval" in + y | yes) CONFIG_BACKEND_CAN=yes ;; + *) CONFIG_BACKEND_CAN=no ;; + esac], + [CONFIG_BACKEND_CAN=no] +) +AM_CONDITIONAL(BACKEND_CAN, test "${CONFIG_BACKEND_CAN}" = "yes") +AC_MSG_RESULT([${CONFIG_BACKEND_CAN}]) + +if test "${CONFIG_BACKEND_CAN}" = "yes"; then + + AC_CHECK_HEADER([linux/can.h], have_can_h=yes,, [[ + #include + ]]) + if test "$have_can_h" != "yes"; then + AC_MSG_ERROR([linux/can.h must be available when building with --enable-backend-can]) + fi + +fi + + AC_CONFIG_FILES([ GNUmakefile config/libfddi.pc Modified: trunks/fddi-trunk/src/GNUmakefile.am ============================================================================== --- trunks/fddi-trunk/src/GNUmakefile.am (original) +++ trunks/fddi-trunk/src/GNUmakefile.am Thu Aug 9 22:59:35 2007 @@ -2,6 +2,9 @@ if BACKEND_LIBMODBUS BACKEND_LIBS += libfddi_libmodbus.la endif +if BACKEND_CAN +BACKEND_LIBS += libfddi_can.la +endif lib_LTLIBRARIES = \ libfddi.la \ @@ -41,9 +44,18 @@ $(top_builddir)/src/libfddi.la \ $(libmodbus_LIBS) -MAINTAINERCLEANFILES = \ - GNUmakefile.in +# +# libfddi_can +# + +libfddi_can_la_SOURCES = \ + libfddi_can.c +libfddi_can_la_CPPFLAGS = \ + -DPF_CAN=29 -DAF_CAN=PF_CAN +# libfddi_can_la_LIBADD = +MAINTAINERCLEANFILES = \ + GNUmakefile.in Added: trunks/fddi-trunk/src/libfddi_can.c ============================================================================== --- (empty file) +++ trunks/fddi-trunk/src/libfddi_can.c Thu Aug 9 22:59:35 2007 @@ -0,0 +1,363 @@ +/* + * fddi backend for arbitrary CAN messages + */ + +/* FIXME: this file is an uggly hack which hardcodes everything, as long + * as we have a proper xml parser + */ + +#if 0 +#include +#include +#include +#include +#endif + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +static fddi_tpu_t tpu1 = { + .id = { + .prefix = "cantpu", + .index = 0, + .suffix = "", + }, + .direction = IN, + .cycletime = 0, +}; + +static fddi_tpu_t tpu2 = { + .id = { + .prefix = "cantpu", + .index = 1, + .suffix = "", + }, + .direction = IN, + .cycletime = 0, +}; + +/* ----- */ + +static fddi_pv_t pv_v_can = { + .id = { + .prefix = "v_can", + .index = -1, + .suffix = "", + }, + .param_list_head = NULL, + .name = NULL, + .type = BE_UINT16, + .offset = 0, + .bit = 0, +}; + +static fddi_pv_t pv_n_can = { + .id = { + .prefix = "n_can", + .index = -1, + .suffix = "", + }, + .param_list_head = NULL, + .name = NULL, + .type = BE_UINT16, + .offset = 2, + .bit = 0, +}; + +static fddi_pv_t pv_u_dc_can = { + .id = { + .prefix = "u_can", + .index = -1, + .suffix = "", + }, + .param_list_head = NULL, + .name = NULL, + .type = BE_UINT16, + .offset = 4, + .bit = 0, +}; + +static fddi_pv_t pv_i_can = { + .id = { + .prefix = "i_can", + .index = -1, + .suffix = "", + }, + .param_list_head = NULL, + .name = NULL, + .type = BE_UINT16, + .offset = 6, + .bit = 0, +}; + +static fddi_pv_t pv_arate_can = { + .id = { + .prefix = "arate_can", + .index = -1, + .suffix = "", + }, + .param_list_head = NULL, + .name = NULL, + .type = BE_UINT16, + .offset = 0, + .bit = 0, +}; + +static fddi_pv_t pv_srate_can = { + .id = { + .prefix = "srate_can", + .index = -1, + .suffix = "", + }, + .param_list_head = NULL, + .name = NULL, + .type = BE_UINT16, + .offset = 2, + .bit = 0, +}; + +#if 0 +struct modbus_tpu { + timer_t timer; + struct sigevent event; + struct itimerspec timer_spec; + modbus_dev_t *modbus_dev; +}; +struct modbus_tpu modbus_tpu1; +#endif + +typedef struct can_iface { + struct sockaddr_can addr; + struct can_frame frame; + struct ifreq ifr; + int socket; +} can_iface_t; + +can_iface_t can_iface1; + + +#if 0 +void _modbus_tpu_out(fddi_tpu_t *tpu) +{ + struct modbus_tpu *modbus_tpu = (struct modbus_tpu*)(tpu->priv); + + /* application callback */ + if (tpu->callback) + tpu->callback(tpu, NULL); + + /* bus transfer */ + modbus_w_single_coil(modbus_tpu->modbus_dev, 1, coil); + coil = coil == 0 ? 1:0; +} + +void _modbus_tpu_in(fddi_tpu_t *tpu) +{ + /* bus transfer */ + + /* application callback */ + if (tpu->callback) + tpu->callback(tpu, NULL); +} + + +void modbus_timer_handler(sigval_t sigval) +{ + fddi_tpu_t *tpu = (fddi_tpu_t*)sigval.sival_ptr; + + if ((tpu->direction == OUT) || (tpu->direction == INOUT)) + _modbus_tpu_out(tpu); + + if ((tpu->direction == IN) || (tpu->direction == INOUT)) + _modbus_tpu_in(tpu); + + return; +} +#endif + +/* + * fddi backend functions + */ + +int fddi_backend_init(fddi_iface_t *iface); +int fddi_backend_destroy(fddi_iface_t *iface); +int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data); +int fddi_backend_setstate(fddi_iface_t *iface, fddi_state_enum_t state); +int fddi_backend_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd); + +int fddi_backend_init(fddi_iface_t *iface) +{ + if ((can_iface1.socket = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) { + perror("socket"); + return -ESOCKTNOSUPPORT; + } + + can_iface1.addr.can_family = AF_CAN; + + strcpy(can_iface1.ifr.ifr_name, "vcan0"); + if (ioctl(can_iface1.socket, SIOCGIFINDEX, &can_iface1.ifr) < 0) { + perror("SIOCGIFINDEX"); + return 1; + } + can_iface1.addr.can_ifindex = can_iface1.ifr.ifr_ifindex; + + if (bind(can_iface1.socket, (struct sockaddr *)&can_iface1.addr, sizeof(can_iface1.addr)) < 0) { + perror("bind"); + return 1; + } + + iface->priv = &can_iface1; + return 0; +} + +int fddi_backend_destroy(fddi_iface_t *iface) +{ + can_iface_t *can_iface = (can_iface_t*)(iface->priv); + + close(can_iface->socket); + + return 0; +} + +int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data) +{ +#if 0 + int ret; + modbus_dev_t *modbus_dev = (modbus_dev_t*)(iface->priv); + + printf("parsing configfile: %s\n", configfile); + printf("for interface: %s\n", iface->id.id_as_string); /* FIXME private */ + + /* FIXME: everything's hardcoded & static for now, we add an xml parser later */ + + iface->tpulist_head = &tpu1; + tpu1.pv_list_head = &pv1; + + pv1.next = &pv2; + pv2.previous = &pv1; + pv2.next = &pv3; + pv3.previous = &pv2; + + /* modbus has no hardware bus cycle, emulate one for each tpu */ + /* FIXME: loop */ + { + modbus_tpu1.event.sigev_notify = SIGEV_THREAD; + modbus_tpu1.event.sigev_notify_function = modbus_timer_handler; + modbus_tpu1.event.sigev_notify_attributes = NULL; + modbus_tpu1.event.sigev_value.sival_ptr = &tpu1; + tpu1.priv = &modbus_tpu1; + + if ((ret = timer_create(CLOCK_REALTIME, &modbus_tpu1.event, &modbus_tpu1.timer)) < 0 ) { + perror("timer create"); + return -1; + } + } + + if (modbus_bind(modbus_dev, "192.168.23.242", 502) == -1) { + fprintf(stderr, "modbus_bind() failed\n"); + return -1; + } + + /* FIXME: modbus_dev must be put into the device, not iface! */ + modbus_tpu1.modbus_dev = modbus_dev; + + /* we are ready now and go into preoperational state */ + + fddi_backend_setstate(iface, STATE_PREOPERATIONAL); +#endif + return 0; +} + +int fddi_backend_setstate(fddi_iface_t *iface, fddi_state_enum_t state) +{ + int retval = -1; + + switch(state) { + case STATE_UNCONFIGURED: + case STATE_MISSING: + case STATE_CONFIG_ERROR: + case STATE_PREOPERATIONAL: + case STATE_OPERATIONAL: + case STATE_OPERATION_ERROR: + iface->state = state; + retval = 0; + break; + default: + break; + } + + return retval; +} + +int fddi_backend_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd) +{ + int retval = -1; + + switch (cmd) { + + case CMD_START: +#if 0 + + printf("start\n"); + /* FIXME loop over all tpus here */ + { + struct modbus_tpu *mtpu = ((struct modbus_tpu*)(iface->tpulist_head->priv)); + + mtpu->timer_spec.it_value.tv_sec = 1; + mtpu->timer_spec.it_value.tv_nsec = 0; + mtpu->timer_spec.it_interval.tv_sec = 0; + mtpu->timer_spec.it_interval.tv_nsec = 500*1000*1000; + + if ((retval = timer_settime(mtpu->timer, 0, &mtpu->timer_spec, NULL)) < 0 ) { + perror("timer settime"); + /* FIXME: disarm timers here */ + return -1; + } + } +#endif + retval = 0; + break; + + case CMD_STOP: +#if 0 + /* FIXME: loop over all tpus here */ + { + struct modbus_tpu *mtpu = ((struct modbus_tpu*)(iface->tpulist_head->priv)); + + mtpu->timer_spec.it_value.tv_sec = 0; + mtpu->timer_spec.it_value.tv_nsec = 0; + mtpu->timer_spec.it_interval.tv_sec = 0; + mtpu->timer_spec.it_interval.tv_nsec = 0; + + if ((retval = timer_settime(mtpu->timer, 0, &mtpu->timer_spec, NULL)) < 0 ) { + perror("timer settime"); + return -1; + } + } +#endif + retval = 0; + break; + + case CMD_RESET: + case CMD_IDENTIFY: + case CMD_QUITERR: + retval = 0; + break; + default: + break; + + } + + return retval; +} + From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:47:55 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:47:55 +0200 Subject: [OSADL-svn-commits] r104 - trunks/fddi-trunk/include Message-ID: <200710020947.l929lt35021790@www.osadl.org> Author: robert Date: Thu Aug 9 22:59:56 2007 New Revision: 104 Log: add missing header files to distro Modified: trunks/fddi-trunk/include/GNUmakefile.am Modified: trunks/fddi-trunk/include/GNUmakefile.am ============================================================================== --- trunks/fddi-trunk/include/GNUmakefile.am (original) +++ trunks/fddi-trunk/include/GNUmakefile.am Thu Aug 9 22:59:56 2007 @@ -2,8 +2,16 @@ fddistuff.h nobase_include_HEADERS = \ - osadl/fddi.h + osadl/fddi.h \ + osadl/fddi_device.h \ + osadl/fddi_id.h \ + osadl/fddi_iface.h \ + osadl/fddi_param.h \ + osadl/fddi_pv.h \ + osadl/fddi_tpu.h \ + osadl/fddi_types.h MAINTAINERCLEANFILES = \ fddi_config.h.in \ GNUmakefile.in + From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:47:59 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:47:59 +0200 Subject: [OSADL-svn-commits] r105 - trunks/fddi-trunk/src Message-ID: <200710020947.l929lxpm021821@www.osadl.org> Author: robert Date: Fri Aug 10 00:28:31 2007 New Revision: 105 Log: more can updates Modified: trunks/fddi-trunk/src/libfddi_can.c Modified: trunks/fddi-trunk/src/libfddi_can.c ============================================================================== --- trunks/fddi-trunk/src/libfddi_can.c (original) +++ trunks/fddi-trunk/src/libfddi_can.c Fri Aug 10 00:28:31 2007 @@ -75,7 +75,7 @@ .bit = 0, }; -static fddi_pv_t pv_u_dc_can = { +static fddi_pv_t pv_u_can = { .id = { .prefix = "u_can", .index = -1, @@ -231,9 +231,8 @@ int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data) { -#if 0 int ret; - modbus_dev_t *modbus_dev = (modbus_dev_t*)(iface->priv); + can_iface_t *can_iface = (can_iface_t*)(iface->priv); printf("parsing configfile: %s\n", configfile); printf("for interface: %s\n", iface->id.id_as_string); /* FIXME private */ @@ -241,40 +240,25 @@ /* FIXME: everything's hardcoded & static for now, we add an xml parser later */ iface->tpulist_head = &tpu1; - tpu1.pv_list_head = &pv1; + tpu1.pv_list_head = &pv_v_can; + tpu1.next = &tpu2; - pv1.next = &pv2; - pv2.previous = &pv1; - pv2.next = &pv3; - pv3.previous = &pv2; - - /* modbus has no hardware bus cycle, emulate one for each tpu */ - /* FIXME: loop */ - { - modbus_tpu1.event.sigev_notify = SIGEV_THREAD; - modbus_tpu1.event.sigev_notify_function = modbus_timer_handler; - modbus_tpu1.event.sigev_notify_attributes = NULL; - modbus_tpu1.event.sigev_value.sival_ptr = &tpu1; - tpu1.priv = &modbus_tpu1; - - if ((ret = timer_create(CLOCK_REALTIME, &modbus_tpu1.event, &modbus_tpu1.timer)) < 0 ) { - perror("timer create"); - return -1; - } - } + pv_v_can.next = &pv_n_can; + pv_n_can.previous = &pv_v_can; + pv_n_can.next = &pv_u_can; + pv_u_can.previous = &pv_n_can; + pv_u_can.next = &pv_i_can; + pv_i_can.previous = &pv_u_can; - if (modbus_bind(modbus_dev, "192.168.23.242", 502) == -1) { - fprintf(stderr, "modbus_bind() failed\n"); - return -1; - } + tpu2.pv_list_head = &pv_arate_can; + tpu2.previous = &tpu1; - /* FIXME: modbus_dev must be put into the device, not iface! */ - modbus_tpu1.modbus_dev = modbus_dev; + pv_arate_can.next = &pv_srate_can; + pv_srate_can.previous = &pv_arate_can; /* we are ready now and go into preoperational state */ - fddi_backend_setstate(iface, STATE_PREOPERATIONAL); -#endif + return 0; } From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:48:02 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:48:02 +0200 Subject: [OSADL-svn-commits] r106 - trunks/fddi-trunk/src Message-ID: <200710020948.l929m2O2021842@www.osadl.org> Author: robert Date: Wed Aug 22 20:59:57 2007 New Revision: 106 Log: start of can stuff Modified: trunks/fddi-trunk/src/libfddi_can.c Modified: trunks/fddi-trunk/src/libfddi_can.c ============================================================================== --- trunks/fddi-trunk/src/libfddi_can.c (original) +++ trunks/fddi-trunk/src/libfddi_can.c Wed Aug 22 20:59:57 2007 @@ -14,6 +14,7 @@ #endif #include +#include #include #include #include @@ -137,6 +138,11 @@ struct modbus_tpu modbus_tpu1; #endif +struct can_tpu { + pthread_t can_thread_id; + int endme; +} can_tpu; + typedef struct can_iface { struct sockaddr_can addr; struct can_frame frame; @@ -146,6 +152,42 @@ can_iface_t can_iface1; +#define MAXDEV 6 + +void* _can_thread(void *arg) +{ + fd_set rdfs; + int fd; + int bytes; + int retval; + struct can_frame frame; + + FD_ZERO(&rdfs); + FD_SET(fd, &rdfs); + + while (!(can_tpu.endme)) { + + if ((retval = select(fd, &rdfs, NULL, NULL, NULL)) < 0) { + perror("select"); + can_tpu.endme = 1; + continue; + } + + bytes = recv(fd, &frame, sizeof(struct can_frame), 0); + if (bytes < sizeof(struct can_frame)) { + fprintf(stderr, "error: received short frame"); + exit(-1); + } + + + + + sleep(1); + } + + return NULL; +} + #if 0 void _modbus_tpu_out(fddi_tpu_t *tpu) @@ -197,26 +239,6 @@ int fddi_backend_init(fddi_iface_t *iface) { - if ((can_iface1.socket = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) { - perror("socket"); - return -ESOCKTNOSUPPORT; - } - - can_iface1.addr.can_family = AF_CAN; - - strcpy(can_iface1.ifr.ifr_name, "vcan0"); - if (ioctl(can_iface1.socket, SIOCGIFINDEX, &can_iface1.ifr) < 0) { - perror("SIOCGIFINDEX"); - return 1; - } - can_iface1.addr.can_ifindex = can_iface1.ifr.ifr_ifindex; - - if (bind(can_iface1.socket, (struct sockaddr *)&can_iface1.addr, sizeof(can_iface1.addr)) < 0) { - perror("bind"); - return 1; - } - - iface->priv = &can_iface1; return 0; } @@ -235,8 +257,31 @@ can_iface_t *can_iface = (can_iface_t*)(iface->priv); printf("parsing configfile: %s\n", configfile); - printf("for interface: %s\n", iface->id.id_as_string); /* FIXME private */ +// printf("for interface: %s\n", iface->id.id_as_string); /* FIXME private */ + + /* + * create socket for specified CAN interface + */ + if ((can_iface1.socket = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) { + perror("opening can socket"); + return -ESOCKTNOSUPPORT; + } + + can_iface1.addr.can_family = AF_CAN; + + strcpy(can_iface1.ifr.ifr_name, "vcan0"); + if (ioctl(can_iface1.socket, SIOCGIFINDEX, &can_iface1.ifr) < 0) { + perror("attaching to can interface"); + return 1; + } + can_iface1.addr.can_ifindex = can_iface1.ifr.ifr_ifindex; + + if (bind(can_iface1.socket, (struct sockaddr *)&can_iface1.addr, sizeof(can_iface1.addr)) < 0) { + perror("binding to can socket"); + return 1; + } + iface->priv = &can_iface1; /* FIXME: everything's hardcoded & static for now, we add an xml parser later */ iface->tpulist_head = &tpu1; @@ -290,45 +335,20 @@ switch (cmd) { case CMD_START: -#if 0 - printf("start\n"); - /* FIXME loop over all tpus here */ - { - struct modbus_tpu *mtpu = ((struct modbus_tpu*)(iface->tpulist_head->priv)); - - mtpu->timer_spec.it_value.tv_sec = 1; - mtpu->timer_spec.it_value.tv_nsec = 0; - mtpu->timer_spec.it_interval.tv_sec = 0; - mtpu->timer_spec.it_interval.tv_nsec = 500*1000*1000; - - if ((retval = timer_settime(mtpu->timer, 0, &mtpu->timer_spec, NULL)) < 0 ) { - perror("timer settime"); - /* FIXME: disarm timers here */ - return -1; - } - } -#endif - retval = 0; + /* FIXME: check if we have already a thread running */ + retval = pthread_create(&can_tpu.can_thread_id, NULL, _can_thread, NULL); + if (retval != 0) + perror("creating can_thread"); break; case CMD_STOP: -#if 0 - /* FIXME: loop over all tpus here */ - { - struct modbus_tpu *mtpu = ((struct modbus_tpu*)(iface->tpulist_head->priv)); - - mtpu->timer_spec.it_value.tv_sec = 0; - mtpu->timer_spec.it_value.tv_nsec = 0; - mtpu->timer_spec.it_interval.tv_sec = 0; - mtpu->timer_spec.it_interval.tv_nsec = 0; - - if ((retval = timer_settime(mtpu->timer, 0, &mtpu->timer_spec, NULL)) < 0 ) { - perror("timer settime"); - return -1; - } - } -#endif + + can_tpu.endme = 1; + printf("waiting for can_thread to finish..."); + pthread_join(can_tpu.can_thread_id, NULL); + printf("done\n"); + retval = 0; break; From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:48:06 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:48:06 +0200 Subject: [OSADL-svn-commits] r107 - trunks/fddi-trunk/doc Message-ID: <200710020948.l929m6gq021855@www.osadl.org> Author: robert Date: Wed Aug 22 21:00:41 2007 New Revision: 107 Log: start of documentation, wip Added: trunks/fddi-trunk/doc/GNUmakefile.am trunks/fddi-trunk/doc/OSADL-FieldbusFramework-20070809-1.docbook Added: trunks/fddi-trunk/doc/GNUmakefile.am ============================================================================== --- (empty file) +++ trunks/fddi-trunk/doc/GNUmakefile.am Wed Aug 22 21:00:41 2007 @@ -0,0 +1,29 @@ +DOCBOOKFILES = $(wildcard *.docbook) +HTMLFILES = $(patsubst %.docbook,%.html,$(DOCBOOKFILES)) +TXTFILES = $(patsubst %.docbook,%.txt,$(DOCBOOKFILES)) +HTMLXSL = /usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl +XMLTO = xmlto + +all: $(HTMLFILES) $(TXTFILES) + +%.html: %.docbook + # $(XMLTO) -x $(HTMLXSL) html $< + # mv $(subst .docbook,.proc,$<) $(subst .docbook,.html,$<) + xsltproc --output $(subst .docbook,.html,$<) --stringparam section.autolabel 1 $(HTMLXSL) $< + touch *.wml + +%.txt: %.html + lynx -dump $< > $@ + #recode utf8..latin1 $@ + +clean: + rm -f $(HTMLFILES) $(TXTFILES) osadl-*.html + +osadl-fieldbus-framework.html: OSADL-Fieldbus-Framework-20070809-1.html + +EXTRA_DIST = \ + OSADL-Fieldbus-Framework-20070809-1.docbook + +MAINTAINERCLEANFILES = \ + GNUmakefile.in + Added: trunks/fddi-trunk/doc/OSADL-FieldbusFramework-20070809-1.docbook ============================================================================== --- (empty file) +++ trunks/fddi-trunk/doc/OSADL-FieldbusFramework-20070809-1.docbook Wed Aug 22 21:00:41 2007 @@ -0,0 +1,376 @@ + + + + +
+ + + + + RobertSchwebel + + + + + OSADL Fieldbus Framework + + + + + 0.1 + 2007-08-09 + Draft + + + + + + + + +Rationale + + + Industrial I/O components are the central interface between today's + automation systems and our physical environment. As Linux is becoming + more and more the first-class choice for embedded controllers, measurement + devices, soft PLCs and other control equipment throughout the industry, + there is still no commonly accepted way to connect I/O devices to a POSIX + operating system. + + Although modern embedded controllers use more and more + decentralized infrastructure and although there is a huge variety of + fieldbus topologies available today, we are still far away from the + situation we have in the IT business: today's server infrastructure + is completely based on open standards. It simply does not matter if + you buy a network card from vendor A or vendor B: nobody would ever + try to start changing lowlevel hardware access code inside of the + apache web server just in case of a hardware change. But that's exactly + how industral I/O works today. There is no generally accepted interface + for accessing fieldbusses and local I/O on the market. + + OSADL, being an organization who's members are machine building + companies, software specialists and embedded Linux experts, has the + declared aim to join market forces in order to make such a unified + framework possible. This document outlines the ideas and concepts behind + the OSADL Fieldbus Framework. + + + + +BSP Definition + + + The Vanilla Kernel does not offer support for all kinds of + industrial mainboards or modules by default. There are different + hardware form factors available today, ranging from x86 mainboards, + following standard PC layouts, down to deeply embedded systems based + on non-x86 System-on-Chip CPUs. For non-standard platforms there is + usually the need to extend the Vanilla Linux Kernel to support the + specific vendor hardware, in order to enable the hardware to fulfill + the specific needs of an industrial project. + + These modifications are being done by BSP Providers. Necessary + modifications include + + + + Driver Development. Industrial projects usually + have several hardware components not supported by standard Linux + drivers, so these components have to be developed. Drivers consist + of the driver code itself and the integration of the device in the + Driver Model. + + Kernel Architecture Modifications, necessary to + enable features not present in the current in-kernel code for the + used architecture (x86, ARM, PowerPC, MIPS, ...). + + Kernel Infrastructure Modifications. In some rare + cases it is necessary to modify generic kernel code, for example if + an architecture has features not supported by standard abstractions + of the generic code. + + + + The BSP Provider hands over the BSP, consisting of a vanilla + kernel plus necessary modifications, to the End Customer. The standard + method to transfer modifications is a patch in the unified diff + format. + + This results in the following patch flow: + + + - kernel.org ---> BSP Provider ---> Board Vendor ---> End Customer + BSP BSP + + + OSADL explicitly encourages BSP providers and board vendors to + submit their patches upstream; note that the high quality of the Linux + kernel is mainly a result of the peer review mechanism which cannot + take place if the patches are not submitted upstream. + + Details instructions how to provide a patch for upstream can be + found in Documentation/SubmittingPatches in the Linux kernel. + + + + +Kernel Modifications Rules + + + Each BSP must consist of a patch or a patch series against a + vanilla kernel version. The version of the vanilla kernel the BSP is + based on has to be specified explicitly. + + It is up to the BSP provider to hand out standard patches or a + custom mechanism which wraps standard patches with additional + information. In any case it must be easily possible to extract a patch + in the "canonical patch format" as being defined by the kernel + documentation. If the BSP provicer does not offer his patches in the + canonical patch format by default, he has to provide a description + how to convert his patch format into canonical patches. + + Patches have to be separated "by topic". That means that one + patch has to address one issue at a time and must be documented in a + way that makes it clear what issue the patch is addressing. The + canonical patch format should be used to make it easier to merge + patches upstream. One-big-patch is not allowed to be the only form of + delivery of a kernel patch in a BSP. + + Patches are never allowed to delete parts of the tree, + especially not other architectures. Files already existing in the + vanilla kernel tree are not allowed to be replaced by a file with the + same name but other contention. + + If there is more than one patch it must be clearly defined in + which order the patches have to be applied. This may be done by + providing a quilt patch series, or any other adequate mechanism. + + + Patches must have a documented originator. In order to follow + the standard rule for merging patches upstream, all patches should + have a "Signed-Off-By:" line, following the canonical patch format. + + + If patches by third parties are being included by a BSP, the + originator has to be specified, usually by adding a Signed-Off-By line + and by adding a hint to the original source to the patch + documentation. + + Patches should not destroy other architectures or sub + archtectures. The Linux kernel offers a clear abstraction of generic + vs. platform vs. BSP code, which has to be used. + + In rare cases there may be a need to break other platform code + due to project reasons; patches which do so have to be explicitly + marked as "uggly hack". + + + + +Levels of Conformance + + + Patches do conform to one of the following OSADL Boardsupport + Conformance Specification Levels (OBSPS-Patch-Level). Usually not the + whole BSP will conform to the same level, so the OSADL Testlab + documents the conformance to the levels on a per-patch base. The BSP + provider has to specify for each patch the proposed OBSPS-Patch-Level. + + + The OSADL Testlab BSP Spec Certificate documents a statistics + of the patches of a BSP and their according OBCS level. + + OBSPS-Patch-Level-0 + + The BSP does boot on the target architecture but doesn't + follow any particular rule of this specification. The patches are + neither intended for upstream, nor do they follow the quality + standards of this specification. + + + + OBSPS-Patch-Level-1 + + The BSP only adds board specific code components and usually + does not touch generic files. The only case where generic files are + being touched is to provide generic patches for bugs or extensions. + + + + + OBSPS-Patch-Level-2 + + The patches follow the kernel patch rules and the coding + style. The BSP can be compiled with sparse check without warnings. + The patches may or may not be reviewed by upstream parties. + + + + OBSPS-Patch-Level-3 + + The patches are continuously integrated with the mainline + kernel (at least once per week). The continuous integration has to + be documented by automatic protocols which show that the patches do + apply to the upstream GIT trees; breakages have to be fixed as they + do appear. Patches are actively code reviewed by the Linux community + with regard to quality, realtime or security issues. + + + + + + +Toolchains + + + One important part of a BSP is the toolchain used to compile + the kernel, which usually is also provided by the BSP provider. + + + There are two levels of toolchain conformance, specified as + OBSPS-Toochain-Levels: + + It always has to be specified on which host platform the + toolchain is able to run. This information is also part of the + documentation of the OSADL certification process. + + Toolchains may run on other platforms than Linux; however, in + order to get the OSADL BSP Certificate there needs to be at least a + version of the toolchain which is able to run on standard x86 Linux. + + + OBSPS-Toolchain-Level 0 + + The BSP Provider offers a binary toolchain packet. + + + + OBSPS-Toolchain-Level 1 + + The BSP Provider offers a script to build the toolchain from + the original sources plus necessary patches; the script must enable + the end user to re-build the toolchain from the original sources. If + it is possible to build the BSP with a standard toolchain supplied + by one of the major distributions (SuSE, RedHat, Debian), this also + does conform to this level. + + + + + + +Off Tree Drivers + + + Drivers not intended for upstream may be written using the + kernel standard mechanism for off-tree drivers. + + Off-tree drivers need a mechanism to find out where the + according kernel sources can be found. + + They must include information about which kernel version the + driver was last tested against. + + The off-tree driver has to compile with -Wall without warnings. + + + + + +Glossary and Abbreviations + + + + + + Vanilla Kernel + + + The generally accepted main version of the Linux kernel is + being maintained by Linus Torvalds. It is the base for all + distributions, is the most whidespread version and the base for + all kernel development activities. The vanilla kernel can be + downloaded from http://www.kernel.org/. + + + + + + + Upstream + + + Open Source projects make it possible that everyone + modifies the code, but there usually is an official version of the + code, being released by the project maintainer. The maintainer is + responsible for the project and releases official versions. Often + it is an aim of local devleopment to push the modifications to the + "upstream" maintainer, to have them integrated in future versions + of the official code. + + + + + + Patch + + + + + + + + + Diff + + + + + + + + + BSP + + + + + + + + + BSP Provider + + + + + + + + + + + + + +Authors + + + +Robert Schwebel +Pengutronix +Hannoversche Stra?e 2 +31134 Hildesheim +Tel. +49-5121-206917-0 +Fax: +49-5121-206917-9 +e-Mail: r.schwebel at pengutronix.de +URI: http://www.pengutronix.de + + + + + +
From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:48:11 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:48:11 +0200 Subject: [OSADL-svn-commits] r108 - trunks/fddi-trunk Message-ID: <200710020948.l929mBKo021885@www.osadl.org> Author: robert Date: Fri Sep 7 18:56:39 2007 New Revision: 108 Log: Modified: trunks/fddi-trunk/TODO Modified: trunks/fddi-trunk/TODO ============================================================================== --- trunks/fddi-trunk/TODO (original) +++ trunks/fddi-trunk/TODO Fri Sep 7 18:56:39 2007 @@ -1,5 +1,25 @@ TODO ---- -[ ] invent performant data transport model with persistence +[ ] Usecases + + [ ] packet streaming with jvisu observation + [ ] PLC (SPS) + [ ] controller (e.g. PID) + +[ ] Questions: + + [ ] workflow / timing for use cases? + [ ] where does the data come from? + [ ] where does it go? + [ ] when is it being processed? + [ ] take input+output into account + [ ] what happens if two processes want to manipulate variables + in the same TPU? Example: error counters; jvisu. + [ ] Put permission model into mapping layer? This could also + handle safety issues (e.g. who is allowed to write? + [ ] command api (e.g. having a "pv->increment" command which is + distributed over the network) + +[ ] invent performant data transport model with persistence; rcu? From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:48:14 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:48:14 +0200 Subject: [OSADL-svn-commits] r109 - trunks/fddi-trunk Message-ID: <200710020948.l929mEk6021906@www.osadl.org> Author: robert Date: Fri Sep 7 19:15:54 2007 New Revision: 109 Log: Modified: trunks/fddi-trunk/TODO Modified: trunks/fddi-trunk/TODO ============================================================================== --- trunks/fddi-trunk/TODO (original) +++ trunks/fddi-trunk/TODO Fri Sep 7 19:15:54 2007 @@ -21,5 +21,9 @@ [ ] command api (e.g. having a "pv->increment" command which is distributed over the network) +[ ] Wakeup: D. Hess suggests that TPUs can have a sync flag, which means that + upper layers can subscribe to that flags and are being woken up when they come + in. + [ ] invent performant data transport model with persistence; rcu? From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:48:17 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:48:17 +0200 Subject: [OSADL-svn-commits] r110 - trunks/fddi-trunk/tests Message-ID: <200710020948.l929mHf5021933@www.osadl.org> Author: robert Date: Sat Sep 8 02:04:51 2007 New Revision: 110 Log: Added: trunks/fddi-trunk/tests/usecase_controller.c Added: trunks/fddi-trunk/tests/usecase_controller.c ============================================================================== --- (empty file) +++ trunks/fddi-trunk/tests/usecase_controller.c Sat Sep 8 02:04:51 2007 @@ -0,0 +1,144 @@ +#include +#include +#include +#include + +//#include + +#define PV_CREATE(var, type) \ + do { \ + ret = pv_##type##_create(&pv_##var, &ldi, #var); \ + if (ret) { \ + fprintf(stderr, "error: could not register process variable '"#var"'\n"); \ + goto out_pv_##var; \ + } \ + } while(0) + +#define PV_DESTROY(var, type) \ + pv_##type##_destroy(&pv_##var); \ + out_pv_##var: \ + do {} while(0) + +#define PV_TRIGGER_CREATE(var) \ + do { \ + ret = ldi_trigger_define(&ldi, &pv_##var); \ + if (ret) { \ + fprintf(stderr, "error: could not create trigger on process variable "#var"\n"); \ + goto out_trigger; \ + } \ + } while(0) + +#define PV_TRIGGER_DESTROY(var) \ + out_trigger: do {} while(0) + + +/* FIXME put into header file */ + + typedef struct ldi_attr { + } ldi_attr_t; + + typedef struct ldi { + } ldi_t; + typedef struct pv { + } pv_t; + + /* pv */ + int pv_uint32_create(pv_t *pv, ldi_t *ldi, const char *name); + int pv_uint32_destroy(pv_t *pv); + uint32_t pv_uint32_get(pv_t *pv); + void pv_uint32_set(pv_t *pv, uint32_t val); + + /* ldi_attr */ + int ldi_attr_init_from_cmdline(ldi_attr_t *attr, int argc, char *argv[]); + int ldi_attr_destroy(ldi_attr_t *attr); + + /* ldi */ + int ldi_create(ldi_t *ldi, ldi_attr_t *attr); + int ldi_destroy(ldi_t *ldi); + int ldi_trigger_define(ldi_t *ldi, pv_t *pv); + int ldi_trigger_wait(ldi_t *ldi, uint64_t timeout_ns); + + +static int shutdown = 0; +static int Ta = (10*1000*1000); /* 10 ms */ + +void +signalhandler(int sig) +{ + if ((sig == SIGPIPE) || (sig == SIGHUP)) + return; + if (sig == SIGTERM || sig == SIGINT) + shutdown = 1; +} + +int main(int argc, char *argv[]) +{ + struct sigaction action; + ldi_attr_t ldi_attr; + ldi_t ldi; + int ret; + + pv_t pv_input; + pv_t pv_output; + pv_t pv_Kp; + pv_t pv_Ki; + pv_t pv_Kd; + + /* setup signal handler */ + action.sa_handler = signalhandler; + sigemptyset (&action.sa_mask); + action.sa_flags = 0; + sigaction (SIGTERM, &action, 0); /* catches kill from the shell */ + sigaction (SIGINT, &action, 0); /* catches Ctrl-C from the shell */ + sigaction (SIGPIPE, &action, 0); /* catches Broken Pipe exception */ + sigaction (SIGHUP, &action, 0); /* catches HUP */ + + /* initialize ldi */ + ret = ldi_attr_init_from_cmdline(&ldi_attr, argc, argv); + if (ret) { + fprintf(stderr, "error: could not init ldi_attr\n"); + exit(EXIT_FAILURE); + } + + ret = ldi_create(&ldi, &ldi_attr); + if (ret) { + fprintf(stderr, "error: couldn't create ldi\n"); + exit(EXIT_FAILURE); + } + + PV_CREATE(input, uint32); + PV_CREATE(output, uint32); + PV_CREATE(Kp, uint32); + PV_CREATE(Ki, uint32); + PV_CREATE(Kd, uint32); + + PV_TRIGGER_CREATE(input); + + /* control loop */ + while (!shutdown) { + + uint32_t e, x, esum, ealt; + + ret = ldi_trigger_wait(&ldi, 100*1000*1000); /* wait until trigger fires, with timeout in ns */ + if (ret) + continue; + + e = pv_uint32_get(&pv_input) - x; /* comparism */ + esum = esum + e; /* I part */ + pv_uint32_set(&pv_output, pv_uint32_get(&pv_Kp)*e + pv_uint32_get(&pv_Ki)*Ta*esum + pv_uint32_get(&pv_Kd)/Ta * (e ? ealt : e)); + ealt = e; + + } + + PV_TRIGGER_DESTROY(input); + + PV_DESTROY(Kd, uint32); + PV_DESTROY(Ki, uint32); + PV_DESTROY(Kp, uint32); + PV_DESTROY(output, uint32); + PV_DESTROY(input, uint32); + + ldi_destroy(&ldi); + ldi_attr_destroy(&ldi_attr); + return ret; +} From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:48:20 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:48:20 +0200 Subject: [OSADL-svn-commits] r111 - trunks/fddi-trunk/tests Message-ID: <200710020948.l929mKMf021950@www.osadl.org> Author: robert Date: Sat Sep 8 21:52:08 2007 New Revision: 111 Log: Added: trunks/fddi-trunk/tests/usecase_streaming.c Modified: trunks/fddi-trunk/tests/usecase_controller.c Modified: trunks/fddi-trunk/tests/usecase_controller.c ============================================================================== --- trunks/fddi-trunk/tests/usecase_controller.c (original) +++ trunks/fddi-trunk/tests/usecase_controller.c Sat Sep 8 21:52:08 2007 @@ -112,6 +112,7 @@ PV_CREATE(Ki, uint32); PV_CREATE(Kd, uint32); + /* incoming tpu containing variable 'input' is a trigger */ PV_TRIGGER_CREATE(input); /* control loop */ Added: trunks/fddi-trunk/tests/usecase_streaming.c ============================================================================== --- (empty file) +++ trunks/fddi-trunk/tests/usecase_streaming.c Sat Sep 8 21:52:08 2007 @@ -0,0 +1,110 @@ +#include +#include +#include +#include + +//#include + +/* FIXME put into header file */ + + typedef struct ldi_attr { + } ldi_attr_t; + + typedef struct ldi { + } ldi_t; + typedef struct pv { + } pv_t; + typedef struct tpu { + } tpu_t; + + /* pv */ + int pv_uint32_create(pv_t *pv, ldi_t *ldi, const char *name); + int pv_uint32_destroy(pv_t *pv); + uint32_t pv_uint32_get(pv_t *pv); + void pv_uint32_set(pv_t *pv, uint32_t val); + + /* tpu */ + int tpu_create(tpu_t *tpu /*, FIXME */); + int tpu_destroy(tpu_t *tpu); + + /* ldi_attr */ + int ldi_attr_init_from_cmdline(ldi_attr_t *attr, int argc, char *argv[]); + int ldi_attr_destroy(ldi_attr_t *attr); + + /* ldi */ + int ldi_create(ldi_t *ldi, ldi_attr_t *attr); + int ldi_destroy(ldi_t *ldi); + int ldi_trigger_define(ldi_t *ldi, pv_t *pv); + int ldi_trigger_wait(ldi_t *ldi, uint64_t timeout_ns); + int ldi_tpu_trigger_define(ldi_t *ldi, tpu_t *tpu); + + +static int shutdown = 0; + +void +signalhandler(int sig) +{ + if ((sig == SIGPIPE) || (sig == SIGHUP)) + return; + if (sig == SIGTERM || sig == SIGINT) + shutdown = 1; +} + +int main(int argc, char *argv[]) +{ + struct sigaction action; + ldi_attr_t ldi_attr; + ldi_t ldi; + int ret; + + tpu_t tpu; + + /* setup signal handler */ + action.sa_handler = signalhandler; + sigemptyset (&action.sa_mask); + action.sa_flags = 0; + sigaction (SIGTERM, &action, 0); /* catches kill from the shell */ + sigaction (SIGINT, &action, 0); /* catches Ctrl-C from the shell */ + sigaction (SIGPIPE, &action, 0); /* catches Broken Pipe exception */ + sigaction (SIGHUP, &action, 0); /* catches HUP */ + + /* initialize ldi */ + ret = ldi_attr_init_from_cmdline(&ldi_attr, argc, argv); + if (ret) { + fprintf(stderr, "error: could not init ldi_attr\n"); + exit(EXIT_FAILURE); + } + + ret = ldi_create(&ldi, &ldi_attr); + if (ret) { + fprintf(stderr, "error: couldn't create ldi\n"); + exit(EXIT_FAILURE); + } + + ret = tpu_create(&tpu); /* FIXME: how to find out which one? */ + if (ret) { + fprintf(stderr, "error: could not register tpu\n"); + exit(EXIT_FAILURE); + } + + /* this TPU is our trigger */ + ret = ldi_tpu_trigger_define(&ldi, &tpu); + + /* control loop */ + while (!shutdown) { + + ret = ldi_trigger_wait(&ldi, 100*1000*1000); /* wait until trigger fires, with timeout in ns */ + if (ret) + continue; + + /* FIXME now what to do with the tpu payload? */ + /* FIXME how to decide when TPUs are pushed back to the pool? */ + + } + + tpu_destroy(&tpu); + + ldi_destroy(&ldi); + ldi_attr_destroy(&ldi_attr); + return ret; +} From osadl-svn-commits at lists.osadl.org Tue Oct 2 11:48:23 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 11:48:23 +0200 Subject: [OSADL-svn-commits] r112 - trunks/fddi-trunk/src Message-ID: <200710020948.l929mNtc021964@www.osadl.org> Author: robert Date: Thu Sep 13 22:19:18 2007 New Revision: 112 Log: Modified: trunks/fddi-trunk/src/libfddi_can.c Modified: trunks/fddi-trunk/src/libfddi_can.c ============================================================================== --- trunks/fddi-trunk/src/libfddi_can.c (original) +++ trunks/fddi-trunk/src/libfddi_can.c Thu Sep 13 22:19:18 2007 @@ -27,6 +27,7 @@ #include #include +#include static fddi_tpu_t tpu1 = { .id = { @@ -152,37 +153,102 @@ can_iface_t can_iface1; + +struct priv { + pv_engine_t pv_engine; + + float *pv_v_tractor; + float *pv_n_diesel; + float *pv_u_dc; + float *pv_i_dc; + float *pv_agitation_rate; + float *pv_spray_rate; +}; + +struct priv priv; + #define MAXDEV 6 void* _can_thread(void *arg) { fd_set rdfs; - int fd; - int bytes; + int fd = can_iface1.socket; + ssize_t bytes; int retval; struct can_frame frame; + struct timeval to; FD_ZERO(&rdfs); - FD_SET(fd, &rdfs); while (!(can_tpu.endme)) { + to.tv_sec = 1; + to.tv_usec = 0; + FD_SET(fd, &rdfs); + + retval = select(fd + 1, &rdfs, NULL, NULL, &to); + + /* timeout */ + if (retval == 0) + continue; + + if (retval == -1) { + retval = -errno; + if (retval == -EINTR) + continue; - if ((retval = select(fd, &rdfs, NULL, NULL, NULL)) < 0) { perror("select"); can_tpu.endme = 1; continue; } bytes = recv(fd, &frame, sizeof(struct can_frame), 0); - if (bytes < sizeof(struct can_frame)) { + if (bytes < (ssize_t)sizeof(struct can_frame)) { fprintf(stderr, "error: received short frame"); exit(-1); } + switch (frame.can_id) { + case (0x18E0F108 & CAN_EFF_MASK) | CAN_EFF_FLAG: { + int v_tractor_can = + frame.data[0] << 8 | + frame.data[1] << 0; + int n_diesel_can = + frame.data[2] << 8 | + frame.data[3] << 0; + int u_dc_can = + frame.data[4] << 8 | + frame.data[5] << 0; + int i_dc_can = + frame.data[6] << 8 | + frame.data[7] << 0; + + pv_lock(&priv.pv_engine); + *(priv.pv_v_tractor) = v_tractor_can; + *(priv.pv_n_diesel) = n_diesel_can; + *(priv.pv_u_dc) = u_dc_can; + *(priv.pv_i_dc) = i_dc_can; + pv_unlock(&priv.pv_engine); + break; + } + case (0x18E0F208 & CAN_EFF_MASK) | CAN_EFF_FLAG: { + int agitation_rate_can = + frame.data[0] << 8 | + frame.data[1] << 0; + int spray_rate_can = + frame.data[2] << 8 | + frame.data[3] << 0; + + pv_lock(&priv.pv_engine); + *(priv.pv_agitation_rate) = agitation_rate_can; + *(priv.pv_spray_rate) = spray_rate_can; + pv_unlock(&priv.pv_engine); + break; + } + default: + fprintf(stderr, "Unknown can_id 0x%08x\n", frame.can_id & CAN_EFF_MASK); + } - - - sleep(1); + } return NULL; @@ -246,6 +312,8 @@ { can_iface_t *can_iface = (can_iface_t*)(iface->priv); + pv_destroy(&priv.pv_engine); + close(can_iface->socket); return 0; @@ -253,9 +321,6 @@ int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data) { - int ret; - can_iface_t *can_iface = (can_iface_t*)(iface->priv); - printf("parsing configfile: %s\n", configfile); // printf("for interface: %s\n", iface->id.id_as_string); /* FIXME private */ @@ -269,7 +334,7 @@ can_iface1.addr.can_family = AF_CAN; - strcpy(can_iface1.ifr.ifr_name, "vcan0"); + strcpy(can_iface1.ifr.ifr_name, "can0"); if (ioctl(can_iface1.socket, SIOCGIFINDEX, &can_iface1.ifr) < 0) { perror("attaching to can interface"); return 1; @@ -301,6 +366,35 @@ pv_arate_can.next = &pv_srate_can; pv_srate_can.previous = &pv_arate_can; + { + pv_engine_attr_t attr; + int err; + + err = pv_engine_attr_init_from_env(&attr); + if (err) + return err; + + err = pv_init(&priv.pv_engine, &attr); + if (err) { + printf("couldn't init pv engine\n"); + return err; + } + priv.pv_v_tractor = pv_register_float(&priv.pv_engine, "v_tractor"); + priv.pv_n_diesel = pv_register_float(&priv.pv_engine, "n_diesel"); + priv.pv_u_dc = pv_register_float(&priv.pv_engine, "u_dc"); + priv.pv_i_dc = pv_register_float(&priv.pv_engine, "i_dc"); + priv.pv_agitation_rate = pv_register_float(&priv.pv_engine, "agitation_rate"); + priv.pv_spray_rate = pv_register_float(&priv.pv_engine, "spray_rate"); + + if ((priv.pv_v_tractor == NULL) || (priv.pv_n_diesel == NULL) || (priv.pv_u_dc == NULL) || + (priv.pv_i_dc == NULL) || (priv.pv_agitation_rate == NULL) || (priv.pv_spray_rate == NULL)) { + fprintf(stderr, "could not register variables\n"); + pv_destroy(&priv.pv_engine); + return -EINVAL; + } + } + + /* we are ready now and go into preoperational state */ fddi_backend_setstate(iface, STATE_PREOPERATIONAL); From osadl-svn-commits at lists.osadl.org Tue Oct 2 16:30:06 2007 From: osadl-svn-commits at lists.osadl.org (OSADL repository commits) Date: Tue, 2 Oct 2007 16:30:06 +0200 Subject: [OSADL-svn-commits] r113 - in branches: . fddi-mapping fddi-mapping/busconfig fddi-mapping/busconfig/3S fddi-mapping/busconfig/Pengutronix fddi-mapping/busconfig/misc fddi-mapping/config fddi-mapping/config/m4 fddi-mapping/doc fddi-mapping/include fddi-mapping/include/osadl fddi-mapping/include/osadl/attic fddi-mapping/src fddi-mapping/tests Message-ID: <200710021430.l92EU6Le025636@www.osadl.org> Author: robert Date: Tue Oct 2 16:30:06 2007 New Revision: 113 Log: * mapping branch: re-added Added: branches/ branches/fddi-mapping/ branches/fddi-mapping/AUTHORS branches/fddi-mapping/COPYING branches/fddi-mapping/ChangeLog branches/fddi-mapping/GNUmakefile.am branches/fddi-mapping/README branches/fddi-mapping/TODO branches/fddi-mapping/autogen.sh (contents, props changed) branches/fddi-mapping/busconfig/ branches/fddi-mapping/busconfig/3S/ branches/fddi-mapping/busconfig/3S/ModBusConfigExample.xml branches/fddi-mapping/busconfig/3S/fddiconfig.xsd branches/fddi-mapping/busconfig/Pengutronix/ branches/fddi-mapping/busconfig/Pengutronix/can-example.xml branches/fddi-mapping/busconfig/Pengutronix/modbus-example.xml branches/fddi-mapping/busconfig/misc/ branches/fddi-mapping/busconfig/misc/pretty.xsl branches/fddi-mapping/config/ branches/fddi-mapping/config/GNUmakefile.am branches/fddi-mapping/config/libfddi.pc.in branches/fddi-mapping/config/m4/ branches/fddi-mapping/config/m4/.secret-world-domination-project branches/fddi-mapping/config/m4/acx_pthread.m4 branches/fddi-mapping/configure.ac branches/fddi-mapping/doc/ branches/fddi-mapping/doc/GNUmakefile.am branches/fddi-mapping/doc/OSADL-FieldbusFramework-20070809-1.docbook branches/fddi-mapping/doc/fddi_modbus_config_3s-20070710-7.odt (contents, props changed) branches/fddi-mapping/doc/fddi_proposal_3s-20070618-1.odt (contents, props changed) branches/fddi-mapping/doc/header.txt branches/fddi-mapping/include/ branches/fddi-mapping/include/GNUmakefile.am branches/fddi-mapping/include/fddistuff.h branches/fddi-mapping/include/osadl/ branches/fddi-mapping/include/osadl/attic/ branches/fddi-mapping/include/osadl/attic/fddi_hess.h branches/fddi-mapping/include/osadl/fddi.h branches/fddi-mapping/include/osadl/fddi_device.h branches/fddi-mapping/include/osadl/fddi_id.h branches/fddi-mapping/include/osadl/fddi_iface.h branches/fddi-mapping/include/osadl/fddi_param.h branches/fddi-mapping/include/osadl/fddi_pv.h branches/fddi-mapping/include/osadl/fddi_pv_attr.h branches/fddi-mapping/include/osadl/fddi_pv_engine.h branches/fddi-mapping/include/osadl/fddi_pv_group.h branches/fddi-mapping/include/osadl/fddi_pv_group_attr.h branches/fddi-mapping/include/osadl/fddi_tpu.h branches/fddi-mapping/include/osadl/fddi_types.h branches/fddi-mapping/src/ branches/fddi-mapping/src/GNUmakefile.am branches/fddi-mapping/src/fddi_pv.c branches/fddi-mapping/src/fddi_pv_engine.c branches/fddi-mapping/src/fddi_pv_group.c branches/fddi-mapping/src/fddi_pv_group_attr.c branches/fddi-mapping/src/libfddi.c branches/fddi-mapping/src/libfddi_can.c branches/fddi-mapping/src/libfddi_hess.c branches/fddi-mapping/src/libfddi_libmodbus.c branches/fddi-mapping/tests/ branches/fddi-mapping/tests/GNUmakefile.am branches/fddi-mapping/tests/example.xml branches/fddi-mapping/tests/examplebus.h branches/fddi-mapping/tests/fddi_examplebus.h branches/fddi-mapping/tests/libexamplebus.c branches/fddi-mapping/tests/libfddi_examplebus.c branches/fddi-mapping/tests/test_examplebus1.c branches/fddi-mapping/tests/test_fddi_can1.c branches/fddi-mapping/tests/test_fddi_can1.xml branches/fddi-mapping/tests/test_fddi_examplebus1.c branches/fddi-mapping/tests/test_fddi_examplebus_attach_backend.c branches/fddi-mapping/tests/test_fddi_examplebus_cmd_identify.c branches/fddi-mapping/tests/test_fddi_examplebus_cmd_quiterr.c branches/fddi-mapping/tests/test_fddi_examplebus_cmd_reset.c branches/fddi-mapping/tests/test_fddi_examplebus_cmd_start.c branches/fddi-mapping/tests/test_fddi_examplebus_cmd_stop.c branches/fddi-mapping/tests/test_fddi_examplebus_configure.c branches/fddi-mapping/tests/test_fddi_examplebus_setstate_configerror.c branches/fddi-mapping/tests/test_fddi_examplebus_setstate_missing.c branches/fddi-mapping/tests/test_fddi_examplebus_setstate_operation_error.c branches/fddi-mapping/tests/test_fddi_examplebus_setstate_operational.c branches/fddi-mapping/tests/test_fddi_examplebus_setstate_preoperational.c branches/fddi-mapping/tests/test_fddi_examplebus_setstate_unconfigured.c branches/fddi-mapping/tests/test_fddi_examplebus_tpu_usecase.c branches/fddi-mapping/tests/test_fddi_libmodbus1.c branches/fddi-mapping/tests/test_fddi_versionstr.c branches/fddi-mapping/tests/usecase_controller.c branches/fddi-mapping/tests/usecase_streaming.c Added: branches/fddi-mapping/AUTHORS ============================================================================== --- (empty file) +++ branches/fddi-mapping/AUTHORS Tue Oct 2 16:30:06 2007 @@ -0,0 +1,18 @@ +N: Dieter Hess +E: d.hess AT 3s-software.com +W: http://www.3s-software.com +D: Maintainer +S: 3S-Smart Software Solutions GmbH +S: Memminger Str.151 +S: 87439 Kempten +S: Germany + +N: Robert Schwebel +E: r.schwebel AT pengutronix.de +W: http://www.pengutronix.de +D: Maintainer +S: Pengutronix e.K. +S: Hannoversche Strasse 2 +S: 31134 Hildesheim +S: Germany + Added: branches/fddi-mapping/COPYING ============================================================================== --- (empty file) +++ branches/fddi-mapping/COPYING Tue Oct 2 16:30:06 2007 @@ -0,0 +1,31 @@ +LICENCING INFORMATION +--------------------- + +libfddi is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License version 2 as published by +the Free Software Foundation + +libfddi is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License along +with libfddi; if not, write to the Free Software Foundation, Inc., 59 +Temple Place, Suite 330, Boston, MA 02111-1307 USA. + +LINK EXCEPTION +-------------- + +For all source files required to build the libfddi library, which are +referenced by the term 'these files' in the following section. As a +special exception, if other files instantiate templates or use macros or +inline functions from these files, or you compile these files and link +them with other works to produce a work based on these files, these +files do not by themselves cause the resulting work to be covered by the +GNU General Public License. However the source code for these files must +still be made available in accordance with section (3) of the GNU +General Public License. This exception DOES NOT invalidate any other +reasons why a work based on these files might be covered by the GNU +General Public License. + Added: branches/fddi-mapping/ChangeLog ============================================================================== --- (empty file) +++ branches/fddi-mapping/ChangeLog Tue Oct 2 16:30:06 2007 @@ -0,0 +1,27 @@ +2007-07-04 Robert Schwebel + + * libftdl: added + * makefiles: fixed distcheck (works now if all tests would work, + which is not the case because of unimplemented functionality) + * release: released 20070618-1-ptx3 (svn only) + +2007-06-30 Robert Schwebel + + * libfddi: return -1 for functions which are currently unimplemented + * tests: added test for fddi_getversionstr + * tests: added tests for setstate + * tests: added first bunch of unit tests + * libexamplebus: added example fieldbus library + * libfddi_examplebus: added fddi wrapper library + * libfddi: implement lt_dlopen loader for backends + * release: released 20070618-1-ptx2 (svn only) + +2007-06-18 Robert Schwebel + + * design: model fddi components as POSIX like objects + * release: released 20070618-1-ptx1 (svn only) + +2007-06-18 Dieter Hess + + * design: initial proposal for an API + Added: branches/fddi-mapping/GNUmakefile.am ============================================================================== --- (empty file) +++ branches/fddi-mapping/GNUmakefile.am Tue Oct 2 16:30:06 2007 @@ -0,0 +1,52 @@ + +DIST_SUBDIRS = include config src tests +SUBDIRS = $(LIBLTDL_DIR) $(DIST_SUBDIRS) + +EXTRA_DIST = \ + autogen.sh \ + busconfig \ + config/m4/.secret-world-domination-project \ + libltdl/COPYING.LIB \ + libltdl/Makefile.am \ + libltdl/Makefile.in \ + libltdl/README \ + libltdl/acinclude.m4 \ + libltdl/aclocal.m4 \ + libltdl/config-h.in \ + libltdl/config.guess \ + libltdl/config.sub \ + libltdl/configure \ + libltdl/configure.ac \ + libltdl/install-sh \ + libltdl/ltdl.c \ + libltdl/ltdl.h \ + libltdl/ltmain.sh \ + libltdl/missing + +MAINTAINERCLEANFILES = \ + configure \ + GNUmakefile.in \ + aclocal.m4 \ + config/autoconf/compile \ + config/autoconf/config.guess \ + config/autoconf/config.sub \ + config/autoconf/depcomp \ + config/autoconf/install-sh \ + config/autoconf/ltmain.sh \ + config/autoconf/mdate-sh \ + config/autoconf/missing \ + config/autoconf/texinfo.tex \ + config/m4/libtool.m4 \ + config/m4/ltoptions.m4 \ + config/m4/ltsugar.m4 \ + config/m4/ltversion.m4 + +maintainer-clean-local: + -rm -fr $(srcdir)/libltdl + +distclean-local: + -cd $(builddir)/libltdl && make distclean + +uninstall-local: + -rm -rf $(DESTDIR)$(pkgdatadir)/libltdl + Added: branches/fddi-mapping/README ============================================================================== Added: branches/fddi-mapping/TODO ============================================================================== --- (empty file) +++ branches/fddi-mapping/TODO Tue Oct 2 16:30:06 2007 @@ -0,0 +1,29 @@ +TODO +---- + +[ ] Usecases + + [ ] packet streaming with jvisu observation + [ ] PLC (SPS) + [ ] controller (e.g. PID) + +[ ] Questions: + + [ ] workflow / timing for use cases? + [ ] where does the data come from? + [ ] where does it go? + [ ] when is it being processed? + [ ] take input+output into account + [ ] what happens if two processes want to manipulate variables + in the same TPU? Example: error counters; jvisu. + [ ] Put permission model into mapping layer? This could also + handle safety issues (e.g. who is allowed to write? + [ ] command api (e.g. having a "pv->increment" command which is + distributed over the network) + +[ ] Wakeup: D. Hess suggests that TPUs can have a sync flag, which means that + upper layers can subscribe to that flags and are being woken up when they come + in. + +[ ] invent performant data transport model with persistence; rcu? + Added: branches/fddi-mapping/autogen.sh ============================================================================== --- (empty file) +++ branches/fddi-mapping/autogen.sh Tue Oct 2 16:30:06 2007 @@ -0,0 +1,48 @@ +#!/bin/bash + +# +# usage: +# +# banner +# +banner() { + echo + TG=`echo $1 | sed -e "s,/.*/,,g"` + LINE=`echo $TG |sed -e "s/./-/g"` + echo $LINE + echo $TG + echo $LINE + echo +} + + +ACLOCAL=${ACLOCAL:=aclocal} +AUTOHEADER=${AUTOHEADER:=autoheader} +AUTOMAKE=${AUTOMAKE:=automake} +AUTOCONF=${AUTOCONF:=autoconf} + +#$ACLOCAL --version | \ +# awk -vPROG="aclocal" -vVERS=1.7\ +# '{if ($1 == PROG) {gsub ("-.*","",$4); if ($4 < VERS) print PROG" < version "VERS"\nThis may result in errors\n"}}' + +#$AUTOMAKE --version | \ +# awk -vPROG="automake" -vVERS=1.7\ +# '{if ($1 == PROG) {gsub ("-.*","",$4); if ($4 < VERS) print PROG" < version "VERS"\nThis may result in errors\n"}}' + + +banner "running aclocal" +$ACLOCAL -I config/m4 || exit + +banner "running libtoolize" +libtoolize --force --ltdl --copy || exit + +banner "running autoheader" +$AUTOHEADER || exit + +banner "running automake" +$AUTOMAKE --gnu --add-missing -Wall || exit + +banner "running autoconf" +$AUTOCONF -Wall || exit + +banner "Finished" Added: branches/fddi-mapping/busconfig/3S/ModBusConfigExample.xml ============================================================================== --- (empty file) +++ branches/fddi-mapping/busconfig/3S/ModBusConfigExample.xml Tue Oct 2 16:30:06 2007 @@ -0,0 +1,44 @@ + + + + + + + 0 + ModbusMaster + + + 1 + ModbusSlave1 + 14 + 0 + 22 + 17 + 64 + 8 + 1 + 100 + false + 72 + 12 + 2 + 100 + true + + + + 2 + ModbusSlave2 + 4 + 11 + 20 + 4 + 1 + 50 + true + + + 1010 + + Added: branches/fddi-mapping/busconfig/3S/fddiconfig.xsd ============================================================================== --- (empty file) +++ branches/fddi-mapping/busconfig/3S/fddiconfig.xsd Tue Oct 2 16:30:06 2007 @@ -0,0 +1,27 @@ + + + + + + Root device of a fddi configuration + + + + + + + + + + + + + + + + + + + + + Added: branches/fddi-mapping/busconfig/Pengutronix/can-example.xml ============================================================================== --- (empty file) +++ branches/fddi-mapping/busconfig/Pengutronix/can-example.xml Tue Oct 2 16:30:06 2007 @@ -0,0 +1,121 @@ + + + + + + + + + OSADL CAN Demo System + + + + Board Computer + + + + + CAN + 500000 + + + + + + + + + + + + The Car + + + + + CAN + 500000 + + + + + + + + 8 + + + + + + Car Speed (from CAN) + uint16_t + 0 + + + + RPM (from CAN) + uint16_t + 2 + + + + Voltage (from CAN) + uint16_t + 4 + + + + Current (from CAN) + uint16_t + 6 + + + + + + 4 + + + + + + A Rate (from CAN) + uint16_t + 0 + + + + S Rate (from CAN) + uint16_t + 2 + + + + + + + + + + + + + + + + + + + + + + Added: branches/fddi-mapping/busconfig/Pengutronix/modbus-example.xml ============================================================================== --- (empty file) +++ branches/fddi-mapping/busconfig/Pengutronix/modbus-example.xml Tue Oct 2 16:30:06 2007 @@ -0,0 +1,97 @@ + + + + + + + + OSADL Modbus Demo System + + + + + Controller PC + + + + + Ethernet + + + + + + + + + master + + + + + + + + Wago IO Box + + + + + Ethernet + + + + + + + + + slave + + + 1 + + + Signal Noun Red Light + bool_t + 0 + 0 + + + + Signal Noun Yellow Light + bool_t + 0 + 1 + + + + Signal Noun Green Light + bool_t + 0 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + Added: branches/fddi-mapping/busconfig/misc/pretty.xsl ============================================================================== --- (empty file) +++ branches/fddi-mapping/busconfig/misc/pretty.xsl Tue Oct 2 16:30:06 2007 @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: branches/fddi-mapping/config/GNUmakefile.am ============================================================================== --- (empty file) +++ branches/fddi-mapping/config/GNUmakefile.am Tue Oct 2 16:30:06 2007 @@ -0,0 +1,7 @@ +EXTRA_DIST = libfddi.pc.in + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libfddi.pc + +MAINTAINERCLEANFILES = \ + GNUmakefile.in Added: branches/fddi-mapping/config/libfddi.pc.in ============================================================================== --- (empty file) +++ branches/fddi-mapping/config/libfddi.pc.in Tue Oct 2 16:30:06 2007 @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libfddi +Description: OSADL Fieldbus Device Driver Interface +Requires: +Version: @VERSION@ +Libs: -L${libdir} -lfddi +#Libs.private: -lm -lpthread ...etc... +Cflags: -I${includedir} Added: branches/fddi-mapping/config/m4/.secret-world-domination-project ============================================================================== Added: branches/fddi-mapping/config/m4/acx_pthread.m4 ============================================================================== --- (empty file) +++ branches/fddi-mapping/config/m4/acx_pthread.m4 Tue Oct 2 16:30:06 2007 @@ -0,0 +1,238 @@ +dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +dnl +dnl @summary figure out how to build C programs using POSIX threads +dnl +dnl This macro figures out how to build C programs using POSIX threads. +dnl It sets the PTHREAD_LIBS output variable to the threads library and +dnl linker flags, and the PTHREAD_CFLAGS output variable to any special +dnl C compiler flags that are needed. (The user can also force certain +dnl compiler flags/libs to be tested by setting these environment +dnl variables.) +dnl +dnl Also sets PTHREAD_CC to any special C compiler that is needed for +dnl multi-threaded programs (defaults to the value of CC otherwise). +dnl (This is necessary on AIX to use the special cc_r compiler alias.) +dnl +dnl NOTE: You are assumed to not only compile your program with these +dnl flags, but also link it with them as well. e.g. you should link +dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS +dnl $LIBS +dnl +dnl If you are only building threads programs, you may wish to use +dnl these variables in your default LIBS, CFLAGS, and CC: +dnl +dnl LIBS="$PTHREAD_LIBS $LIBS" +dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +dnl CC="$PTHREAD_CC" +dnl +dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute +dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to +dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). +dnl +dnl ACTION-IF-FOUND is a list of shell commands to run if a threads +dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to +dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the +dnl default action will define HAVE_PTHREAD. +dnl +dnl Please let the authors know if this macro fails on any platform, or +dnl if you have any other suggestions or comments. This macro was based +dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with +dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros +dnl posted by Alejandro Forero Cuervo to the autoconf macro repository. +dnl We are also grateful for the helpful feedback of numerous users. +dnl +dnl @category InstalledPackages +dnl @author Steven G. Johnson +dnl @version 2005-06-15 +dnl @license GPLWithACException + +AC_DEFUN([ACX_PTHREAD], [ +AC_REQUIRE([AC_CANONICAL_HOST]) +AC_LANG_SAVE +AC_LANG_C +acx_pthread_ok=no + +# We used to check for pthread.h first, but this fails if pthread.h +# requires special compiler flags (e.g. on True64 or Sequent). +# It gets checked for in the link test anyway. + +# First of all, check if the user has set any of the PTHREAD_LIBS, +# etcetera environment variables, and if threads linking works using +# them: +if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) + AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) + AC_MSG_RESULT($acx_pthread_ok) + if test x"$acx_pthread_ok" = xno; then + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" + fi + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" +fi + +# We must check for the threads library under a number of different +# names; the ordering is very important because some systems +# (e.g. DEC) have both -lpthread and -lpthreads, where one of the +# libraries is broken (non-POSIX). + +# Create a list of thread flags to try. Items starting with a "-" are +# C compiler flags, and other items are library names, except for "none" +# which indicates that we try without any flags at all, and "pthread-config" +# which is a program returning the flags for the Pth emulation library. + +acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" + +# The ordering *is* (sometimes) important. Some notes on the +# individual items follow: + +# pthreads: AIX (must check this before -lpthread) +# none: in case threads are in libc; should be tried before -Kthread and +# other compiler flags to prevent continual compiler warnings +# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) +# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) +# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) +# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) +# -pthreads: Solaris/gcc +# -mthreads: Mingw32/gcc, Lynx/gcc +# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it +# doesn't hurt to check since this sometimes defines pthreads too; +# also defines -D_REENTRANT) +# ... -mt is also the pthreads flag for HP/aCC +# pthread: Linux, etcetera +# --thread-safe: KAI C++ +# pthread-config: use pthread-config program (for GNU Pth library) + +case "${host_cpu}-${host_os}" in + *solaris*) + + # On Solaris (at least, for some versions), libc contains stubbed + # (non-functional) versions of the pthreads routines, so link-based + # tests will erroneously succeed. (We need to link with -pthreads/-mt/ + # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather + # a function called by this macro, so we could check for that, but + # who knows whether they'll stub that too in a future libc.) So, + # we'll just look for -pthreads and -lpthread first: + + acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags" + ;; +esac + +if test x"$acx_pthread_ok" = xno; then +for flag in $acx_pthread_flags; do + + case $flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + + -*) + AC_MSG_CHECKING([whether pthreads work with $flag]) + PTHREAD_CFLAGS="$flag" + ;; + + pthread-config) + AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no) + if test x"$acx_pthread_config" = xno; then continue; fi + PTHREAD_CFLAGS="`pthread-config --cflags`" + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" + ;; + + *) + AC_MSG_CHECKING([for the pthreads library -l$flag]) + PTHREAD_LIBS="-l$flag" + ;; + esac + + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we + # need a special flag -Kthread to make this header compile.) + # We check for pthread_join because it is in -lpthread on IRIX + # while pthread_create is in libc. We check for pthread_attr_init + # due to DEC craziness with -lpthreads. We check for + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. + AC_TRY_LINK([#include ], + [pthread_t th; pthread_join(th, 0); + pthread_attr_init(0); pthread_cleanup_push(0, 0); + pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], + [acx_pthread_ok=yes]) + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + AC_MSG_RESULT($acx_pthread_ok) + if test "x$acx_pthread_ok" = xyes; then + break; + fi + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi + +# Various other checks: +if test "x$acx_pthread_ok" = xyes; then + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. + AC_MSG_CHECKING([for joinable pthread attribute]) + attr_name=unknown + for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do + AC_TRY_LINK([#include ], [int attr=$attr; return attr;], + [attr_name=$attr; break]) + done + AC_MSG_RESULT($attr_name) + if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then + AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, + [Define to necessary symbol if this constant + uses a non-standard name on your system.]) + fi + + AC_MSG_CHECKING([if more special flags are required for pthreads]) + flag=no + case "${host_cpu}-${host_os}" in + *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; + *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; + esac + AC_MSG_RESULT(${flag}) + if test "x$flag" != xno; then + PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" + fi + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + # More AIX lossage: must compile with cc_r + AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC}) +else + PTHREAD_CC="$CC" +fi + +AC_SUBST(PTHREAD_LIBS) +AC_SUBST(PTHREAD_CFLAGS) +AC_SUBST(PTHREAD_CC) + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test x"$acx_pthread_ok" = xyes; then + ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) + : +else + acx_pthread_ok=no + $2 +fi +AC_LANG_RESTORE +])dnl ACX_PTHREAD Added: branches/fddi-mapping/configure.ac ============================================================================== --- (empty file) +++ branches/fddi-mapping/configure.ac Tue Oct 2 16:30:06 2007 @@ -0,0 +1,280 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. +AC_PREREQ(2.59) + +AC_INIT([fddi], [0.0.1], [bugs at pengutronix.de]) +AC_CONFIG_HEADERS([include/fddi_config.h]) +AC_CONFIG_SRCDIR([src/libfddi.c]) +AC_CONFIG_MACRO_DIR([config/m4]) +AC_CONFIG_AUX_DIR([config/autoconf]) +AC_CANONICAL_BUILD +AC_CANONICAL_HOST + +AM_MAINTAINER_MODE + +CFLAGS="${CFLAGS} -Wall" + +# +# libtool library versioning stuff +# + +# Library code modified: REVISION++ +# Interfaces changed/added/removed: CURRENT++ REVISION=0 +# Interfaces added: AGE++ +# Interfaces removed: AGE=0 +LT_CURRENT=0 +LT_REVISION=0 +LT_AGE=0 +AC_SUBST(LT_CURRENT) +AC_SUBST(LT_REVISION) +AC_SUBST(LT_AGE) + +# +# libtool and lt_dl +# + +AC_LIBLTDL_INSTALLABLE +AC_LIBTOOL_DLOPEN +AC_LIBTOOL_WIN32_DLL +AC_PROG_LIBTOOL +AC_CONFIG_SUBDIRS(libltdl) +AC_SUBST(INCLTDL) +AC_SUBST(LIBLTDL) +if test "${enable_ltdl_install}" = "yes"; then + LIBLTDL_DIR=libltdl +else + LIBLTDL_DIR="" +fi +AC_SUBST(LIBLTDL_DIR) + +# +# Checks for programs. +# + +AC_PROG_CC + +AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2]) + + +# +# Checks for libraries +# + +## +# librn +## +# REQUIRES_LIBRN="librn >= 0.4.2" +# AC_SUBST(REQUIRES_LIBRN) +# PKG_CHECK_MODULES([librn], +# [${REQUIRES_LIBRN}], +# [], +# [AC_MSG_ERROR([*** ${REQUIRES_LIBRN} not found by pkg-config on your system])] +# ) +# AC_SUBST(librn_CFLAGS) +# AC_SUBST(librn_LIBS) + +# +# Checks for header files. +# + +AC_HEADER_DIRENT +AC_HEADER_STDC +AC_HEADER_SYS_WAIT +AC_CHECK_HEADERS([ \ + arpa/inet.h \ + limits.h \ + netdb.h \ + netinet/in.h \ + stddef.h \ + stdlib.h \ + string.h \ + sys/param.h \ + sys/socket.h \ + sys/time.h \ + sys/un.h \ + unistd.h \ + utime.h \ + ]) + + +# +# Checks for typedefs, structures, and compiler characteristics. +# + +AC_C_CONST +AC_C_INLINE +AC_TYPE_SIZE_T +AC_HEADER_TIME + + +# +# Checks for library functions. +# + +AC_FUNC_MEMCMP +AC_TYPE_SIGNAL +AC_FUNC_STAT +AC_FUNC_UTIME_NULL +AC_CHECK_FUNCS([gethostbyaddr gethostbyname gethostname gettimeofday memset mkdir socket utime]) + + +# +# Debugging +# + +AC_MSG_CHECKING([whether to enable debugging]) +AC_ARG_ENABLE(debug, + AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=yes@:>@]), + [case "$enableval" in + y | yes) CONFIG_DEBUG=yes ;; + *) CONFIG_DEBUG=no ;; + esac], + [CONFIG_DEBUG=yes] +) +AC_MSG_RESULT([${CONFIG_DEBUG}]) +if test "${CONFIG_DEBUG}" = "yes"; then + CFLAGS="${CFLAGS} -Wsign-compare -Wfloat-equal -Wformat-security -g -O1" + AC_DEFINE(DEBUG, 1, [debugging]) +else + CFLAGS="${CFLAGS} -Werror -O2" +fi + + +# +# XML parsers +# + +AC_MSG_CHECKING([for xml parser]) +AC_ARG_WITH(xmlparser, + AS_HELP_STRING([--with-xmlparser], [select used xml parser; you can chose from expat, + libxml2 or auto. @<:@default=libxml2@:>@]), + [case "$withval" in + expat) CONFIG_XMLPARSER=expat ;; + libxml2) CONFIG_XMLPARSER=libxml2 ;; + n | no) CONFIG_XMLPARSER=no ;; + auto | *) CONFIG_XMLPARSER=auto ;; + esac], + [CONFIG_XMLPARSER=auto] +) +if test "${CONFIG_XMLPARSER}" = "auto"; then + AC_MSG_WARN([echo "FIXME - auto test for xml parser not written yet"]) +fi +AM_CONDITIONAL(XMLPARSER_EXPAT, test "${CONFIG_XMLPARSER}" = "expat") +AM_CONDITIONAL(XMLPARSER_LIBXML2, test "${CONFIG_XMLPARSER}" = "libxml2") +AC_MSG_RESULT([${CONFIG_XMLPARSER}]) + + +# +# Backends +# + +AC_MSG_CHECKING([whether to enable libmodbus backend]) +AC_ARG_ENABLE(backend-libmodbus, + AS_HELP_STRING([--enable-backend-libmodbus], [enable libmodbus backend @<:@default=no@:>@]), + [case "$enableval" in + y | yes) CONFIG_BACKEND_LIBMODBUS=yes ;; + *) CONFIG_BACKEND_LIBMODBUS=no ;; + esac], + [CONFIG_BACKEND_LIBMODBUS=no] +) +AM_CONDITIONAL(BACKEND_LIBMODBUS, test "${CONFIG_BACKEND_LIBMODBUS}" = "yes") +AC_MSG_RESULT([${CONFIG_BACKEND_LIBMODBUS}]) + +if test "${CONFIG_BACKEND_LIBMODBUS}" = "yes"; then + + REQUIRES_LIBMODBUS="libmodbus >= 1.0.3" + AC_SUBST(REQUIRES_LIBMODBUS) + PKG_CHECK_MODULES([libmodbus], + [${REQUIRES_LIBMODBUS}], + [], + [AC_MSG_ERROR([${REQUIRES_LIBMODBUS} not found by pkg-config on your system])] + ) + AC_SUBST(libmodbus_CFLAGS) + AC_SUBST(libmodbus_LIBS) + + AC_MSG_CHECKING([whether libmodbus backend finds an xml parser]) + if test "${CONFIG_XMLPARSER}" != "libxml2"; then + AC_MSG_RESULT([no]) + AC_MSG_ERROR([libmodbus backend needs libxml2, specify with --with-xmlparser]) + else + AC_MSG_RESULT([yes]) + fi + +fi + + +AC_MSG_CHECKING([whether to enable can backend]) +AC_ARG_ENABLE(backend-can, + AS_HELP_STRING([--enable-backend-can], [enable can backend @<:@default=no@:>@]), + [case "$enableval" in + y | yes) CONFIG_BACKEND_CAN=yes ;; + *) CONFIG_BACKEND_CAN=no ;; + esac], + [CONFIG_BACKEND_CAN=no] +) +AM_CONDITIONAL(BACKEND_CAN, test "${CONFIG_BACKEND_CAN}" = "yes") +AC_MSG_RESULT([${CONFIG_BACKEND_CAN}]) + +if test "${CONFIG_BACKEND_CAN}" = "yes"; then + + AC_CHECK_HEADER([linux/can.h], have_can_h=yes,, [[ + #include + ]]) + if test "$have_can_h" != "yes"; then + AC_MSG_ERROR([linux/can.h must be available when building with --enable-backend-can]) + fi + +fi + + +# +# Documentation +# + +AC_MSG_CHECKING(whether to build doxygen documentation) +AC_ARG_ENABLE(doc, + AS_HELP_STRING([--enable-doc], [enable documentation @<:@default=no@:>@]), + [case "$enableval" in + y | yes) CONFIG_DOCUMENTATION=yes ;; + *) CONFIG_DOCUMENTATION=no ;; + esac], + [CONFIG_DOCUMENTATION=no] +) + +#if test \! -d $srcdir/doc ; then +# if test x$CONFIG_XENO_DOC_DOX = xy ; +# then +# AC_MSG_ERROR([documentation tree is missing.]) +# fi +# AC_MSG_RESULT([not present]) +#else +# AC_MSG_RESULT(${CONFIG_XENO_DOC_DOX:-no}) +#fi + +AC_CHECK_PROG(DOXYGEN, doxygen, doxygen) +if test "$CONFIG_DOCUMENTATION" = "y" -a -z "$DOXYGEN"; then + AC_MSG_ERROR([you need doxygen to generate the documentation, or use --disable-doc]) +fi + +AC_CHECK_PROG(DOXYGEN_HAVE_DOT, dot, YES, NO) +if test "$DOXYGEN_HAVE_DOT" = "YES" ; then + DOXYGEN_SHOW_INCLUDE_FILES=NO +else + DOXYGEN_SHOW_INCLUDE_FILES=YES +fi + + +# +# Finished +# + +AC_CONFIG_FILES([ + GNUmakefile + config/libfddi.pc + config/GNUmakefile + include/GNUmakefile + src/GNUmakefile + tests/GNUmakefile + ]) +AC_OUTPUT + Added: branches/fddi-mapping/doc/GNUmakefile.am ============================================================================== --- (empty file) +++ branches/fddi-mapping/doc/GNUmakefile.am Tue Oct 2 16:30:06 2007 @@ -0,0 +1,29 @@ +DOCBOOKFILES = $(wildcard *.docbook) +HTMLFILES = $(patsubst %.docbook,%.html,$(DOCBOOKFILES)) +TXTFILES = $(patsubst %.docbook,%.txt,$(DOCBOOKFILES)) +HTMLXSL = /usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl +XMLTO = xmlto + +all: $(HTMLFILES) $(TXTFILES) + +%.html: %.docbook + # $(XMLTO) -x $(HTMLXSL) html $< + # mv $(subst .docbook,.proc,$<) $(subst .docbook,.html,$<) + xsltproc --output $(subst .docbook,.html,$<) --stringparam section.autolabel 1 $(HTMLXSL) $< + touch *.wml + +%.txt: %.html + lynx -dump $< > $@ + #recode utf8..latin1 $@ + +clean: + rm -f $(HTMLFILES) $(TXTFILES) osadl-*.html + +osadl-fieldbus-framework.html: OSADL-Fieldbus-Framework-20070809-1.html + +EXTRA_DIST = \ + OSADL-Fieldbus-Framework-20070809-1.docbook + +MAINTAINERCLEANFILES = \ + GNUmakefile.in + Added: branches/fddi-mapping/doc/OSADL-FieldbusFramework-20070809-1.docbook ============================================================================== --- (empty file) +++ branches/fddi-mapping/doc/OSADL-FieldbusFramework-20070809-1.docbook Tue Oct 2 16:30:06 2007 @@ -0,0 +1,140 @@ + + + + +
+ + + + + + Robert + Schwebel + + + + + + OSADL Fieldbus Framework + + + + + 0.1 + 2007-08-09 + Draft + + + + + + + + +Rationale + + + Industrial I/O components are the central interface between today's + automation systems and our physical environment. As Linux is becoming + more and more the first-class choice for embedded controllers, measurement + devices, soft PLCs and other control equipment throughout the industry, + there is still no commonly accepted way to connect I/O devices to a POSIX + operating system. + + Although modern embedded controllers use more and more + decentralized infrastructure and although there is a huge variety of + fieldbus topologies available today, we are still far away from the + situation we have in the IT business: today's server infrastructure + is completely based on open standards. It simply does not matter if + you buy a network card from vendor A or vendor B: nobody would ever + try to start changing lowlevel hardware access code inside of the + apache web server just in case of a hardware change. But that's exactly + how industral I/O works today. There is no generally accepted interface + for accessing fieldbusses and local I/O on the market. + + OSADL, being an organization who's members are machine building + companies, software specialists and embedded Linux experts, has the + declared aim to join market forces in order to make such a unified + framework possible. This document outlines the ideas and concepts behind + the OSADL Fieldbus Framework. + + + + + + + + + +BSP Definition + + + bla bla + + + + foo + + bar + + + + + - kernel.org ---> BSP Provider ---> Board Vendor ---> End Customer + BSP BSP + + + Sub Chapter + + gargelpu + + + + + + +Glossary and Abbreviations + + + + + + Vanilla Kernel + + + The generally accepted main version of the Linux kernel is + being maintained by Linus Torvalds. It is the base for all + distributions, is the most whidespread version and the base for + all kernel development activities. The vanilla kernel can be + downloaded from http://www.kernel.org/. + + + + + + + + + + + +Authors + + + +Robert Schwebel +Pengutronix +Hannoversche Stra?e 2 +31134 Hildesheim +Tel. +49-5121-206917-0 +Fax: +49-5121-206917-9 +e-Mail: r.schwebel at pengutronix.de +URI: http://www.pengutronix.de + + + + + +
Added: branches/fddi-mapping/doc/fddi_modbus_config_3s-20070710-7.odt ============================================================================== Binary file. No diff available. Added: branches/fddi-mapping/doc/fddi_proposal_3s-20070618-1.odt ============================================================================== Binary file. No diff available. Added: branches/fddi-mapping/doc/header.txt ============================================================================== --- (empty file) +++ branches/fddi-mapping/doc/header.txt Tue Oct 2 16:30:06 2007 @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ Added: branches/fddi-mapping/include/GNUmakefile.am ============================================================================== --- (empty file) +++ branches/fddi-mapping/include/GNUmakefile.am Tue Oct 2 16:30:06 2007 @@ -0,0 +1,17 @@ +noinst_HEADERS = \ + fddistuff.h + +nobase_include_HEADERS = \ + osadl/fddi.h \ + osadl/fddi_device.h \ + osadl/fddi_id.h \ + osadl/fddi_iface.h \ + osadl/fddi_param.h \ + osadl/fddi_pv.h \ + osadl/fddi_tpu.h \ + osadl/fddi_types.h + +MAINTAINERCLEANFILES = \ + fddi_config.h.in \ + GNUmakefile.in + Added: branches/fddi-mapping/include/fddistuff.h ============================================================================== --- (empty file) +++ branches/fddi-mapping/include/fddistuff.h Tue Oct 2 16:30:06 2007 @@ -0,0 +1,5 @@ +#ifndef FDDI_H +#define FDDI_H + + +#endif Added: branches/fddi-mapping/include/osadl/attic/fddi_hess.h ============================================================================== --- (empty file) +++ branches/fddi-mapping/include/osadl/attic/fddi_hess.h Tue Oct 2 16:30:06 2007 @@ -0,0 +1,434 @@ +#ifndef _OSADL_FDDI_H +#define _OSADL_FDDI_H + +/* fieldbus device driver interface */ + + +/* #include "lldi.h" */ +typedef void *LL_INTERFACE; +struct _io_interface_inst; +struct _io_device; +enum _io_device_command; + +/* result codes */ +#define RESOK 0 +#define RESERR_INTERFACE_ALREADY_REGISTERD 1 +#define RESERR_LLINTERFACE_ALREADY_IN_USE 2 +#define RESERR_LLINTERFACE_HAS_WRONG_TYPE 3 +#define RESERR_OUT_OF_MEM 4 +#define RESERR_TIMEOUT 5 +#define RESERR_NO_ACCESS 6 +#define RESERR_BUFFER_TO_SMALL 7 +#define RESERR_WRONGTPUTYPE 8 +#define RESERR_UNKOWNADDRESS 9 + +/* io-interface */ + +#if 0 + +bind() +configure() +scan() +read_device_async() +write_device_async() +cmd_device() + +#endif + +struct _io_interface +{ + char* name; /* name of the interface */ + unsigned long version; /* version of the interface */ + + int (*_fptr_bind_io_interface)(char* name, LL_INTERFACE llitf, struct _io_interface_inst **result); + /* function pointer of the bind_io_interface method (see bind_io_interface for further information) */ + int (*_fptr_configure_io_interface_inst)(struct _io_interface_inst *itfinst, struct _io_device *root); + /* function pointer of the configure_io_interface_inst method (see configure_io_interface for further information) */ + int (*_fptr_scan_io_interface_inst)(struct _io_interface_inst *itfinst, struct _io_device **root); + /* function pointer of the scan_io_interface_inst method (see scan_io_interface_inst for further information) */ + int (*_fptr_read_device_async)(struct _io_device *dev, unsigned long address, unsigned char* buf, unsigned long buf_size, unsigned long* read_size); + /* function pointer of the read_iodevice_async method (see scan_io_interface_inst for further information) */ + int (*_fptr_write_device_async)(struct _io_device *dev, unsigned long address, unsigned char* buf, unsigned long size); + /* function pointer of the write_iodevice_async method (see scan_io_interface_inst for further information) */ + int (*_fptr_cmd_device)(struct _io_device *dev, enum _io_device_command cmd); + /* function pointer of the cmd_iodevice method (see scan_io_interface_inst for further information) */ +}; + +typedef struct _io_interface *IO_INTERFACE; + + +/* instance of io-interface */ +struct _io_interface_inst +{ + char* name; /* name of the io-interface-instance */ + IO_INTERFACE ioitf; /* the type of the io-interface */ + LL_INTERFACE llitf; /* the low level interface, to which the io-interface is bound to */ + + struct _io_device *root; /* root device, set during configuration */ + + int num_tpus; /* number of io-transport units (set after configuration) */ + struct _io_transport_unit **tpus; /* list of io-transport units (set after configuration by fddi-driver) */ + + int num_dev; /* number of devices */ + struct _io_device **devlist; /* linear list of all devices (set automatically after configuration by fddi) */ + + int num_var; /* number of variables */ + struct _io_variable **varlist; /* linear list of all variables (set after configuration by fddi-driver) */ + + void* inst_data; /* type specific management data */ +}; + +typedef struct _io_interface_inst *IO_INTERFACE_INST; + + +/* io-device */ +enum _io_device_state +{ + DEVSTATE_VOID, /* the device is not configured */ + DEVSTATE_MISSING, /* the configuration of the device failed, because it is missing */ + DEVSTATE_CONFIG_ERROR, /* the configuration of the device failed, because of wrong config data */ + DEVSTATE_PREOPERATIONAL, /* the device is configured, but not working */ + DEVSTATE_OPERATIONAL, /* the device is working */ + DEVSTATE_OPERATION_ERROR /* the device encountered an error, while it is working */ +}; + +typedef enum _io_device_state IO_DEVICE_STATE; + +enum _io_device_command +{ + DEVCMD_START, /* start the device */ + DEVCMD_STOP, /* stop the device */ + DEVCMD_RESET, /* reset the device */ + DEVCMD_IDENTIFY, /* let the device do something to identify itself (like blinking with a LED) */ + DEVCMD_QUITERR /* quit an error of the device, to return to normal operation */ +}; + +typedef enum _io_device_command IO_DEVICE_COMMAND; +/* use this datatype with the function cmd_iodevice */ + +struct _io_device_param +{ + unsigned long key; + unsigned long value; + unsigned short flags; +}; + +#define PARAMFLAG_PTR 0 /* value contains a pointer to a struct (frist word of the struct is size) */ +#define PARAMFLAG_BYTE 1 /* value contais a byte */ +#define PARAMFLAG_WORD 2 /* value contains a word */ +#define PARAMFLAG_LONG 3 /* value contains a double word */ +#define PARAMFLAG_TYPEMASK 3 /* value contains a double word */ +#define PARAMFLAG_DEFAULT 4 /* value contains a device default parameter. the parameter is used to set up the configuration, + * but need not to be sent to the device + */ + +typedef struct _io_device_param IO_DEVICE_PARAM; + +struct _io_device +{ + IO_INTERFACE_INST itfinst; /* reference to owning io-interface instance (set by fddi) */ + + unsigned long physical_id; /* physical id of the device */ + unsigned long logical_id; /* logical id of the device */ + unsigned long type_id; /* type id of the device */ + char* name; /* optional name of the device (from configuration) */ + + int num_params; /* number of parameters */ + IO_DEVICE_PARAM* params; /* pointer to list of parameters */ + + struct _io_device* parent; /* parent device */ + struct _io_device* first_child; /* first child device of this device */ + struct _io_device* next_child;/* next child of the same parent */ + + IO_DEVICE_STATE state; /* state of the device */ +}; + +typedef struct _io_device *IO_DEVICE; + +#define MAXCALLBACKS 3 + +/* io-transport unit */ +struct _io_transport_unit +{ + IO_INTERFACE_INST itfinst; /* reference to owning io-interface instance (set by fddi) */ + + unsigned long id; + unsigned long time_stamp; + unsigned long flags; + unsigned long size; + unsigned char* buf_read; + unsigned char* buf_write; + + int num_callbacks; + void (*callback[MAXCALLBACKS])(struct _io_transport_unit *iotpu); + + int read_count; + int write_count; + + int num_var; /* number of variables */ + struct _io_variable **varlist; /* linear list of all variables (set after configuration by fddi-driver) */ +}; + +#define TPUFLAG_IN 1 /* application reads from this transport unit */ +#define TPUFLAG_OUT 2 /* application writes to this transport unit */ +#define TPUFLAG_SYNC 4 /* this transport unit synchronizes a group of io-devices */ +#define TPUFLAG_EXTMEM 8 /* the memory of this transport unit is not maintained by the fddi */ +#define TPUFLAG_CONSIST 16 /* the memory of this transport unit is kept consistent by the fddi (cannot be used with TPUFLAG_EXTMEM) */ + +typedef struct _io_transport_unit *IO_TRANSPORT_UNIT; + + +/* io-variable */ +struct _io_variable +{ + char* name; /* optional name of the variable */ + unsigned long size; /* size of the variable */ + unsigned long offset; /* offset of the variable in io-transport unit */ + + IO_TRANSPORT_UNIT iotpu;/* reference to io-transport unit */ + IO_DEVICE iodev; /* reference to io-device */ +}; + +typedef struct _io_variable *IO_VARIABLE; + + + +/* functions of the fddi */ +int register_io_interface(IO_INTERFACE ioitf); + /* registers a new io-interface to the fddi layer (for example a CANopen stack) + * + * ioitf: [in] the definition of the new interface + * + * result: RESOK, RESERR_INTERFACE_ALREADY_REGISTERD, RESERR_OUT_OF_MEM + * + * remarks: this function is only called by the module which implements his own driver + * it need not to be called by users of an existiong driver + */ + +int bind_io_interface(IO_INTERFACE ioitf, char* name, LL_INTERFACE llitf, IO_INTERFACE_INST* res); + /* binds a io-interface to a hardware interface (for example a CANopen stack to CAN interface 1) + * + * name: [in] name of the interface instance (for example "CANopen on can1") + * The name can be used to open the instance + * llitf: [in] handle of the low level interface, to which the io_interface should be bound to + * res: [out] pointer to resulting interface instace + * + * result: RESOK, RESERR_LLINTERFACE_ALREADY_IN_USE, RESERR_LLINTERFACE_HAS_WRONG_TYPE, RESERR_OUT_OF_MEM + */ + +int enum_io_interfaces(IO_INTERFACE** ioitfs); + /* enumerates all registered io-interfaces + * + * ioitfs: [out] pointer to pointer to an array of io_interfaces + * + * result: Because this function can never fail, the number of io_interfaces is returned + */ + +int enum_io_interface_instances(IO_INTERFACE_INST** ioitfinsts); + /* enumerates all io-interface instances + * + * ioitfinsts: [out] pointer to pointer to an array of io-interfaces-instances + * + * result: Because this function can never fail, the number of io interfaces instances is returned + */ + +IO_INTERFACE get_io_interface(char* name); + /* retrieves a io-interface by its name + * + * name: [in] name of the io-interface to retrieved + * + * result: the io-interface with the given name or null if the name was not found + */ + +IO_INTERFACE_INST get_io_interface_inst(char* name); + /* retrieves a io-interface instance by its name + * + * name: [in] name of the io-interface instance to retrieved + * + * result: the io-interface instance with the given name or null if the name was not found + */ + +int enum_io_transport_units(IO_INTERFACE_INST ioitfinst, IO_TRANSPORT_UNIT** iotpus); + /* enumerates all configured io-transport-units of an io-interface instances + * + * ioitfinst: [in] interface instance, which content should be enumerated + * iotpus: [out] pointer to pointer to an array of io-transport-units + * + * result: Because this function can never fail, the number of io-transport-units is returned + */ + +int enum_io_devices(IO_INTERFACE_INST ioitfinst, IO_DEVICE** iodevices); + /* enumerates all configured io-devices of an io-interface instances as a flat list + * + * ioitfinst: [in] interface instance, which content should be enumerated + * iodevices: [out] pointer to pointer to an array of io-devices + * + * result: Because this function can never fail, the number of io-devices is returned + */ + +int enum_io_variables(IO_INTERFACE_INST ioitfinst, IO_VARIABLE** iovars); + /* enumerates all configured io-variables of an io-interface instances + * + * ioitfinst: [in] interface instance, which content should be enumerated + * iovars: [out] pointer to pointer to an array of io-variables + * + * result: Because this function can never fail, the number of io-variables is returned + */ + +int configure_io_interface_inst(IO_INTERFACE_INST ioitfinst, IO_DEVICE root); + /* configures a io-interface instance + * + * ioitfinst: [in] the interface to be configured + * root: [in] root node, which contains the configured child nodes. + * Typically the root node contains the interface hardware and the childs are the fieldbus slaves. + * The following members of IO_DEVICE are expected to be set correctly in each node: + * + * logical_id; + * type_id; + * name; (optional) + * + * num_params; + * params; + * + * parent; + * first_child; + * next_child; + * + * result: RESOK, RESERR_OUT_OF_MEM + * remarks: all previous configurations are disgarded. + * configuration can take some time. it can be useful to do process it in a extra thread with a timeout. + */ + +int scan_io_interface_inst(IO_INTERFACE_INST itfinst, IO_DEVICE *root); + /* scans a io-interface instance for all connected devices + * + * ioitfinst: [in] the interface to be scanned + * root: [out] root node, which contains the connected child nodes. The following members of IO_DEVICE + * are set: + * + * pysical_id + * logical_id; + * type_id; + * name; (optional) + * + * parent; + * first_child; + * next_child; + * + * result: RESOK, RESERR_OUT_OF_MEM + * remarks: a previous configurations is not disgarded. + * scan can take some time. it can be useful to do process it in a extra thread with a timeout. + */ + +int read_iodevice_async(IO_DEVICE iodev, unsigned long address, unsigned char* buf, unsigned long buf_size, unsigned long* read_size); + /* performs an asynchronous read (for example CANopen SDO, Profibus DPV1 etc.) on an io-device + * + * iodev: [in] device on which the read operation is done + * address: [in] address in the device + * buf: [out] buffer to receive the result + * buf_size:[in] size of the buffer / size of the data to read + * read_size:[out] size of the data, which was actually read + * + * result: RESOK, RESERR_TIMEOUT, RESERR_NO_ACCESS, RESERR_BUFFER_TO_SMALL + * remarks: async read can take some time. it can be useful to do process it in a extra thread with a timeout. + */ + +int write_iodevice_async(IO_DEVICE iodev, unsigned long address, unsigned char* buf, unsigned long size); + /* performs an asynchronous write (for example CANopen SDO, Profibus DPV1 etc.) on an io-device + * + * iodev: [in] device on which the write operation is done + * address: [in] address in the device + * buf: [in] buffer with the data to write + * buf_size:[in] size of the data to write + * + * result: RESOK, RESERR_TIMEOUT, RESERR_NO_ACCESS + * remarks: async write can take some time. it can be useful to do process it in a extra thread with a timeout. + */ + +int cmd_iodevice(IO_DEVICE iodev, IO_DEVICE_COMMAND cmd); + /* performs a command like start, stop, reset on an io-device + * + * iodev: [in] device on which the command should be done + * cmd: [in] the command (see definition of IO_DEVICE_COMMAND) + * + * result: RESOK, RESERR_TIMEOUT, RESERR_NO_ACCESS + * remarks: cmd_iodevice can take some time. it can be useful to do process it in a extra thread with a timeout. + * a command done on the root device typically, executes the command for all devices (start, stop) + */ + +int enum_io_variables_of_iodevice(IO_DEVICE iodev, IO_VARIABLE** iovars); + /* enumerates all configured io-variables of an io-device + * + * iodev: [in] device, which content should be enumerated + * iovars: [out] pointer to pointer to an array of io-variables + * + * result: Because this function can never fail, the number of io-variables is returned + */ + +unsigned char* address_to_read(IO_TRANSPORT_UNIT iotpu); + /* Get the adress of the process data of a io-transport unit to read on it + * + * iotpu: [in] transport unit of which the address is retrieved + * + * result: the address + * remarks: only read operations should be done on the memory area. + * use release_address after finishing read operations. + */ + +unsigned char* address_to_write(IO_TRANSPORT_UNIT iotpu); + /* Get the address of the process data of a io-transport unit to write (modify) it + * + * iotpu: [in] transport unit of which the address is retrieved + * + * result: the adress + * remarks: if the complete memory of the io-transport unit is written, use address_to_replace, because it may be faster. + * use release_adress after finishing write operations. + */ + +unsigned char* address_to_replace(IO_TRANSPORT_UNIT iotpu); + /* Get the address of the process data of a io-transport unit to write the complete process data + * + * iotpu: [in] transport unit of which the address is retrieved + * + * result: the adress + * remarks: this function is faster on consistent transport units than address_to_write + * use release_adress after finishing write operations. + */ + +int release_adress(IO_TRANSPORT_UNIT iotpu, unsigned char* address); + /* Releases an address, previously retrieved by address_to_read, address_to_write, address_to_replace + * + * iotpu: [in] transport unit of which the address is released + * address: [in] address to release + * + * result: RESOK, RESERR_UNKOWNADDRESS + */ + +int send_iotransport_unit(IO_TRANSPORT_UNIT iotpu); + /* Explcitly send an io-transport unit, to do I/O syncronously, application triggered + * + * iotpu: [in] transport unit which is to be sent + * + * result: RESOK, RESERR_WRONGTPUTYPE + */ + +int register_callback_to_iotransport_unit(IO_TRANSPORT_UNIT iotpu, void (*callback)(IO_TRANSPORT_UNIT iotpu)); + /* Registers a callback function to a io-transport unit, to do I/O synchronously, IO-system triggered + * + * iotpu: [in] transport unit which should trigger the callback + * callback:[in] callback function, which supplies a reference to the io-transport unit as parameter + * + * result: RESOK, RESERR_WRONGTPUTYPE + * remarks: the callback is called after a write operation is finished (release_address) on the given transport unit + */ + +int enum_io_variables_of_iotransport_unit(IO_TRANSPORT_UNIT iotpu, IO_VARIABLE** iovars); + /* enumerates all configured io-variables of an io-transport-unit + * + * iotpu: [in] transport unit, which content should be enumerated + * iovars: [out] pointer to pointer to an array of io-variables + * + * result: Because this function can never fail, the number of io-variables is returned + */ +#endif + Added: branches/fddi-mapping/include/osadl/fddi.h ============================================================================== --- (empty file) +++ branches/fddi-mapping/include/osadl/fddi.h Tue Oct 2 16:30:06 2007 @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_H +#define OSADL_FDDI_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif Added: branches/fddi-mapping/include/osadl/fddi_device.h ============================================================================== --- (empty file) +++ branches/fddi-mapping/include/osadl/fddi_device.h Tue Oct 2 16:30:06 2007 @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_DEVICE_H +#define OSADL_FDDI_DEVICE_H + +#include +#include + +struct fddi_device { + + /* public */ + fddi_id_t id; + fddi_state_enum_t state; + + /* private */ + struct fddi_device *next; + struct fddi_device *previous; + + fddi_param_t *param_list; + + void *priv; + +}; + +/* fddi_device_t */ +extern int fddi_dev_getnext(fddi_device_t **dev); +extern int fddi_dev_getname(fddi_device_t *dev, char **name); +extern int fddi_dev_getstate(fddi_device_t *dev, fddi_state_enum_t *state); +extern int fddi_dev_getstatestr(fddi_device_t *dev, char **state); +extern int fddi_dev_getphysid(fddi_device_t *dev, int *id); +extern int fddi_dev_getlogicalid(fddi_device_t *dev, int *id); +extern int fddi_dev_getparamlist(fddi_device_t *dev, fddi_param_t **param); +extern int fddi_dev_getnotpus(fddi_device_t *dev); +extern int fddi_dev_read_async(fddi_device_t *dev /* FIXME */); +extern int fddi_dev_write_async(fddi_device_t *dev /* FIXME */); + +#endif + Added: branches/fddi-mapping/include/osadl/fddi_id.h ============================================================================== --- (empty file) +++ branches/fddi-mapping/include/osadl/fddi_id.h Tue Oct 2 16:30:06 2007 @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_ID_H +#define OSADL_FDDI_ID_H + +#include + +#include + +struct fddi_id { + + /* public */ + + /* private */ + char *prefix; + int index; + char *suffix; + + char *id_as_string; + size_t id_as_str_len; + + void *priv; +}; + +extern int fddi_id_init(fddi_id_t *fddi_id, const char *prefix, int index, const char *suffix); +extern int fddi_id_getid(fddi_id_t *fddi_id, char *id_string, size_t len); +extern int fddi_id_destroy(fddi_id_t *fddi_id); + +#endif + Added: branches/fddi-mapping/include/osadl/fddi_iface.h ============================================================================== --- (empty file) +++ branches/fddi-mapping/include/osadl/fddi_iface.h Tue Oct 2 16:30:06 2007 @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_IFACE_H +#define OSADL_FDDI_IFACE_H + +#include + +struct fddi_iface_attr { + + /* public */ + char *path; + fddi_id_t id; + + char *fddi_class_name; /* FIXME */ + +}; + +struct fddi_iface_backend_ops { + + int (*init) (fddi_iface_t *iface); + int (*destroy) (fddi_iface_t *iface); + int (*configure) (fddi_iface_t *iface, const char *configfile, void *data); + int (*setstate) (fddi_iface_t *iface, fddi_state_enum_t state); + int (*cmd) (fddi_iface_t *iface, fddi_cmd_enum_t cmd); + +}; + +struct fddi_iface { + + /* public */ + fddi_id_t id; + fddi_state_enum_t state; + + /* private */ + fddi_device_t *devlist_head; + unsigned int nodev; + + fddi_tpu_t *tpulist_head; + unsigned int notpus; + + unsigned int nopvs; + + void *backend_lib; + fddi_iface_backend_ops_t backend; + + void *priv; +}; + +/* fddi_iface_attr_t */ +extern int fddi_iface_attr_init(fddi_iface_attr_t *attr); +extern int fddi_iface_attr_setclass(fddi_iface_attr_t *attr, char *fddi_class_name); +extern int fddi_iface_attr_setid(fddi_iface_attr_t *attr, const char *path, fddi_id_t device_id); + +/* fddi_iface_t */ +extern int fddi_iface_init(fddi_iface_t *iface, fddi_iface_attr_t *attr); +extern int fddi_iface_destroy(fddi_iface_t *iface); +extern int fddi_iface_configure(fddi_iface_t *iface, const char *configfile, void *data); +extern int fddi_iface_setstate(fddi_iface_t *iface, fddi_state_enum_t state); +extern int fddi_iface_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd); +extern int fddi_iface_getid(fddi_iface_t *iface, fddi_id_t *id); +extern int fddi_iface_setid(fddi_iface_t *iface, fddi_id_t id); +extern int fddi_iface_getnodev(fddi_iface_t *iface); +extern int fddi_iface_getnotpus(fddi_iface_t *iface); +extern int fddi_iface_getnopvs(fddi_iface_t *iface); +extern int fddi_iface_getdevlist(fddi_iface_t *iface, fddi_device_t **dev); +extern int fddi_iface_gettpulist(fddi_iface_t *iface, fddi_tpu_t **tpu); +extern int fddi_iface_getversionstr(fddi_iface_t *iface, const char **version); +extern int fddi_iface_getversion(fddi_iface_t *iface, int *version); +/* + * TODO: split public/private + * TODO: add_tpu(), with counts + * TODO: add_pv(), with counts + */ + +#endif + Added: branches/fddi-mapping/include/osadl/fddi_param.h ============================================================================== --- (empty file) +++ branches/fddi-mapping/include/osadl/fddi_param.h Tue Oct 2 16:30:06 2007 @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_PARAM_H +#define OSADL_FDDI_PARAM_H + +#include + +struct fddi_param { + + /* public */ + char *key; + char *val; + unsigned long flags; + + /* private */ + struct fddi_param *next; + struct fddi_param *previous; + + void *priv; + +}; + +/* fddi_param_t */ +extern int fddi_param_getnext(fddi_param_t **param); +extern int fddi_param_getkey(fddi_param_t *param, char **val); +extern int fddi_param_getval(fddi_param_t *param, char **val); +extern int fddi_param_getflags(fddi_param_t *param, unsigned long *flags); /* FIXME */ +extern int fddi_param_getnotpus(fddi_param_t *param, int *notpus); + +#endif + Added: branches/fddi-mapping/include/osadl/fddi_pv.h ============================================================================== --- (empty file) +++ branches/fddi-mapping/include/osadl/fddi_pv.h Tue Oct 2 16:30:06 2007 @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_PV_H +#define OSADL_FDDI_PV_H + +#include + +#include +#include + +struct fddi_pv { + + /* public */ + fddi_id_t id; + fddi_param_t *name; + fddi_pv_type_enum_t type; + + /* private */ + struct fddi_pv *next; + struct fddi_pv *previous; + fddi_param_t *param_list_head; + unsigned int offset; + unsigned int bit; + + void *priv; +}; + +/* fddi_pv_t */ +extern int fddi_pv_uint32_init(fddi_pv_t *pv, fddi_pv_attr_t *attr); +extern int fddi_pv_uint32_destroy(fddi_pv_t *pv); +extern uint32_t fddi_pv_uint32_get(fddi_pv_t *pv); +extern void fddi_pv_uint32_set(fddi_pv_t *pv, uint32_t val); +#define fddi_pv_UINT32_init fddi_pv_uint32_init +#define fddi_pv_UINT32_destroy fddi_pv_uint32_destroy +#define fddi_pv_UINT32_get fddi_pv_uint32_get +#define fddi_pv_UINT32_set fddi_pv_uint32_set + +/* FIXME: add other data types */ + +extern int fddi_pv_getnext(fddi_pv_t **pv); +extern int fddi_pv_getname(fddi_pv_t *pv, char **name); + +#endif + Added: branches/fddi-mapping/include/osadl/fddi_pv_attr.h ============================================================================== --- (empty file) +++ branches/fddi-mapping/include/osadl/fddi_pv_attr.h Tue Oct 2 16:30:06 2007 @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_PV_ATTR_H +#define OSADL_FDDI_PV_ATTR_H + +#include +#include +#include + +struct fddi_pv_attr { + + /* public */ + fddi_pv_type_enum_t type; + + char *name; + fddi_pv_group_t *pv_group; + + /* private */ + + void *priv; + +}; + +/* fddi_pv_t */ +extern int fddi_pv_attr_init(fddi_pv_attr_t *pv_attr, fddi_pv_group_t *pv_group, const char *name); +extern int fddi_pv_attr_destroy(fddi_pv_attr_t *pv_attr); + +#endif + Added: branches/fddi-mapping/include/osadl/fddi_pv_engine.h ============================================================================== --- (empty file) +++ branches/fddi-mapping/include/osadl/fddi_pv_engine.h Tue Oct 2 16:30:06 2007 @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_PV_ENGINE_H +#define OSADL_FDDI_PV_ENGINE_H + +#include + +struct fddi_pv_engine { + + /* public */ + + /* private */ + + void *priv; +}; + +/* pv_engine_t */ +extern int fddi_pv_engine_init(fddi_pv_engine_t *pv_engine); +extern int fddi_pv_engine_destroy(fddi_pv_engine_t *pv_engine); +extern int fddi_pv_engine_configure_from_cmdline(fddi_pv_engine_t *pv_engine, int argc, char *argv[]); + +#endif + Added: branches/fddi-mapping/include/osadl/fddi_pv_group.h ============================================================================== --- (empty file) +++ branches/fddi-mapping/include/osadl/fddi_pv_group.h Tue Oct 2 16:30:06 2007 @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_PV_GROUP_H +#define OSADL_FDDI_PV_GROUP_H + +#include +#include + +struct fddi_pv_group { + + /* public */ + + /* private */ + + void *priv; +}; + +/* fddi_pv_group_t */ +extern int fddi_pv_group_init(fddi_pv_group_t *pv_group, fddi_pv_group_attr_t *attr); +extern int fddi_pv_group_destroy(fddi_pv_group_t *pv_group); +extern int fddi_pv_group_wait_and_lock(fddi_pv_group_t *pv_group); +extern int fddi_pv_group_unlock(fddi_pv_group_t *pv_group); + +#endif + Added: branches/fddi-mapping/include/osadl/fddi_pv_group_attr.h ============================================================================== --- (empty file) +++ branches/fddi-mapping/include/osadl/fddi_pv_group_attr.h Tue Oct 2 16:30:06 2007 @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_PV_GROUP_ATTR_H +#define OSADL_FDDI_PV_GROUP_ATTR_H + +#include + +struct fddi_pv_group_attr { + + /* public */ + + /* private */ + + void *priv; + +}; + +/* fddi_pv_group_attr_t */ +extern int fddi_pv_group_attr_init(fddi_pv_group_attr_t *pv_group_attr, fddi_pv_engine_t *pv_engine); +extern int fddi_pv_group_attr_destroy(fddi_pv_group_attr_t *pv_group_attr); +extern int fddi_pv_group_attr_setname(fddi_pv_group_attr_t *pv_group_attr, const char *name); + +#endif + Added: branches/fddi-mapping/include/osadl/fddi_tpu.h ============================================================================== --- (empty file) +++ branches/fddi-mapping/include/osadl/fddi_tpu.h Tue Oct 2 16:30:06 2007 @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_TPU_H +#define OSADL_FDDI_TPU_H + +#include + +typedef enum { + + IN, + OUT, + INOUT, + +} fddi_tpu_direction_enum_t; + +struct fddi_tpu { + + /* public */ + fddi_id_t id; + uint64_t cycletime; /* ns */ + fddi_tpu_direction_enum_t direction; + + /* private */ + struct fddi_tpu *next; /* TODO: generic list */ + struct fddi_tpu *previous; + + fddi_pv_t *pv_list_head; + char *payload; + + void *callback_arg; + int (*callback) (fddi_tpu_t *tpu, void *arg); + + void *priv; + +}; + +/* fddi_tpu_t */ +extern int fddi_tpu_getnext(fddi_tpu_t **tpu); +extern int fddi_tpu_getid(fddi_tpu_t *tpu, fddi_id_t *id); +extern int fddi_tpu_gettimestamp(fddi_tpu_t *tpu, int *timestamp); /* FIXME tv */ +extern int fddi_tpu_setcallback(fddi_tpu_t *tpu, int(*tpu_callback)(fddi_tpu_t *tpu, void *arg), void *arg); +extern int fddi_tpu_getpvlist(fddi_tpu_t *tpu, fddi_pv_t **pv); +extern int fddi_tpu_getpayload(fddi_tpu_t *tpu, char **payload); +extern int fddi_tpu_transfer(fddi_tpu_t *tpu); + +#endif Added: branches/fddi-mapping/include/osadl/fddi_types.h ============================================================================== --- (empty file) +++ branches/fddi-mapping/include/osadl/fddi_types.h Tue Oct 2 16:30:06 2007 @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef OSADL_FDDI_TYPES_H +#define OSADL_FDDI_TYPES_H + +typedef enum fddi_state_enum fddi_state_enum_t; +typedef enum fddi_cmd_enum fddi_cmd_enum_t; + +enum fddi_state_enum { + + STATE_UNCONFIGURED, /* the device is not configured */ + STATE_MISSING, /* the configuration of the device failed, because it is missing */ + STATE_CONFIG_ERROR, /* the configuration of the device failed, because of wrong config data */ + STATE_PREOPERATIONAL, /* the device is configured, but not working */ + STATE_OPERATIONAL, /* the device is working */ + STATE_OPERATION_ERROR /* the device encountered an error, while it is working */ + +}; + +enum fddi_cmd_enum { + + CMD_START, /* start the device */ + CMD_STOP, /* stop the device */ + CMD_RESET, /* reset the device */ + CMD_IDENTIFY, /* let the device do something to identify itself (like blinking with a LED) */ + CMD_QUITERR /* quit an error of the device, to return to normal operation */ + +}; + +typedef enum { + + /* little endian */ + LE_UINT8, + LE_UINT16, + LE_UINT32, + LE_UINT64, + + LE_INT8, + LE_INT16, + LE_INT32, + LE_INT64, + + LE_FLOAT, + LE_DOUBLE, + + /* big endian */ + BE_UINT8, + BE_UINT16, + BE_UINT32, + BE_UINT64, + + BE_INT8, + BE_INT16, + BE_INT32, + BE_INT64, + + BE_FLOAT, + BE_DOUBLE, + + /* native endianess */ + UINT8, + UINT16, + UINT32, + UINT64, + + INT8, + INT16, + INT32, + INT64, + + FLOAT, + DOUBLE, + + /* FIXME does endianess matter for bool? */ + + BOOL, + +} fddi_pv_type_enum_t; + +typedef struct fddi_id fddi_id_t; +typedef struct fddi_param fddi_param_t; +typedef struct fddi_device fddi_device_t; +typedef struct fddi_iface_attr fddi_iface_attr_t; +typedef struct fddi_pv fddi_pv_t; +typedef struct fddi_pv_attr fddi_pv_attr_t; +typedef struct fddi_pv_engine fddi_pv_engine_t; +typedef struct fddi_pv_group fddi_pv_group_t; +typedef struct fddi_pv_group_attr fddi_pv_group_attr_t; +typedef struct fddi_tpu fddi_tpu_t; +typedef struct fddi_iface_backend_ops fddi_iface_backend_ops_t; +typedef struct fddi_iface fddi_iface_t; + +#endif + Added: branches/fddi-mapping/src/GNUmakefile.am ============================================================================== --- (empty file) +++ branches/fddi-mapping/src/GNUmakefile.am Tue Oct 2 16:30:06 2007 @@ -0,0 +1,65 @@ +BACKEND_LIBS = +if BACKEND_LIBMODBUS +BACKEND_LIBS += libfddi_libmodbus.la +endif +if BACKEND_CAN +BACKEND_LIBS += libfddi_can.la +endif + +lib_LTLIBRARIES = \ + libfddi.la \ + $(BACKEND_LIBS) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ + $(INCLTDL) + +# +# libfddi +# + +libfddi_la_SOURCES = \ + libfddi.c \ + fddi_pv_group.c \ + fddi_pv_engine.c \ + fddi_pv_group_attr.c \ + fddi_pv.c + +libfddi_la_LDFLAGS = \ + -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ + -no-undefined \ + -export-dynamic + +libfddi_la_LIBADD = \ + $(LIBLTDL) + +# +# libfddi_modbusmaster +# + +libfddi_libmodbus_la_SOURCES = \ + libfddi_libmodbus.c + +libfddi_libmodbus_la_CPPFLAGS = \ + $(libmodbus_CFLAGS) + +libfddi_libmodbus_la_LIBADD = \ + $(top_builddir)/src/libfddi.la \ + $(libmodbus_LIBS) + +# +# libfddi_can +# + +libfddi_can_la_SOURCES = \ + libfddi_can.c + +libfddi_can_la_CPPFLAGS = \ + -DPF_CAN=29 -DAF_CAN=PF_CAN + +# libfddi_can_la_LIBADD = + +MAINTAINERCLEANFILES = \ + GNUmakefile.in + Added: branches/fddi-mapping/src/fddi_pv.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/src/fddi_pv.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#include + +#include + +int fddi_pv_uint32_init(fddi_pv_t *pv, fddi_pv_attr_t *attr) +{ + return 0; +} + +int fddi_pv_uint32_destroy(fddi_pv_t *pv) +{ + return 0; +} + +uint32_t fddi_pv_uint32_get(fddi_pv_t *pv) +{ + return 0; +} + +void fddi_pv_uint32_set(fddi_pv_t *pv, uint32_t val) +{ + return; +} + +int fddi_pv_getnext(fddi_pv_t **pv) +{ + if (!pv) + return EINVAL; + + *pv = (*pv)->next; + return 0; +} + +int fddi_pv_getid(fddi_pv_t *pv, fddi_id_t *id) +{ + if ((!pv) || (!id)) + return EINVAL; + + memcpy(id, &pv->id, sizeof(fddi_id_t)); + + return 0; +} + +int fddi_pv_getname(fddi_pv_t *pv, char **name) +{ + return 0; +} Added: branches/fddi-mapping/src/fddi_pv_engine.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/src/fddi_pv_engine.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#include + +int fddi_pv_engine_init(fddi_pv_engine_t *pv_engine) +{ + return 0; +} + +int fddi_pv_engine_destroy(fddi_pv_engine_t *pv_engine) +{ + return 0; +} + +int fddi_pv_engine_configure_from_cmdline(fddi_pv_engine_t *pv_engine, int argc, char *argv[]) +{ + return 0; +} + + Added: branches/fddi-mapping/src/fddi_pv_group.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/src/fddi_pv_group.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#include + +int fddi_pv_group_init(fddi_pv_group_t *pv_group, fddi_pv_group_attr_t *attr) +{ + return 0; +} + +int fddi_pv_group_destroy(fddi_pv_group_t *pv_group) +{ + return 0; +} + +int fddi_pv_group_wait_and_lock(fddi_pv_group_t *pv_group) +{ + return 0; +} + +int fddi_pv_group_unlock(fddi_pv_group_t *pv_group) +{ + return 0; +} + Added: branches/fddi-mapping/src/fddi_pv_group_attr.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/src/fddi_pv_group_attr.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#include + +int fddi_pv_group_attr_init(fddi_pv_group_attr_t *pv_group_attr, fddi_pv_engine_t *pv_engine) +{ + return 0; +} + +int fddi_pv_group_attr_destroy(fddi_pv_group_attr_t *pv_group_attr) +{ + return 0; +} + +int fddi_pv_group_attr_setname(fddi_pv_group_attr_t *pv_group_attr, const char *name) +{ + return 0; +} + + Added: branches/fddi-mapping/src/libfddi.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/src/libfddi.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,564 @@ +/* + * Copyright (C) 2007 Robert Schwebel + * + * This file is part of the OSADL Fieldbus Framework. + * + * The OSADL Fieldbus Framework is free software; you can redistribute it + * and/or modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. Note that there + * is a special link exception; see COPYING for details. + * + * The OSADL Fieldbus Framework is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the OSADL Fieldbus Framework; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +static pthread_mutex_t lt_dl_mutex = PTHREAD_MUTEX_INITIALIZER; +const char fddi_version_str[] = VERSION; + +/* fddi_iface_attr_t */ +int fddi_iface_attr_init(fddi_iface_attr_t *attr) +{ + if (!attr) + return EINVAL; + + memset(attr, 0, sizeof(fddi_iface_attr_t)); + + return 0; +} + +int fddi_iface_attr_setclass(fddi_iface_attr_t *attr, char *class) +{ + if ((!attr) || (!class)) + return EINVAL; + + attr->fddi_class_name = strdup(class); + /* FIXME: where to free() this memory? */ + + return 0; +} + +int fddi_iface_attr_setid(fddi_iface_attr_t *attr, const char *path, fddi_id_t id) +{ + if (!attr) + return EINVAL; + + if (path) + attr->path = strdup(path); + + memcpy(&attr->id, &id, sizeof(fddi_id_t)); + + return EINVAL; +} + +/* fddi_iface_t */ +int fddi_iface_init(fddi_iface_t *iface, fddi_iface_attr_t *attr) +{ + const char *error_string; + int ret = 0; + + if ((!iface) || (!attr)) + return EINVAL; + + if (attr->fddi_class_name == NULL) + return EINVAL; + + /* initialize instance variables */ + memset(iface, 0, sizeof(fddi_iface_t)); + memcpy(&iface->id, &attr->id, sizeof(fddi_id_t)); + + /* attach to backend library */ + + pthread_mutex_lock(<_dl_mutex); + + if (lt_dlinit()) { + pthread_mutex_unlock(<_dl_mutex); + return ELIBACC; + } + + iface->backend_lib = lt_dlopenext(attr->fddi_class_name); + if ((iface->backend_lib) == NULL) { + pthread_mutex_unlock(<_dl_mutex); + return ELIBACC; + } + + lt_dlerror(); + + /* register backend functions */ + iface->backend.init = lt_dlsym(iface->backend_lib, "fddi_backend_init"); + if ((error_string = lt_dlerror())) { + pthread_mutex_unlock(<_dl_mutex); + goto iface_init_err; + } + + iface->backend.destroy = lt_dlsym(iface->backend_lib, "fddi_backend_destroy"); + if ((error_string = lt_dlerror())) { + pthread_mutex_unlock(<_dl_mutex); + goto iface_init_err; + } + + iface->backend.configure = lt_dlsym(iface->backend_lib, "fddi_backend_configure"); + if ((error_string = lt_dlerror())) { + pthread_mutex_unlock(<_dl_mutex); + goto iface_init_err; + } + + iface->backend.setstate = lt_dlsym(iface->backend_lib, "fddi_backend_setstate"); + if ((error_string = lt_dlerror())) { + pthread_mutex_unlock(<_dl_mutex); + goto iface_init_err; + } + + iface->backend.cmd = lt_dlsym(iface->backend_lib, "fddi_backend_cmd"); + if ((error_string = lt_dlerror())) { + pthread_mutex_unlock(<_dl_mutex); + goto iface_init_err; + } + + pthread_mutex_unlock(<_dl_mutex); + + ret = iface->backend.init(iface); + if (ret) + fprintf(stderr, "error: backend init returned %i\n", ret); + + return ret; + +iface_init_err: + + fprintf(stderr, "%s\n", error_string); + pthread_mutex_lock(<_dl_mutex); + lt_dlclose(iface->backend_lib); + pthread_mutex_unlock(<_dl_mutex); + return EINVAL; /* FIXME better retval? */ +} + +int fddi_iface_destroy(fddi_iface_t *iface) +{ + int ret = 0; + + if (!iface) + return EINVAL; + + ret = iface->backend.destroy(iface); + if (ret) + fprintf(stderr, "error: backend init returned %i\n", ret); + + pthread_mutex_lock(<_dl_mutex); + lt_dlclose(iface->backend_lib); + pthread_mutex_unlock(<_dl_mutex); + + return ret; +} + +int fddi_iface_configure(fddi_iface_t *iface, const char *configfile, void *data) +{ + if ((!iface) || (!configfile)) + return EINVAL; + + if (!iface->backend.configure) + return ENOSYS; + + return iface->backend.configure(iface, configfile, data); +} + +int fddi_iface_setstate(fddi_iface_t *iface, fddi_state_enum_t state) +{ + if (!iface) + return EINVAL; + + if (!iface->backend.setstate) + return ENOSYS; + + return iface->backend.setstate(iface, state); +} + +int fddi_iface_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd) +{ + if (!iface) + return EINVAL; + + if (!iface->backend.cmd) + return ENOSYS; + + return iface->backend.cmd(iface, cmd); +} + +int fddi_iface_getid(fddi_iface_t *iface, fddi_id_t *id) +{ + if ((!iface) || (!id)) + return EINVAL; + + memcpy(id, &iface->id, sizeof(fddi_id_t)); + + return 0; +} + +int fddi_iface_setid(fddi_iface_t *iface, fddi_id_t id) +{ + if (!iface) + return EINVAL; + + memcpy(&iface->id, &id, sizeof(fddi_id_t)); + + return 0; +} + +int fddi_iface_getnodev(fddi_iface_t *iface) +{ + if (!iface) + return EINVAL; + + return -1; /* FIXME: not implemented yet */ +} + +int fddi_iface_getnotpus(fddi_iface_t *iface) +{ + if (!iface) + return EINVAL; + + return -1; /* FIXME: not implemented yet */ +} + +int fddi_iface_getnopvs(fddi_iface_t *iface) +{ + if (!iface) + return EINVAL; + + return -1; /* FIXME: not implemented yet */ +} + +int fddi_iface_getdevlist(fddi_iface_t *iface, fddi_device_t **dev) +{ + if ((!iface) || (!dev)) + return EINVAL; + + *dev = iface->devlist_head; + return 0; +} + +int fddi_iface_gettpulist(fddi_iface_t *iface, fddi_tpu_t **tpu) +{ + if ((!iface) || (!tpu)) + return EINVAL; + + *tpu = iface->tpulist_head; + return 0; +} + +int fddi_iface_getversionstr(fddi_iface_t *iface, const char **version) +{ + if (!iface) + return EINVAL; + + *version = fddi_version_str; + + return 0; +} + +int fddi_iface_getversion(fddi_iface_t *iface, int *version) +{ + /* FIXME: use the kernel mechanics to get a numerical version here */ + return 0; +} + + +/* fddi_device_t */ +int fddi_dev_getnext(fddi_device_t **dev) +{ + if (!dev) + return ENODEV; + + *dev = (*dev)->next; + return 0; +} + +int fddi_dev_getid(fddi_device_t *dev, fddi_id_t *id) +{ + if ((!dev) || (!id)) + return EINVAL; + + memcpy(id, &dev->id, sizeof(fddi_id_t)); + + return 0; +} + +int fddi_dev_getstate(fddi_device_t *dev, fddi_state_enum_t *state) +{ + if ((!dev) || (!state)) + return EINVAL; + + *state = dev->state; + return 0; +} + +int fddi_dev_getstatestr(fddi_device_t *dev, char **state) +{ + if ((!dev) || (!state)) + return EINVAL; + + *state = NULL; + return 0; +} + +int fddi_dev_getphysid(fddi_device_t *dev, int *id) +{ + if (!dev) + return EINVAL; + + return -1; /* FIXME: not implemented yet */ +} + +int fddi_dev_getlogicalid(fddi_device_t *dev, int *id) +{ + if (!dev) + return EINVAL; + + return -1; /* FIXME: not implemented yet */ +} + +int fddi_dev_getparamlist(fddi_device_t *dev, fddi_param_t **param) +{ + if ((!dev) || (!param)) + return EINVAL; + + *param = dev->param_list; + return 0; +} + +int fddi_dev_getnotpus(fddi_device_t *dev) +{ + if (!dev) + return EINVAL; + + return -1; /* FIXME: not implemented yet */ +} + +int fddi_dev_read_async(fddi_device_t *dev /* FIXME */) +{ + if (!dev) + return EINVAL; + + return -1; /* FIXME: not implemented yet */ +} + +int fddi_dev_write_async(fddi_device_t *dev /* FIXME */) +{ + if (!dev) + return EINVAL; + + return -1; /* FIXME: not implemented yet */ +} + + +/* fddi_param_t */ +int fddi_param_getnext(fddi_param_t **param) +{ + if (!param) + return EINVAL; + + *param = (*param)->next; + return 0; +} + +int fddi_param_getkey(fddi_param_t *param, char **key) +{ + if ((!param) || (!key)) + return EINVAL; + + *key = param->key; + return 0; +} + +int fddi_param_getval(fddi_param_t *param, char **val) +{ + if ((!param) || (!val)) + return EINVAL; + + *val = param->val; + return 0; +} + +int fddi_param_getflags(fddi_param_t *param, unsigned long *flags) /* FIXME */ +{ + if ((!param) || (!flags)) + return ENODEV; + + *flags = param->flags; + return 0; +} + +int fddi_param_getnotpus(fddi_param_t *param, int *notpus) +{ + if ((!param) || (!notpus)) + return EINVAL; + + return -1; /* FIXME: not implemented yet */ +} + + +/* fddi_tpu_t */ +int fddi_tpu_getnext(fddi_tpu_t **tpu) +{ + if (!tpu) + return EINVAL; + + *tpu = (*tpu)->next; + return 0; +} + +int fddi_tpu_getid(fddi_tpu_t *tpu, fddi_id_t *id) +{ + if ((!tpu) || (!id)) + return EINVAL; + + memcpy(id, &tpu->id, sizeof(fddi_id_t)); + + return 0; +} + +int fddi_tpu_gettimestamp(fddi_tpu_t *tpu, int *timestamp) /* FIXME tv */ +{ + if ((!tpu) || (!timestamp)) + return EINVAL; + + *timestamp = 0; /* FIMXE */ + return 0; +} + +int fddi_tpu_setcallback(fddi_tpu_t *tpu, int(*tpu_callback)(fddi_tpu_t *tpu, void *arg), void *arg) +{ + if ((!tpu) || (!tpu_callback)) + return EINVAL; + + tpu->callback = tpu_callback; + tpu->callback_arg = arg; + + return 0; +} + +int fddi_tpu_getpvlist(fddi_tpu_t *tpu, fddi_pv_t **pv) +{ + if ((!tpu) || (!pv)) + return EINVAL; + + *pv = tpu->pv_list_head; + return 0; +} + +int fddi_tpu_getpayload(fddi_tpu_t *tpu, char **payload) +{ + if ((!tpu) || (!payload)) + return EINVAL; + + *payload = tpu->payload; + return 0; +} + +int fddi_tpu_transfer(fddi_tpu_t *tpu) +{ + if ((tpu->direction == IN) || (tpu->direction == INOUT)) { + + + } + + if ((tpu->direction == OUT) || (tpu->direction == INOUT)) { + + + } + + return 0; +} + + +/* fddi_id_t */ + +int fddi_id_init(fddi_id_t *fddi_id, const char *prefix, int index, const char *suffix) +{ + int prefix_len; + int index_len; + int suffix_len; + char index_as_string[30]; /* FIXME: find out max strlen of printf(int) */ + + memset(fddi_id, 0, sizeof(fddi_id_t)); + + /* FIXME: is it allowed to have things without index? */ + snprintf(index_as_string, 30, "%i", index); + index_len = strlen(index_as_string); + + if (prefix) { + prefix_len = strlen(prefix); + fddi_id->prefix = strdup(prefix); + if (!fddi_id->prefix) + goto prefix_err; + } else + prefix_len = 0; + + if (suffix) { + suffix_len = strlen(suffix); + fddi_id->suffix = strdup(suffix); + if (!fddi_id->suffix) + goto suffix_err; + } else + suffix_len = 0; + + + fddi_id->id_as_str_len = prefix_len + index_len + suffix_len; + + fddi_id->id_as_string = malloc(fddi_id->id_as_str_len + 1); + if (!fddi_id->id_as_string) + goto id_as_str_err; + + sprintf(fddi_id->id_as_string, "%s%s%s", + fddi_id->prefix ? fddi_id->prefix : "", + index_as_string ? index_as_string : "", + fddi_id->suffix ? fddi_id->suffix: ""); + + return 0; + +id_as_str_err: + fddi_id->id_as_str_len = 0; + free(fddi_id->suffix); + fddi_id->suffix = NULL; +suffix_err: + free(fddi_id->prefix); + fddi_id->prefix = NULL; +prefix_err: + return ENOMEM; +} + +int fddi_id_getid(fddi_id_t *fddi_id, char *id_string, size_t len) +{ + if (len < fddi_id->id_as_str_len) + return EINVAL; /* FIXME */ + + strcpy(id_string, fddi_id->id_as_string); + + return 0; +} + +int fddi_id_destroy(fddi_id_t *fddi_id) +{ + free(fddi_id->prefix); + free(fddi_id->suffix); + free(fddi_id->id_as_string); + + return 0; +} + Added: branches/fddi-mapping/src/libfddi_can.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/src/libfddi_can.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,461 @@ +/* + * fddi backend for arbitrary CAN messages + */ + +/* FIXME: this file is an uggly hack which hardcodes everything, as long + * as we have a proper xml parser + */ + +#if 0 +#include +#include +#include +#include +#endif + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include + +static fddi_tpu_t tpu1 = { + .id = { + .prefix = "cantpu", + .index = 0, + .suffix = "", + }, + .direction = IN, + .cycletime = 0, +}; + +static fddi_tpu_t tpu2 = { + .id = { + .prefix = "cantpu", + .index = 1, + .suffix = "", + }, + .direction = IN, + .cycletime = 0, +}; + +/* ----- */ + +static fddi_pv_t pv_v_can = { + .id = { + .prefix = "v_can", + .index = -1, + .suffix = "", + }, + .param_list_head = NULL, + .name = NULL, + .type = BE_UINT16, + .offset = 0, + .bit = 0, +}; + +static fddi_pv_t pv_n_can = { + .id = { + .prefix = "n_can", + .index = -1, + .suffix = "", + }, + .param_list_head = NULL, + .name = NULL, + .type = BE_UINT16, + .offset = 2, + .bit = 0, +}; + +static fddi_pv_t pv_u_can = { + .id = { + .prefix = "u_can", + .index = -1, + .suffix = "", + }, + .param_list_head = NULL, + .name = NULL, + .type = BE_UINT16, + .offset = 4, + .bit = 0, +}; + +static fddi_pv_t pv_i_can = { + .id = { + .prefix = "i_can", + .index = -1, + .suffix = "", + }, + .param_list_head = NULL, + .name = NULL, + .type = BE_UINT16, + .offset = 6, + .bit = 0, +}; + +static fddi_pv_t pv_arate_can = { + .id = { + .prefix = "arate_can", + .index = -1, + .suffix = "", + }, + .param_list_head = NULL, + .name = NULL, + .type = BE_UINT16, + .offset = 0, + .bit = 0, +}; + +static fddi_pv_t pv_srate_can = { + .id = { + .prefix = "srate_can", + .index = -1, + .suffix = "", + }, + .param_list_head = NULL, + .name = NULL, + .type = BE_UINT16, + .offset = 2, + .bit = 0, +}; + +#if 0 +struct modbus_tpu { + timer_t timer; + struct sigevent event; + struct itimerspec timer_spec; + modbus_dev_t *modbus_dev; +}; +struct modbus_tpu modbus_tpu1; +#endif + +struct can_tpu { + pthread_t can_thread_id; + int endme; +} can_tpu; + +typedef struct can_iface { + struct sockaddr_can addr; + struct can_frame frame; + struct ifreq ifr; + int socket; +} can_iface_t; + +can_iface_t can_iface1; + + +struct priv { + pv_engine_t pv_engine; + + float *pv_v_tractor; + float *pv_n_diesel; + float *pv_u_dc; + float *pv_i_dc; + float *pv_agitation_rate; + float *pv_spray_rate; +}; + +struct priv priv; + +#define MAXDEV 6 + +void* _can_thread(void *arg) +{ + fd_set rdfs; + int fd = can_iface1.socket; + ssize_t bytes; + int retval; + struct can_frame frame; + struct timeval to; + + FD_ZERO(&rdfs); + + while (!(can_tpu.endme)) { + to.tv_sec = 1; + to.tv_usec = 0; + FD_SET(fd, &rdfs); + + retval = select(fd + 1, &rdfs, NULL, NULL, &to); + + /* timeout */ + if (retval == 0) + continue; + + if (retval == -1) { + retval = -errno; + if (retval == -EINTR) + continue; + + perror("select"); + can_tpu.endme = 1; + continue; + } + + bytes = recv(fd, &frame, sizeof(struct can_frame), 0); + if (bytes < (ssize_t)sizeof(struct can_frame)) { + fprintf(stderr, "error: received short frame"); + exit(-1); + } + + switch (frame.can_id) { + case (0x18E0F108 & CAN_EFF_MASK) | CAN_EFF_FLAG: { + int v_tractor_can = + frame.data[0] << 8 | + frame.data[1] << 0; + int n_diesel_can = + frame.data[2] << 8 | + frame.data[3] << 0; + int u_dc_can = + frame.data[4] << 8 | + frame.data[5] << 0; + int i_dc_can = + frame.data[6] << 8 | + frame.data[7] << 0; + + pv_lock(&priv.pv_engine); + *(priv.pv_v_tractor) = v_tractor_can; + *(priv.pv_n_diesel) = n_diesel_can; + *(priv.pv_u_dc) = u_dc_can; + *(priv.pv_i_dc) = i_dc_can; + pv_unlock(&priv.pv_engine); + break; + } + case (0x18E0F208 & CAN_EFF_MASK) | CAN_EFF_FLAG: { + int agitation_rate_can = + frame.data[0] << 8 | + frame.data[1] << 0; + int spray_rate_can = + frame.data[2] << 8 | + frame.data[3] << 0; + + pv_lock(&priv.pv_engine); + *(priv.pv_agitation_rate) = agitation_rate_can; + *(priv.pv_spray_rate) = spray_rate_can; + pv_unlock(&priv.pv_engine); + break; + } + default: + fprintf(stderr, "Unknown can_id 0x%08x\n", frame.can_id & CAN_EFF_MASK); + } + + + } + + return NULL; +} + + +#if 0 +void _modbus_tpu_out(fddi_tpu_t *tpu) +{ + struct modbus_tpu *modbus_tpu = (struct modbus_tpu*)(tpu->priv); + + /* application callback */ + if (tpu->callback) + tpu->callback(tpu, NULL); + + /* bus transfer */ + modbus_w_single_coil(modbus_tpu->modbus_dev, 1, coil); + coil = coil == 0 ? 1:0; +} + +void _modbus_tpu_in(fddi_tpu_t *tpu) +{ + /* bus transfer */ + + /* application callback */ + if (tpu->callback) + tpu->callback(tpu, NULL); +} + + +void modbus_timer_handler(sigval_t sigval) +{ + fddi_tpu_t *tpu = (fddi_tpu_t*)sigval.sival_ptr; + + if ((tpu->direction == OUT) || (tpu->direction == INOUT)) + _modbus_tpu_out(tpu); + + if ((tpu->direction == IN) || (tpu->direction == INOUT)) + _modbus_tpu_in(tpu); + + return; +} +#endif + +/* + * fddi backend functions + */ + +int fddi_backend_init(fddi_iface_t *iface); +int fddi_backend_destroy(fddi_iface_t *iface); +int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data); +int fddi_backend_setstate(fddi_iface_t *iface, fddi_state_enum_t state); +int fddi_backend_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd); + +int fddi_backend_init(fddi_iface_t *iface) +{ + return 0; +} + +int fddi_backend_destroy(fddi_iface_t *iface) +{ + can_iface_t *can_iface = (can_iface_t*)(iface->priv); + + pv_destroy(&priv.pv_engine); + + close(can_iface->socket); + + return 0; +} + +int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data) +{ + printf("parsing configfile: %s\n", configfile); +// printf("for interface: %s\n", iface->id.id_as_string); /* FIXME private */ + + /* + * create socket for specified CAN interface + */ + if ((can_iface1.socket = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) { + perror("opening can socket"); + return -ESOCKTNOSUPPORT; + } + + can_iface1.addr.can_family = AF_CAN; + + strcpy(can_iface1.ifr.ifr_name, "can0"); + if (ioctl(can_iface1.socket, SIOCGIFINDEX, &can_iface1.ifr) < 0) { + perror("attaching to can interface"); + return 1; + } + can_iface1.addr.can_ifindex = can_iface1.ifr.ifr_ifindex; + + if (bind(can_iface1.socket, (struct sockaddr *)&can_iface1.addr, sizeof(can_iface1.addr)) < 0) { + perror("binding to can socket"); + return 1; + } + + iface->priv = &can_iface1; + /* FIXME: everything's hardcoded & static for now, we add an xml parser later */ + + iface->tpulist_head = &tpu1; + tpu1.pv_list_head = &pv_v_can; + tpu1.next = &tpu2; + + pv_v_can.next = &pv_n_can; + pv_n_can.previous = &pv_v_can; + pv_n_can.next = &pv_u_can; + pv_u_can.previous = &pv_n_can; + pv_u_can.next = &pv_i_can; + pv_i_can.previous = &pv_u_can; + + tpu2.pv_list_head = &pv_arate_can; + tpu2.previous = &tpu1; + + pv_arate_can.next = &pv_srate_can; + pv_srate_can.previous = &pv_arate_can; + + { + pv_engine_attr_t attr; + int err; + + err = pv_engine_attr_init_from_env(&attr); + if (err) + return err; + + err = pv_init(&priv.pv_engine, &attr); + if (err) { + printf("couldn't init pv engine\n"); + return err; + } + priv.pv_v_tractor = pv_register_float(&priv.pv_engine, "v_tractor"); + priv.pv_n_diesel = pv_register_float(&priv.pv_engine, "n_diesel"); + priv.pv_u_dc = pv_register_float(&priv.pv_engine, "u_dc"); + priv.pv_i_dc = pv_register_float(&priv.pv_engine, "i_dc"); + priv.pv_agitation_rate = pv_register_float(&priv.pv_engine, "agitation_rate"); + priv.pv_spray_rate = pv_register_float(&priv.pv_engine, "spray_rate"); + + if ((priv.pv_v_tractor == NULL) || (priv.pv_n_diesel == NULL) || (priv.pv_u_dc == NULL) || + (priv.pv_i_dc == NULL) || (priv.pv_agitation_rate == NULL) || (priv.pv_spray_rate == NULL)) { + fprintf(stderr, "could not register variables\n"); + pv_destroy(&priv.pv_engine); + return -EINVAL; + } + } + + + /* we are ready now and go into preoperational state */ + fddi_backend_setstate(iface, STATE_PREOPERATIONAL); + + return 0; +} + +int fddi_backend_setstate(fddi_iface_t *iface, fddi_state_enum_t state) +{ + int retval = -1; + + switch(state) { + case STATE_UNCONFIGURED: + case STATE_MISSING: + case STATE_CONFIG_ERROR: + case STATE_PREOPERATIONAL: + case STATE_OPERATIONAL: + case STATE_OPERATION_ERROR: + iface->state = state; + retval = 0; + break; + default: + break; + } + + return retval; +} + +int fddi_backend_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd) +{ + int retval = -1; + + switch (cmd) { + + case CMD_START: + + /* FIXME: check if we have already a thread running */ + retval = pthread_create(&can_tpu.can_thread_id, NULL, _can_thread, NULL); + if (retval != 0) + perror("creating can_thread"); + break; + + case CMD_STOP: + + can_tpu.endme = 1; + printf("waiting for can_thread to finish..."); + pthread_join(can_tpu.can_thread_id, NULL); + printf("done\n"); + + retval = 0; + break; + + case CMD_RESET: + case CMD_IDENTIFY: + case CMD_QUITERR: + retval = 0; + break; + default: + break; + + } + + return retval; +} + Added: branches/fddi-mapping/src/libfddi_hess.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/src/libfddi_hess.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,289 @@ +#include +#include +#include +#include + +#include + +#define MAX_IO_INTERFACES 16 +#define MAX_IO_INTERFACE_INSTS 64 + +/* managment of io-interfaces */ +static int num_of_interfaces = 0; +static IO_INTERFACE io_interfaces[MAX_IO_INTERFACES]; + + +static int num_of_interface_instances = 0; +static IO_INTERFACE_INST io_interface_instances[MAX_IO_INTERFACE_INSTS]; + +int register_io_interface(IO_INTERFACE ioitf) +{ + if (num_of_interfaces >= MAX_IO_INTERFACES) + return RESERR_OUT_OF_MEM; + io_interfaces[num_of_interfaces++] = ioitf; + return RESOK; +} + +int bind_io_interface(IO_INTERFACE ioitf, char* name, LL_INTERFACE llitf, IO_INTERFACE_INST* res) +{ + int ret; + if (num_of_interface_instances >= MAX_IO_INTERFACE_INSTS) + return RESERR_OUT_OF_MEM; + /* call to function pointer from registered io-interface */ + ret = (*ioitf->_fptr_bind_io_interface)(name, llitf, res); + if (ret == RESOK) + io_interface_instances[num_of_interface_instances++] = *res; + return ret; +} + +int enum_io_interfaces(IO_INTERFACE** ioitfs) +{ + *ioitfs = io_interfaces; + return num_of_interfaces; +} + +int enum_io_interface_instances(IO_INTERFACE_INST** ioitfinsts) +{ + *ioitfinsts = io_interface_instances; + return num_of_interface_instances; +} + +IO_INTERFACE get_io_interface(char* name) +{ + int i; + for (i = 0; i < num_of_interfaces; i++) + if (strcmp(name, io_interfaces[i]->name) == 0) + return io_interfaces[i]; + return NULL; +} + +IO_INTERFACE_INST get_io_interface_inst(char* name) +{ + int i; + for (i = 0; i < num_of_interface_instances; i++) + if (strcmp(name, io_interface_instances[i]->name) == 0) + return io_interface_instances[i]; + return NULL; +} + +int enum_io_transport_units(IO_INTERFACE_INST ioitfinst, IO_TRANSPORT_UNIT** iotpus) +{ + *iotpus = ioitfinst->tpus; + return ioitfinst->num_tpus; +} + +int enum_io_devices(IO_INTERFACE_INST ioitfinst, IO_DEVICE** iodevices) +{ + *iodevices = ioitfinst->devlist; + return ioitfinst->num_dev; +} + +int enum_io_variables(IO_INTERFACE_INST ioitfinst, IO_VARIABLE** iovars) +{ + *iovars = ioitfinst->varlist; + return ioitfinst->num_var; +} + +static int count_devices(IO_DEVICE io_device) +{ + int n_dev; + IO_DEVICE dev_child; + + if (io_device == NULL) + return 0; + + n_dev = 1; // the device itself + dev_child = io_device->first_child; + + while (dev_child != NULL) + { + n_dev += count_devices(dev_child); + dev_child = dev_child->next_child; + } + return n_dev; +} + +static IO_DEVICE* fill_devices(IO_DEVICE dev, IO_DEVICE* devlist) +/* return adress to continue. devlist must be large enough */ +{ + IO_DEVICE* list = devlist; + IO_DEVICE dev_child; + + *list = dev; + list++; + + dev_child = dev->first_child; + + while (dev_child != NULL) + { + list = fill_devices(dev_child, list); + dev_child = dev_child->next_child; + } + return list; +} + +int configure_io_interface_inst(IO_INTERFACE_INST ioitfinst, IO_DEVICE root) +{ + int ret; + /* call to function pointer from registered io-interface */ + ret = (*ioitfinst->ioitf->_fptr_configure_io_interface_inst)(ioitfinst, root); + if (ret == RESOK) + { + int i; + IO_VARIABLE* list; + + /* the configure method fills the tpu-list */ + /* the other lists are filled by the fddi interface in this function */ + + /* fill device list */ + ioitfinst->num_dev = count_devices(root); + ioitfinst->devlist = malloc(ioitfinst->num_dev * sizeof(IO_DEVICE)); + fill_devices(root, ioitfinst->devlist); + + /* fill variable list */ + ioitfinst->num_var = 0; + for (i = 0; i < ioitfinst->num_tpus; i++) + ioitfinst->num_var += ioitfinst->tpus[i]->num_var; + + ioitfinst->varlist = malloc(ioitfinst->num_var * sizeof(IO_VARIABLE)); + list = ioitfinst->varlist; + for (i = 0; i < ioitfinst->num_tpus; i++) + { + memcpy(list, ioitfinst->tpus[i]->varlist, ioitfinst->tpus[i]->num_var * sizeof(IO_VARIABLE)); + list += ioitfinst->tpus[i]->num_var; + } + } + return ret; +} + +int scan_io_interface_inst(IO_INTERFACE_INST ioitfinst, IO_DEVICE *root) +{ + int ret; + /* call to function pointer from registered io-interface */ + ret = (*ioitfinst->ioitf->_fptr_scan_io_interface_inst)(ioitfinst, root); + return ret; +} + +int read_iodevice_async(IO_DEVICE iodev, unsigned long address, unsigned char* buf, unsigned long buf_size, unsigned long* read_size) +{ + int ret; + /* call to function pointer from registered io-interface */ + ret = (*iodev->itfinst->ioitf->_fptr_read_device_async)(iodev, address, buf, buf_size, read_size); + return ret; +} + +int write_iodevice_async(IO_DEVICE iodev, unsigned long address, unsigned char* buf, unsigned long size) +{ + int ret; + /* call to function pointer from registered io-interface */ + ret = (*iodev->itfinst->ioitf->_fptr_write_device_async)(iodev, address, buf, size); + return ret; +} + +int cmd_iodevice(IO_DEVICE iodev, IO_DEVICE_COMMAND cmd) +{ + int ret; + /* call to function pointer from registered io-interface */ + ret = (*iodev->itfinst->ioitf->_fptr_cmd_device)(iodev, cmd); + return ret; +} + +int enum_io_variables_of_iodevice(IO_DEVICE iodev, IO_VARIABLE** iovars) +{ + // todo + return 0; +} + +/* A very simple implementation of transport units with a lot of improvement possibilities */ +/* While anyone is reading the buffer all write operations are done in a extra buffer to keep the read buffer consistent */ + +unsigned char* address_to_read(IO_TRANSPORT_UNIT iotpu) +{ + iotpu->read_count++; + return iotpu->buf_read; +} + +unsigned char* address_to_write(IO_TRANSPORT_UNIT iotpu) +{ + if (iotpu->write_count != 0) + return NULL; + + iotpu->write_count++; + if (iotpu->buf_read == iotpu->buf_write) + { + iotpu->buf_write = malloc(iotpu->size); + memcpy(iotpu->buf_write, iotpu->buf_read, iotpu->size); + } + return iotpu->buf_write; +} + +unsigned char* address_to_replace(IO_TRANSPORT_UNIT iotpu) +{ + if (iotpu->write_count != 0) + return NULL; + + iotpu->write_count++; + if (iotpu->buf_read == iotpu->buf_write) + iotpu->buf_write = malloc(iotpu->size); + return iotpu->buf_write; +} + +int release_adress(IO_TRANSPORT_UNIT iotpu, unsigned char* address) +{ + if (address == iotpu->buf_read) + { + iotpu->read_count--; + /* assert iotpu->read_count >= 0 */ + if (iotpu->read_count == 0 && iotpu->write_count == 0 && iotpu->buf_read != iotpu->buf_write) + { + free(iotpu->buf_read); + iotpu->buf_read = iotpu->buf_write; + } + return RESOK; + } + else if (address == iotpu->buf_write) + { + int i; + iotpu->write_count--; + /* assert iotpu->write_count >= 0 */ + if (iotpu->read_count == 0 && iotpu->write_count == 0 && iotpu->buf_read != iotpu->buf_write) + { + free(iotpu->buf_read); + iotpu->buf_read = iotpu->buf_write; + } + + /* trigger callbacks */ + for (i = 0; i < iotpu->num_callbacks; i++) + (*iotpu->callback[i])(iotpu); + + return RESOK; + } + return RESERR_UNKOWNADDRESS; +} + +int send_iotransport_unit(IO_TRANSPORT_UNIT iotpu) +{ + // FIXME int res = 0; + /* pseudo code, because low level interface is not ready */ + /* may be redirected trough stack */ + /* + res = iotpu->itfinst->llitf->Send(iotpu->id, iotpu->buf_write, iotpu->size); + */ + return 0; +} + +int register_callback_to_iotransport_unit(IO_TRANSPORT_UNIT iotpu, void (*callback)(IO_TRANSPORT_UNIT iotpu)) +{ + if (iotpu->num_callbacks >= MAXCALLBACKS) + return RESERR_OUT_OF_MEM; + iotpu->callback[iotpu->num_callbacks] = callback; + iotpu->num_callbacks++; + return RESOK; +} + +int enum_io_variables_of_iotransport_unit(IO_TRANSPORT_UNIT iotpu, IO_VARIABLE** iovars) +{ + *iovars = iotpu->varlist; + return iotpu->num_var; +} + Added: branches/fddi-mapping/src/libfddi_libmodbus.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/src/libfddi_libmodbus.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,271 @@ +/* + * fddi backend for libmodbus + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include + +static fddi_tpu_t tpu1 = { + .id = { + .prefix = "dout", + .index = -1, + .suffix = "", + }, + .direction = OUT, + .cycletime = (10*1000*1000), +}; + +static fddi_pv_t pv1 = { + .id = { + .prefix = "signal_red", + .index = -1, + .suffix = "", + }, + .param_list_head = NULL, + .name = NULL, + .type = BOOL, + .offset = 0, + .bit = 0, +}; + +static fddi_pv_t pv2 = { + .id = { + .prefix = "signal_yellow", + .index = -1, + .suffix = "", + }, + .param_list_head = NULL, + .name = NULL, + .type = BOOL, + .offset = 0, + .bit = 1, +}; + +static fddi_pv_t pv3 = { + .id = { + .prefix = "signal_green", + .index = -1, + .suffix = "", + }, + .param_list_head = NULL, + .name = NULL, + .type = BOOL, + .offset = 0, + .bit = 2, +}; + +struct modbus_tpu { + timer_t timer; + struct sigevent event; + struct itimerspec timer_spec; + modbus_dev_t *modbus_dev; +}; +struct modbus_tpu modbus_tpu1; + +struct modbus_iface { + modbus_dev_t modbus_dev; +}; +struct modbus_iface modbus_iface1; + +int coil; + +void _modbus_tpu_out(fddi_tpu_t *tpu) +{ + struct modbus_tpu *modbus_tpu = (struct modbus_tpu*)(tpu->priv); + + /* application callback */ + if (tpu->callback) + tpu->callback(tpu, NULL); + + /* bus transfer */ + modbus_w_single_coil(modbus_tpu->modbus_dev, 1, coil); + coil = coil == 0 ? 1:0; +} + +void _modbus_tpu_in(fddi_tpu_t *tpu) +{ + /* bus transfer */ + + /* application callback */ + if (tpu->callback) + tpu->callback(tpu, NULL); +} + + +void modbus_timer_handler(sigval_t sigval) +{ + fddi_tpu_t *tpu = (fddi_tpu_t*)sigval.sival_ptr; + + if ((tpu->direction == OUT) || (tpu->direction == INOUT)) + _modbus_tpu_out(tpu); + + if ((tpu->direction == IN) || (tpu->direction == INOUT)) + _modbus_tpu_in(tpu); + + return; +} + +/* + * fddi backend functions + */ + +int fddi_backend_init(fddi_iface_t *iface); +int fddi_backend_destroy(fddi_iface_t *iface); +int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data); +int fddi_backend_setstate(fddi_iface_t *iface, fddi_state_enum_t state); +int fddi_backend_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd); + +int fddi_backend_init(fddi_iface_t *iface) +{ + iface->priv = &modbus_iface1; + return 0; +} + +int fddi_backend_destroy(fddi_iface_t *iface) +{ + modbus_dev_t *modbus_dev = (modbus_dev_t*)(iface->priv); + + if (modbus_unbind (modbus_dev) == -1) + return -1; + + return 0; +} + +int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data) +{ + int ret; + modbus_dev_t *modbus_dev = (modbus_dev_t*)(iface->priv); + + printf("parsing configfile: %s\n", configfile); + printf("for interface: %s\n", iface->id.id_as_string); /* FIXME private */ + + /* FIXME: everything's hardcoded & static for now, we add an xml parser later */ + + iface->tpulist_head = &tpu1; + tpu1.pv_list_head = &pv1; + + pv1.next = &pv2; + pv2.previous = &pv1; + pv2.next = &pv3; + pv3.previous = &pv2; + + /* modbus has no hardware bus cycle, emulate one for each tpu */ + /* FIXME: loop */ + { + modbus_tpu1.event.sigev_notify = SIGEV_THREAD; + modbus_tpu1.event.sigev_notify_function = modbus_timer_handler; + modbus_tpu1.event.sigev_notify_attributes = NULL; + modbus_tpu1.event.sigev_value.sival_ptr = &tpu1; + tpu1.priv = &modbus_tpu1; + + if ((ret = timer_create(CLOCK_REALTIME, &modbus_tpu1.event, &modbus_tpu1.timer)) < 0 ) { + perror("timer create"); + return -1; + } + } + + if (modbus_bind(modbus_dev, "192.168.23.242", 502) == -1) { + fprintf(stderr, "modbus_bind() failed\n"); + return -1; + } + + /* FIXME: modbus_dev must be put into the device, not iface! */ + modbus_tpu1.modbus_dev = modbus_dev; + + /* we are ready now and go into preoperational state */ + + fddi_backend_setstate(iface, STATE_PREOPERATIONAL); + + return 0; +} + +int fddi_backend_setstate(fddi_iface_t *iface, fddi_state_enum_t state) +{ + int retval = -1; + + switch(state) { + case STATE_UNCONFIGURED: + case STATE_MISSING: + case STATE_CONFIG_ERROR: + case STATE_PREOPERATIONAL: + case STATE_OPERATIONAL: + case STATE_OPERATION_ERROR: + iface->state = state; + retval = 0; + break; + default: + break; + } + + return retval; +} + +int fddi_backend_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd) +{ + int retval = -1; + + switch (cmd) { + + case CMD_START: + + printf("start\n"); + /* FIXME loop over all tpus here */ + { + struct modbus_tpu *mtpu = ((struct modbus_tpu*)(iface->tpulist_head->priv)); + + mtpu->timer_spec.it_value.tv_sec = 1; + mtpu->timer_spec.it_value.tv_nsec = 0; + mtpu->timer_spec.it_interval.tv_sec = 0; + mtpu->timer_spec.it_interval.tv_nsec = 500*1000*1000; + + if ((retval = timer_settime(mtpu->timer, 0, &mtpu->timer_spec, NULL)) < 0 ) { + perror("timer settime"); + /* FIXME: disarm timers here */ + return -1; + } + } + + retval = 0; + break; + + case CMD_STOP: + + /* FIXME: loop over all tpus here */ + { + struct modbus_tpu *mtpu = ((struct modbus_tpu*)(iface->tpulist_head->priv)); + + mtpu->timer_spec.it_value.tv_sec = 0; + mtpu->timer_spec.it_value.tv_nsec = 0; + mtpu->timer_spec.it_interval.tv_sec = 0; + mtpu->timer_spec.it_interval.tv_nsec = 0; + + if ((retval = timer_settime(mtpu->timer, 0, &mtpu->timer_spec, NULL)) < 0 ) { + perror("timer settime"); + return -1; + } + } + + retval = 0; + break; + + case CMD_RESET: + case CMD_IDENTIFY: + case CMD_QUITERR: + retval = 0; + break; + default: + break; + + } + + return retval; +} + Added: branches/fddi-mapping/tests/GNUmakefile.am ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/GNUmakefile.am Tue Oct 2 16:30:06 2007 @@ -0,0 +1,222 @@ +BACKEND_EXAMPLEBUS_TESTS = \ + test_fddi_examplebus_attach_backend \ + test_fddi_examplebus_configure \ + test_fddi_examplebus_cmd_start \ + test_fddi_examplebus_cmd_stop \ + test_fddi_examplebus_cmd_quiterr \ + test_fddi_examplebus_cmd_identify \ + test_fddi_examplebus_cmd_reset \ + test_fddi_examplebus_setstate_configerror \ + test_fddi_examplebus_setstate_missing \ + test_fddi_examplebus_setstate_operational \ + test_fddi_examplebus_setstate_operation_error \ + test_fddi_examplebus_setstate_preoperational \ + test_fddi_examplebus_setstate_unconfigured + +# test_fddi_examplebus1 + +if BACKEND_CAN +BACKEND_CAN_TESTS = \ + test_fddi_can1 +endif + +if BACKEND_LIBMODBUS +BACKEND_LIBMODBUS_TESTS = \ + test_fddi_libmodbus1 +endif + +TESTS = \ + test_examplebus1 \ + test_fddi_versionstr \ + usecase_controller \ + $(BACKEND_CAN_TESTS) \ + $(BACKEND_EXAMPLEBUS_TESTS) \ + $(BACKEND_LIBMODBUS_TESTS) + +TESTS_ENVIRONMENT = \ + LD_LIBRARY_PATH=$(top_builddir)/tests/.libs + +noinst_PROGRAMS = \ + test_examplebus1 \ + test_fddi_versionstr \ + usecase_controller \ + $(BACKEND_CAN_TESTS) \ + $(BACKEND_EXAMPLEBUS_TESTS) \ + $(BACKEND_LIBMODBUS_TESTS) + +lib_LTLIBRARIES = \ + libexamplebus.la \ + libfddi_examplebus.la + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ + $(LTDLINCL) + +# +# libraries +# + +libexamplebus_la_SOURCES = \ + libexamplebus.c + +libfddi_examplebus_la_SOURCES = \ + libfddi_examplebus.c + +libfddi_examplebus_la_LDFLAGS = \ + -module + +# +# can backend +# + +test_fddi_can1_SOURCES = \ + test_fddi_can1.c + +test_fddi_can1_LDADD = \ + -lpthread -lrt \ + $(top_builddir)/src/libfddi.la + +test_fddi_can1_DEPENDENCIES = \ + test_fddi_can1.xml + +test_fddi_can1.xml: + cp $(top_srcdir)/busconfig/Pengutronix/can-example.xml test_fddi_can1.xml + + +# +# examplebus backend +# + +test_examplebus1_SOURCES = \ + test_examplebus1.c + +test_examplebus1_LDADD = \ + libexamplebus.la + +#test_fddi_examplebus1_SOURCES = \ +# test_fddi_examplebus1.c +# +#test_fddi_examplebus1_LDADD = \ +# $(top_builddir)/src/libfddi.la + +test_fddi_examplebus_attach_backend_SOURCES = \ + test_fddi_examplebus_attach_backend.c + +test_fddi_examplebus_attach_backend_LDADD = \ + $(top_builddir)/src/libfddi.la + +test_fddi_versionstr_SOURCES = \ + test_fddi_versionstr.c + +test_fddi_versionstr_LDADD = \ + $(top_builddir)/src/libfddi.la + +test_fddi_examplebus_configure_SOURCES = \ + test_fddi_examplebus_configure.c + +test_fddi_examplebus_configure_LDADD = \ + $(top_builddir)/src/libfddi.la + +test_fddi_examplebus_cmd_start_SOURCES = \ + test_fddi_examplebus_cmd_start.c + +test_fddi_examplebus_cmd_start_LDADD = \ + $(top_builddir)/src/libfddi.la + +test_fddi_examplebus_cmd_stop_SOURCES = \ + test_fddi_examplebus_cmd_stop.c + +test_fddi_examplebus_cmd_stop_LDADD = \ + $(top_builddir)/src/libfddi.la + +test_fddi_examplebus_cmd_quiterr_SOURCES = \ + test_fddi_examplebus_cmd_quiterr.c + +test_fddi_examplebus_cmd_quiterr_LDADD = \ + $(top_builddir)/src/libfddi.la + +test_fddi_examplebus_cmd_identify_SOURCES = \ + test_fddi_examplebus_cmd_identify.c + +test_fddi_examplebus_cmd_identify_LDADD = \ + $(top_builddir)/src/libfddi.la + +test_fddi_examplebus_cmd_reset_SOURCES = \ + test_fddi_examplebus_cmd_reset.c + +test_fddi_examplebus_cmd_reset_LDADD = \ + $(top_builddir)/src/libfddi.la + +test_fddi_examplebus_setstate_configerror_SOURCES = \ + test_fddi_examplebus_setstate_configerror.c + +test_fddi_examplebus_setstate_configerror_LDADD = \ + $(top_builddir)/src/libfddi.la + +test_fddi_examplebus_setstate_missing_SOURCES = \ + test_fddi_examplebus_setstate_missing.c + +test_fddi_examplebus_setstate_missing_LDADD = \ + $(top_builddir)/src/libfddi.la + +test_fddi_examplebus_setstate_operational_SOURCES = \ + test_fddi_examplebus_setstate_operational.c + +test_fddi_examplebus_setstate_operational_LDADD = \ + $(top_builddir)/src/libfddi.la + +test_fddi_examplebus_setstate_operation_error_SOURCES = \ + test_fddi_examplebus_setstate_operation_error.c + +test_fddi_examplebus_setstate_operation_error_LDADD = \ + $(top_builddir)/src/libfddi.la + +test_fddi_examplebus_setstate_preoperational_SOURCES = \ + test_fddi_examplebus_setstate_preoperational.c + +test_fddi_examplebus_setstate_preoperational_LDADD = \ + $(top_builddir)/src/libfddi.la + +test_fddi_examplebus_setstate_unconfigured_SOURCES = \ + test_fddi_examplebus_setstate_unconfigured.c + +test_fddi_examplebus_setstate_unconfigured_LDADD = \ + $(top_builddir)/src/libfddi.la + +# +# libmodbus backend +# + +test_fddi_libmodbus1_SOURCES = \ + test_fddi_libmodbus1.c + +test_fddi_libmodbus1_LDADD = \ + -lpthread -lrt \ + $(top_builddir)/src/libfddi_libmodbus.la + +test_fddi_libmodbus1_DEPENDENCIES = \ + test_fddi_libmodbus1.xml + +test_fddi_libmodbus1.xml: + cp $(top_srcdir)/busconfig/Pengutronix/modbus-example.xml test_fddi_libmodbus1.xml + +# +# usecases +# +usecase_controller_SOURCES = \ + usecase_controller.c + +usecase_controller_LDADD = \ + -lpthread -lrt \ + $(top_builddir)/src/libfddi.la + +EXTRA_DIST = \ + examplebus.h + +MAINTAINERCLEANFILES = \ + GNUmakefile.in + +CLEANFILES = \ + test_fddi_libmodbus1.xml + Added: branches/fddi-mapping/tests/example.xml ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/example.xml Tue Oct 2 16:30:06 2007 @@ -0,0 +1,33 @@ + + + + + + + Examplebus Test Setup + + + + IPC Controller Box + + + + + master + + + + + + Analog Input 1 + uint32_t + 0 + + + + + + + + + Added: branches/fddi-mapping/tests/examplebus.h ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/examplebus.h Tue Oct 2 16:30:06 2007 @@ -0,0 +1,38 @@ +#ifndef EXAMPLEBUS_H +#define EXAMPLEBUS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct { + int logfile_fd; +} examplebus_t; + + +typedef struct { + char *logfile; +} examplebus_attr_t; + + +/* API */ + +/* attribute handling */ +extern int examplebus_attr_init(examplebus_attr_t *attr); +extern int examplebus_attr_setlogfile(examplebus_attr_t *attr, char *logfile); + +/* object lifetime */ +extern int examplebus_init(examplebus_t *bus, examplebus_attr_t *attr); +extern int examplebus_destroy(examplebus_t *bus); + +/* some arbitrary bus functions */ +extern int examplebus_r_din(examplebus_t *dev, int index, int *value); +extern int examplebus_w_dout(examplebus_t *dev, int index, int value); +extern int examplebus_r_ain(examplebus_t *dev, int index, int *value); +extern int examplebus_w_aout(examplebus_t *dev, int reg, int value); + +# ifdef __cplusplus +} +# endif +#endif /* EXAMPLEBUS_H */ Added: branches/fddi-mapping/tests/fddi_examplebus.h ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/fddi_examplebus.h Tue Oct 2 16:30:06 2007 @@ -0,0 +1,40 @@ +#ifndef EXAMPLEBUS_H +#define EXAMPLEBUS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct { + int logfile_fd; +} fddi_examplebus_t; + + +typedef struct { + char *logfile; +} fddi_examplebus_attr_t; + + +/* API */ + +/* attribute handling */ +extern int fddi_examplebus_attr_init(fddi_examplebus_attr_t *attr); +extern int fddi_examplebus_attr_setxmlconfig(fddi_examplebus_attr_t *attr, char *configfile); + +/* object lifetime */ +extern int fddi_examplebus_init(fddi_examplebus_t *bus, fddi_examplebus_attr_t *attr); +extern int fddi_examplebus_destroy(fddi_examplebus_t *bus); + +/* some arbitrary bus functions */ +#if 0 +extern int examplebus_r_din(examplebus_t *dev, int index, int *value); +extern int examplebus_w_dout(examplebus_t *dev, int index, int value); +extern int examplebus_r_ain(examplebus_t *dev, int index, int *value); +extern int examplebus_w_aout(examplebus_t *dev, int reg, int value); +#endif + +# ifdef __cplusplus +} +# endif +#endif /* EXAMPLEBUS_H */ Added: branches/fddi-mapping/tests/libexamplebus.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/libexamplebus.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,97 @@ +#include +#include +#include +#include +#include +#include +#include + +typedef struct { + int logfile_fd; + int simulate_ain; + int simulate_din; +} examplebus_t; + +typedef struct { + char *logfile; +} examplebus_attr_t; + +int examplebus_attr_init(examplebus_attr_t *attr) +{ + memset(attr, 0, sizeof(examplebus_attr_t)); + return 0; +} + +int examplebus_attr_setlogfile(examplebus_attr_t *attr, char *logfile) +{ + if (!attr) + return ENODEV; + + if (attr->logfile) + free(attr->logfile); + + attr->logfile = malloc(strlen(logfile)); + if (!attr->logfile) + return ENOMEM; + strcpy(attr->logfile, logfile); + return 0; +} + +int examplebus_init(examplebus_t *bus, examplebus_attr_t *attr) +{ + if ((!attr) || (!bus)) + return EINVAL; + + if (!attr->logfile) + return EINVAL; + + memset(bus, 0, sizeof(examplebus_t)); + bus->logfile_fd = open(attr->logfile, O_RDWR); + if (bus->logfile_fd < 0) + return ENOENT; + + return 0; +} + +int examplebus_destroy(examplebus_t *bus) +{ + close(bus->logfile_fd); + return 0; +} + +int examplebus_r_din(examplebus_t *bus, int index, int *value) +{ + if (!bus) + return ENODEV; + + if (!value) + return EINVAL; + + bus->simulate_din = bus->simulate_din == 1 ? 0 : 1; + *value = bus->simulate_din; + + return 0; +} + +int examplebus_w_dout(examplebus_t *bus, int index, int value) +{ + /* FIXME do something */ + return 0; +} + +int examplebus_r_ain(examplebus_t *bus, int index, int *value) +{ + bus->simulate_ain += 1; + if (bus->simulate_ain == 10) + bus->simulate_ain = 0; + *value = bus->simulate_ain; + + return 0; +} + +int examplebus_w_aout(examplebus_t *bus, int index, int value) +{ + /* FIXME do something */ + return 0; +} + Added: branches/fddi-mapping/tests/libfddi_examplebus.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/libfddi_examplebus.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,61 @@ +/* + * This is an example fieldbus library implementation + */ + +#include +#include + +int fddi_backend_init(fddi_iface_t *iface) +{ + return 0; +} + +int fddi_backend_destroy(fddi_iface_t *iface) +{ + return 0; +} + +int fddi_backend_configure(fddi_iface_t *iface, const char *configfile, void *data) +{ + return 0; +} + +int fddi_backend_setstate(fddi_iface_t *iface, fddi_state_enum_t state) +{ + int retval = -1; + + switch(state) { + case STATE_UNCONFIGURED: + case STATE_MISSING: + case STATE_CONFIG_ERROR: + case STATE_PREOPERATIONAL: + case STATE_OPERATIONAL: + case STATE_OPERATION_ERROR: + retval = 0; + break; + default: + break; + } + + return retval; +} + +int fddi_backend_cmd(fddi_iface_t *iface, fddi_cmd_enum_t cmd) +{ + int retval = -1; + + switch (cmd) { + case CMD_START: + case CMD_STOP: + case CMD_RESET: + case CMD_IDENTIFY: + case CMD_QUITERR: + retval = 0; + break; + default: + break; + } + + return retval; +} + Added: branches/fddi-mapping/tests/test_examplebus1.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_examplebus1.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,31 @@ +#include +#include + +#include + +int main(void) +{ + examplebus_attr_t attr; + examplebus_t examplebus; + int val; + int ret; + + examplebus_attr_init(&attr); + examplebus_attr_setlogfile(&attr, "logfile"); + + examplebus_init(&examplebus, &attr); + + /* test digital ins */ + ret = examplebus_r_din(&examplebus, 0, &val); + if (val != 1) + exit(-1); + + ret = examplebus_r_din(&examplebus, 0, &val); + if (val != 0) + exit(-1); + + examplebus_destroy(&examplebus); + + exit(0); +} + Added: branches/fddi-mapping/tests/test_fddi_can1.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_can1.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,96 @@ +#include +#include +#include +#include + +#include + +static int endme; + +void signalhandler(int sig) +{ + if (sig == SIGPIPE) + return; + if (sig == SIGHUP) { + fprintf(stderr, "SIGHUP received\n"); + } + if (sig == SIGTERM || sig == SIGINT) { + fprintf(stderr, "ctrl-c pressed, shutting down\n"); + endme = 1; + } +} + + +int tpu_callback(fddi_tpu_t *tpu, void *arg) +{ + printf("callback\n"); + return 0; +} + +/* + * FIXME: we have to agree on a bus start workflow! + */ + +int main(void) +{ + struct sigaction action; + + fddi_iface_attr_t can0_attr; + fddi_iface_t can0_iface; + fddi_id_t can0_id; + fddi_tpu_t *tpu; + + int ret; + + /* setup signal handler */ + action.sa_handler = signalhandler; + sigemptyset(&action.sa_mask); + action.sa_flags = 0; + sigaction(SIGTERM, &action, 0); /* catches kill from the shell */ + sigaction(SIGINT, &action, 0); /* catches Ctrl-C from the shell */ + sigaction(SIGPIPE, &action, 0); /* catches Broken Pipe exception */ + sigaction(SIGHUP, &action, 0); /* catches HUP */ + + fddi_id_init(&can0_id, "can", 0, NULL); + + /* instanciate io_interface */ + fddi_iface_attr_init(&can0_attr); + fddi_iface_attr_setclass(&can0_attr, "libfddi_can.so"); + fddi_iface_attr_setid(&can0_attr, "demosystem.boardcomputer", can0_id); + + ret = fddi_iface_init(&can0_iface, &can0_attr); + if (ret) { + fprintf(stderr, "fddi_iface_init() failed\n"); + return ret; + } + + ret = fddi_iface_configure(&can0_iface, "test_fddi_can1.xml", NULL); + if (ret) { + fprintf(stderr, "fddi_iface_configure() failed\n"); + return ret; + } + + /* attach callbacks to TPUs */ + fddi_iface_gettpulist(&can0_iface, &tpu); + while (tpu) { + fddi_tpu_setcallback(tpu, tpu_callback, NULL); + fddi_tpu_getnext(&tpu); + } + + /* everything is configured, now we can start */ + ret = fddi_iface_cmd(&can0_iface, CMD_START); + if (ret) { + fprintf(stderr, "fddi_iface_cmd() failed\n"); + return ret; + } + + printf("entering main loop, press ctrl-c to end\n"); + while (!endme) + sleep(1); + + /* destruct io_interface */ + fddi_iface_destroy(&can0_iface); + + exit(0); +} + Added: branches/fddi-mapping/tests/test_fddi_can1.xml ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_can1.xml Tue Oct 2 16:30:06 2007 @@ -0,0 +1,139 @@ + + + + + + + + + CAN Demo System + + + + Board Computer + + + + + CAN + 500000 + + + + + + + + + + + + + + + + The Vehicle + + + + + CAN + 500000 + + + + + + + + + + + + + + + + + + + + + + 8 + + + + + + Car Speed (from CAN) + uint16_t + 0 + + + + RPM (from CAN) + uint16_t + 2 + + + + Voltage (from CAN) + uint16_t + 4 + + + + Current (from CAN) + uint16_t + 6 + + + + + + + 4 + + + + + + A Rate (from CAN) + uint16_t + 0 + + + + S Rate (from CAN) + uint16_t + 2 + + + + + + + + + + Added: branches/fddi-mapping/tests/test_fddi_examplebus1.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_examplebus1.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,145 @@ +#include +#include +#include + +#include + +/* + * application usage of fddi + * + * FIXME: make this an example and split test case into smaller pieces + */ + +int tpu_callback(fddi_tpu_t *tpu) +{ + printf("hallo\n"); + return 0; +} + +int main(void) +{ + fddi_device_t *dev; + + fddi_iface_attr_t exb0_attr; + fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; + + fddi_tpu_t *tpu; + fddi_pv_t *pv; /* FIXME: pv_t ? */ + fddi_param_t *param; + char *strbuf; + int i; + unsigned long ul; + + /* instanciate io_interface */ + fddi_iface_attr_init(&exb0_attr); + fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); + + fddi_iface_init(&exb0_iface, &exb0_attr); + + /* some things you can do with ifaces */ + fddi_iface_configure(&exb0_iface, "config.xml", NULL); + + fddi_iface_setstate(&exb0_iface, STATE_UNCONFIGURED); /* add blocking/nonblocking */ + fddi_iface_cmd(&exb0_iface, CMD_START); /* propagates to devices behind iface */ + + if (fddi_iface_getnodev(&exb0_iface) != 0) + return 1; + + if (fddi_iface_getnotpus(&exb0_iface) != 0) + return 1; + + if (fddi_iface_getnopvs(&exb0_iface) != 0) + return 1; + + /* do something with all devices */ + fddi_iface_getdevlist(&exb0_iface, &dev); + while (dev) { + fddi_dev_getname(dev, &strbuf); +// printf("device=%s\n", strbuf); + fddi_dev_getstatestr(dev, &strbuf); +// printf(" state=%s\n", strbuf); + fddi_dev_getphysid(dev, &i); +// printf(" phys_id=%i\n", i); + fddi_dev_getlogicalid(dev, &i); +// printf(" logical_id=%i\n", i); + + fddi_dev_getparamlist(dev, ¶m); + while (param) { + fddi_param_getkey(param, &strbuf); +// printf(" key=%s", strbuf); + fddi_param_getval(param, &strbuf); +// printf(" value=%s", strbuf); + fddi_param_getnext(¶m); + } + +// printf(" tpus=%i\n", fddi_dev_getnotpus(dev)); +// printf("\n"); + + fddi_dev_read_async(dev); /* add arguments */ + fddi_dev_write_async(dev); /* add arguments */ + + fddi_dev_getnext(&dev); + } + + /* do something with all tpus */ + fddi_iface_gettpulist(&exb0_iface, &tpu); + while (tpu) { + fddi_tpu_getname(tpu, &strbuf); +// printf("tpu=%s\n", strbuf); + fddi_tpu_getid(tpu, &i); +// printf(" id=%i\n", i); + fddi_tpu_gettimestamp(tpu, &i); +// printf(" timestamp=%i\n", i); /* FIXME tv */ + fddi_tpu_getflags(tpu, &ul); +// printf(" flags=%li\n", ul); + + fddi_tpu_setcallback(tpu, tpu_callback); + + /* iterate over process variables */ + fddi_tpu_getpvlist(tpu, &pv); + while (pv) { + fddi_pv_getname(pv, &strbuf); +// printf("pv=%s\n",strbuf); + fddi_pv_getnext(&pv); + } + fddi_tpu_getpayload(tpu, &strbuf); +// printf(" payload=0x%p\n", strbuf); + + fddi_tpu_send(tpu); + +// printf("\n"); + + fddi_tpu_getnext(&tpu); + } + + /* + * Questions: + * + * - Can an io_interface be deconfigured? Otherwhise we should put the + * configure() method into init(). If not, we should add deconfigure + * or document that it can be re-run. + * -> re-configure is possible + * -> null config -> clean + * + * - Why isn't read_device_async() a method of the io_device? + * -> it is, but the stack has to trigger it + * + * - Are transport units a property of the device or of the io_interface? + * Probably io_interface (knows how to collect the process data) + * -> the io_interface instance (configured) generates the tpus + * + * - State handling: isn't that a method of the io_interface? It should + * know what to do internally, to bring up it's devices. + */ + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: branches/fddi-mapping/tests/test_fddi_examplebus_attach_backend.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_examplebus_attach_backend.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,32 @@ +#include +#include +#include + +#include + +int main(void) +{ + fddi_iface_attr_t exb0_attr; + fddi_iface_t exb0_iface; + fddi_id_t exb0id = { + .prefix="exb", + .index=0, + }; + + int ret; + + /* instanciate io_interface */ + fddi_iface_attr_init(&exb0_attr); + fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0id); + + ret = fddi_iface_init(&exb0_iface, &exb0_attr); + if (ret) + return ret; + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: branches/fddi-mapping/tests/test_fddi_examplebus_cmd_identify.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_examplebus_cmd_identify.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,39 @@ +#include +#include + +#include + +int main(void) +{ + fddi_iface_attr_t exb0_attr; + fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; + + int ret; + + /* instanciate io_interface */ + fddi_iface_attr_init(&exb0_attr); + fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); + + ret = fddi_iface_init(&exb0_iface, &exb0_attr); + if (ret) { + fprintf(stderr, "fddi_iface_init() failed\n"); + return ret; + } + + ret = fddi_iface_cmd(&exb0_iface, CMD_IDENTIFY); + if (ret) { + fprintf(stderr, "fddi_iface_cmd(CMD_IDENTIFY) failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: branches/fddi-mapping/tests/test_fddi_examplebus_cmd_quiterr.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_examplebus_cmd_quiterr.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,39 @@ +#include +#include + +#include + +int main(void) +{ + fddi_iface_attr_t exb0_attr; + fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; + + int ret; + + /* instanciate io_interface */ + fddi_iface_attr_init(&exb0_attr); + fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); + + ret = fddi_iface_init(&exb0_iface, &exb0_attr); + if (ret) { + fprintf(stderr, "fddi_iface_init() failed\n"); + return ret; + } + + ret = fddi_iface_cmd(&exb0_iface, CMD_QUITERR); + if (ret) { + fprintf(stderr, "fddi_iface_cmd(CMD_QUITERR) failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: branches/fddi-mapping/tests/test_fddi_examplebus_cmd_reset.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_examplebus_cmd_reset.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,39 @@ +#include +#include + +#include + +int main(void) +{ + fddi_iface_attr_t exb0_attr; + fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; + + int ret; + + /* instanciate io_interface */ + fddi_iface_attr_init(&exb0_attr); + fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); + + ret = fddi_iface_init(&exb0_iface, &exb0_attr); + if (ret) { + fprintf(stderr, "fddi_iface_init() failed\n"); + return ret; + } + + ret = fddi_iface_cmd(&exb0_iface, CMD_RESET); + if (ret) { + fprintf(stderr, "fddi_iface_cmd(CMD_RESET) failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: branches/fddi-mapping/tests/test_fddi_examplebus_cmd_start.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_examplebus_cmd_start.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,39 @@ +#include +#include + +#include + +int main(void) +{ + fddi_iface_attr_t exb0_attr; + fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; + + int ret; + + /* instanciate io_interface */ + fddi_iface_attr_init(&exb0_attr); + fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); + + ret = fddi_iface_init(&exb0_iface, &exb0_attr); + if (ret) { + fprintf(stderr, "fddi_iface_init() failed\n"); + return ret; + } + + ret = fddi_iface_cmd(&exb0_iface, CMD_START); + if (ret) { + fprintf(stderr, "fddi_iface_cmd(CMD_START) failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: branches/fddi-mapping/tests/test_fddi_examplebus_cmd_stop.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_examplebus_cmd_stop.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,39 @@ +#include +#include + +#include + +int main(void) +{ + fddi_iface_attr_t exb0_attr; + fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; + + int ret; + + /* instanciate io_interface */ + fddi_iface_attr_init(&exb0_attr); + fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); + + ret = fddi_iface_init(&exb0_iface, &exb0_attr); + if (ret) { + fprintf(stderr, "fddi_iface_init() failed\n"); + return ret; + } + + ret = fddi_iface_cmd(&exb0_iface, CMD_STOP); + if (ret) { + fprintf(stderr, "fddi_iface_cmd(CMD_STOP) failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: branches/fddi-mapping/tests/test_fddi_examplebus_configure.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_examplebus_configure.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,39 @@ +#include +#include + +#include + +int main(void) +{ + fddi_iface_attr_t exb0_attr; + fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; + + int ret; + + /* instanciate io_interface */ + fddi_iface_attr_init(&exb0_attr); + fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); + + ret = fddi_iface_init(&exb0_iface, &exb0_attr); + if (ret) { + fprintf(stderr, "fddi_iface_init() failed\n"); + return ret; + } + + ret = fddi_iface_configure(&exb0_iface, "test_fddi_examplebus_configure.xml", NULL); + if (ret) { + fprintf(stderr, "fddi_iface_configure() failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: branches/fddi-mapping/tests/test_fddi_examplebus_setstate_configerror.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_examplebus_setstate_configerror.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,39 @@ +#include +#include + +#include + +int main(void) +{ + fddi_iface_attr_t exb0_attr; + fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; + + int ret; + + /* instanciate io_interface */ + fddi_iface_attr_init(&exb0_attr); + fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); + + ret = fddi_iface_init(&exb0_iface, &exb0_attr); + if (ret) { + fprintf(stderr, "fddi_iface_init() failed\n"); + return ret; + } + + ret = fddi_iface_setstate(&exb0_iface, STATE_CONFIG_ERROR); + if (ret) { + fprintf(stderr, "fddi_iface_setstate(STATE_CONFIG_ERROR) failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: branches/fddi-mapping/tests/test_fddi_examplebus_setstate_missing.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_examplebus_setstate_missing.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,39 @@ +#include +#include + +#include + +int main(void) +{ + fddi_iface_attr_t exb0_attr; + fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; + + int ret; + + /* instanciate io_interface */ + fddi_iface_attr_init(&exb0_attr); + fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); + + ret = fddi_iface_init(&exb0_iface, &exb0_attr); + if (ret) { + fprintf(stderr, "fddi_iface_init() failed\n"); + return ret; + } + + ret = fddi_iface_setstate(&exb0_iface, STATE_MISSING); + if (ret) { + fprintf(stderr, "fddi_iface_setstate(STATE_MISSING) failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: branches/fddi-mapping/tests/test_fddi_examplebus_setstate_operation_error.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_examplebus_setstate_operation_error.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,39 @@ +#include +#include + +#include + +int main(void) +{ + fddi_iface_attr_t exb0_attr; + fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; + + int ret; + + /* instanciate io_interface */ + fddi_iface_attr_init(&exb0_attr); + fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); + + ret = fddi_iface_init(&exb0_iface, &exb0_attr); + if (ret) { + fprintf(stderr, "fddi_iface_init() failed\n"); + return ret; + } + + ret = fddi_iface_setstate(&exb0_iface, STATE_OPERATION_ERROR); + if (ret) { + fprintf(stderr, "fddi_iface_setstate(STATE_OPERATION_ERROR) failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: branches/fddi-mapping/tests/test_fddi_examplebus_setstate_operational.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_examplebus_setstate_operational.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,39 @@ +#include +#include + +#include + +int main(void) +{ + fddi_iface_attr_t exb0_attr; + fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; + + int ret; + + /* instanciate io_interface */ + fddi_iface_attr_init(&exb0_attr); + fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); + + ret = fddi_iface_init(&exb0_iface, &exb0_attr); + if (ret) { + fprintf(stderr, "fddi_iface_init() failed\n"); + return ret; + } + + ret = fddi_iface_setstate(&exb0_iface, STATE_OPERATIONAL); + if (ret) { + fprintf(stderr, "fddi_iface_setstate(STATE_OPERATIONAL) failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: branches/fddi-mapping/tests/test_fddi_examplebus_setstate_preoperational.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_examplebus_setstate_preoperational.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,39 @@ +#include +#include + +#include + +int main(void) +{ + fddi_iface_attr_t exb0_attr; + fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; + + int ret; + + /* instanciate io_interface */ + fddi_iface_attr_init(&exb0_attr); + fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); + + ret = fddi_iface_init(&exb0_iface, &exb0_attr); + if (ret) { + fprintf(stderr, "fddi_iface_init() failed\n"); + return ret; + } + + ret = fddi_iface_setstate(&exb0_iface, STATE_PREOPERATIONAL); + if (ret) { + fprintf(stderr, "fddi_iface_setstate(STATE_PREOPERATIONAL) failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: branches/fddi-mapping/tests/test_fddi_examplebus_setstate_unconfigured.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_examplebus_setstate_unconfigured.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,39 @@ +#include +#include + +#include + +int main(void) +{ + fddi_iface_attr_t exb0_attr; + fddi_iface_t exb0_iface; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; + + int ret; + + /* instanciate io_interface */ + fddi_iface_attr_init(&exb0_attr); + fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); + + ret = fddi_iface_init(&exb0_iface, &exb0_attr); + if (ret) { + fprintf(stderr, "fddi_iface_init() failed\n"); + return ret; + } + + ret = fddi_iface_setstate(&exb0_iface, STATE_UNCONFIGURED); + if (ret) { + fprintf(stderr, "fddi_iface_setstate(STATE_UNCONFIGURED) failed\n"); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: branches/fddi-mapping/tests/test_fddi_examplebus_tpu_usecase.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_examplebus_tpu_usecase.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,154 @@ +#include +#include + +#include + +int main(void) +{ + fddi_iface_attr_t exb0_attr; + fddi_iface_t exb0_iface; + fddi_tpu_t *tpu; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; + + int ret; + + /* instanciate io_interface */ + fddi_iface_attr_init(&exb0_attr); + fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); + + ret = fddi_iface_init(&exb0_iface, &exb0_attr); + if (ret) { + fprintf(stderr, "fddi_iface_init() failed\n"); + return ret; + } + + ret = fddi_iface_configure(&exb0_iface, "config.xml", NULL); + if (ret) { + fprintf(stderr, "fddi_iface_configure() failed\n"); + fddi_iface_destroy(&exb0_iface); + return ret; + } + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + +/* FIXME pseudocode */ + +int main1(void) +{ + int endme; + pv_engine_t engine; + pv_engine_attr_t engine_attr; + pv_group_t group; + int ret; + + struct pv { + pv_uint32_t voltage; + pv_uint32_t speed; + pv_uint32_t x; + pv_bool_t end_switch_left; + pv_bool_t end_switch_right; + } + + /* instanciate a pv_engine */ + ret = pv_engine_init(&engine, &engine_attr); + if (ret) { + fprintf(stderr, "pv_init() failed\n"); + exit(EXIT_FAILURE); + } + + /* + * now register a pv_group (lockable set of pvs) + * let's take for example a linear drive + */ + + ret = pv_group_init(&group); + if (ret) { + fprintf(stderr, "pv_group_init() failed\n"); + pv_engine_destroy(&engine); + exit(EXIT_FAILURE); + } + + ret = 0; + ret += pv_group_register_uint32(&group, "voltage", &pv.voltage, O_RDWR); + ret += pv_group_register_uint32(&group, "current_speed", &pv.current_speed, O_RDONLY); + ret += pv_group_register_uint32(&group, "current_x", &pv.current_x, O_RDONLY); + ret += pv_group_register_bool(&group, "end_switch_left", &pv.end_switch_left, O_RDONLY); + ret += pv_group_register_bool(&group, "end_switch_right", &pv.end_switch_right, O_RDONLY); + + if (ret != 0) { + fprintf(stderr, "error registering process variables\n"); + pv_group_destroy(&group); + pv_engine_destroy(&engine); + exit(EXIT_FAILURE); + } + + /* example for "active / locking" scenario */ + + while (!endme) { + + /* + * "lock" the pv_group while updating the pvs; note that the + * pv_group contains a list of all affected TPUs, and locking + * means that we "allocate" a tpu (usecount+=1) while accessing it + */ + pv_group_lock(&group, timeout); + + /* starting from here, we have our exclusive sets of TPU buffers */ + + /* yes, printf is not realtime, just for demonstration */ + printf("current speed: \n", pv_uint32_get(&pv.current_speed)); + printf("current x: \n", pv_uint32_get(&pv.current_x)); + printf("end_switch_left: \n", pv_bool_get(&pv.end_switch_left)); + printf("end_switch_right: \n", pv_bool_get(&pv.end_switch_right)); + + /* now calculate the outputs */ + pv_uint32_set(&pv.voltage, 12345); + + /* + * update outputs + */ + pv_group_unlock(&group); + + sleep_until_next_period(); + + } + + /* example for "blocking" scenario, for group */ + + while (!endme) { + /* sleep until one of the TPUs in the group updates */ + pv_group_lock_on_group_change(&group, timeout); + /* do something with the pvs, or find out which pvs have changed */ + pv_group_unlock(&group); + } + + /* example for "blocking" scenario, for pv */ + + while (!endme) { + pv_group_lock_on_pv_change(&group, &pv.current.speed, timeout); + /* ... */ + pv_group_unlock(&group); + } + + /* example for "callback" scenario */ + pv_group_callback_on_group_change(&group, function); + pv_group_callback_on_pv_change(&group, &pv.current.speed, function); + + while (!endme) + sleep(1); + + /* destruct */ + pv_set_destroy(&set); + pv_engine_destroy(&engine); + + return 0; +} + Added: branches/fddi-mapping/tests/test_fddi_libmodbus1.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_libmodbus1.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,96 @@ +#include +#include +#include +#include + +#include + +static int endme; + +void signalhandler(int sig) +{ + if (sig == SIGPIPE) + return; + if (sig == SIGHUP) { + fprintf(stderr, "SIGHUP received\n"); + } + if (sig == SIGTERM || sig == SIGINT) { + fprintf(stderr, "ctrl-c pressed, shutting down\n"); + endme = 1; + } +} + + +int tpu_callback(fddi_tpu_t *tpu, void *arg) +{ + printf("callback\n"); + return 0; +} + +/* + * FIXME: we have to agree on a bus start workflow! + */ + +int main(void) +{ + struct sigaction action; + + fddi_iface_attr_t modbus0_attr; + fddi_iface_t modbus0_iface; + fddi_id_t modbus0_id; + fddi_tpu_t *tpu; + + int ret; + + /* setup signal handler */ + action.sa_handler = signalhandler; + sigemptyset(&action.sa_mask); + action.sa_flags = 0; + sigaction(SIGTERM, &action, 0); /* catches kill from the shell */ + sigaction(SIGINT, &action, 0); /* catches Ctrl-C from the shell */ + sigaction(SIGPIPE, &action, 0); /* catches Broken Pipe exception */ + sigaction(SIGHUP, &action, 0); /* catches HUP */ + + fddi_id_init(&modbus0_id, "modbus", 0, NULL); + + /* instanciate io_interface */ + fddi_iface_attr_init(&modbus0_attr); + fddi_iface_attr_setclass(&modbus0_attr, "libfddi_libmodbus.so"); + fddi_iface_attr_setid(&modbus0_attr, "demosystem.controller", modbus0_id); + + ret = fddi_iface_init(&modbus0_iface, &modbus0_attr); + if (ret) { + fprintf(stderr, "fddi_iface_init() failed\n"); + return ret; + } + + ret = fddi_iface_configure(&modbus0_iface, "test_fddi_libmodbus1.xml", NULL); + if (ret) { + fprintf(stderr, "fddi_iface_configure() failed\n"); + return ret; + } + + /* attach callbacks to TPUs */ + fddi_iface_gettpulist(&modbus0_iface, &tpu); + while (tpu) { + fddi_tpu_setcallback(tpu, tpu_callback, NULL); + fddi_tpu_getnext(&tpu); + } + + /* everything is configured, now we can start */ + ret = fddi_iface_cmd(&modbus0_iface, CMD_START); + if (ret) { + fprintf(stderr, "fddi_iface_cmd() failed\n"); + return ret; + } + + printf("entering main loop, press ctrl-c to end\n"); + while (!endme) + sleep(1); + + /* destruct io_interface */ + fddi_iface_destroy(&modbus0_iface); + + exit(0); +} + Added: branches/fddi-mapping/tests/test_fddi_versionstr.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/test_fddi_versionstr.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,36 @@ +#include +#include +#include + +#include + +int main(void) +{ + fddi_iface_attr_t exb0_attr; + fddi_iface_t exb0_iface; + + int ret; + const char *version; + fddi_id_t exb0_id = { + .prefix="exb", + .index=0, + }; + + /* instanciate io_interface */ + fddi_iface_attr_init(&exb0_attr); + fddi_iface_attr_setclass(&exb0_attr, "libfddi_examplebus.so"); + fddi_iface_attr_setid(&exb0_attr, NULL, exb0_id); + + ret = fddi_iface_init(&exb0_iface, &exb0_attr); + if (ret) + return ret; + + fddi_iface_getversionstr(&exb0_iface, &version); + printf("fddi version: %s\n", version); + + /* destruct io_interface */ + fddi_iface_destroy(&exb0_iface); + + exit(0); +} + Added: branches/fddi-mapping/tests/usecase_controller.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/usecase_controller.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,149 @@ +#include +#include +#include +#include +#include + +#include + +/* + * FIXME: + * - for timeout, invent a mechanism which wakes up _all_ + * wait_and_locks and lets them return with an error + * - do we need the type for pv_attr and pv_*_init? + */ + +#define PV_CREATE(var, thetype, group) \ + do { \ + int ret; \ + char *name = strdup(#var); \ + fddi_pv_attr_t pv_##var##_attr = { .type = thetype, .name = name, .pv_group = group, }; \ + ret = fddi_pv_##thetype##_init(&pv_##var, &pv_##var##_attr); \ + if (ret) { \ + fprintf(stderr, "error: could not register process variable '"#var"'\n"); \ + goto out_pv_##var; \ + } \ + } while(0) + +#define PV_DESTROY(var, type) \ + fddi_pv_##type##_destroy(&pv_##var); \ + out_pv_##var: \ + do {} while(0) + +static int shutdown = 0; +static int Ta = (10*1000*1000); /* 10 ms */ + +void +signalhandler(int sig) +{ + if ((sig == SIGPIPE) || (sig == SIGHUP)) + return; + if (sig == SIGTERM || sig == SIGINT) + shutdown = 1; +} + +int main(int argc, char *argv[]) +{ + struct sigaction action; + fddi_pv_engine_t pv_engine; + fddi_pv_group_attr_t pv_group_attr; + fddi_pv_group_t pv_group; + int ret; + + fddi_pv_t pv_input; + fddi_pv_t pv_output; + fddi_pv_t pv_Kp; + fddi_pv_t pv_Ki; + fddi_pv_t pv_Kd; + + /* setup signal handler */ + action.sa_handler = signalhandler; + sigemptyset (&action.sa_mask); + action.sa_flags = 0; + sigaction (SIGTERM, &action, 0); /* catches kill from the shell */ + sigaction (SIGINT, &action, 0); /* catches Ctrl-C from the shell */ + sigaction (SIGPIPE, &action, 0); /* catches Broken Pipe exception */ + sigaction (SIGHUP, &action, 0); /* catches HUP */ + + /* initialize */ + ret = fddi_pv_engine_init(&pv_engine); + if (ret) { + fprintf(stderr, "error: could not create pv_engine\n"); + exit(EXIT_FAILURE); + } + + /* fddi_pv_engine_configure(&pv_engine, "model.xml", "/path/for/module"); */ + ret = fddi_pv_engine_configure_from_cmdline(&pv_engine, argc, argv); + if (ret) { + fprintf(stderr, "error: could not configure pv_engine\n"); + exit(EXIT_FAILURE); + } + + /* initialize pv_group */ + ret = fddi_pv_group_attr_init(&pv_group_attr, &pv_engine); + if (ret) { + fprintf(stderr, "error: could not init pv_group_attr\n"); + exit(EXIT_FAILURE); + } + ret = fddi_pv_group_attr_setname(&pv_group_attr, "controller"); + if (ret) { + fprintf(stderr, "error: could not set pv_group's name\n"); + exit(EXIT_FAILURE); + } + ret = fddi_pv_group_init(&pv_group, &pv_group_attr); + if (ret) { + fprintf(stderr, "error: couldn't create pv_group\n"); + exit(EXIT_FAILURE); + } + + /* register process variables and put them into pv_group */ + PV_CREATE(input, UINT32, &pv_group); + PV_CREATE(output, UINT32, &pv_group); + PV_CREATE(Kp, UINT32, &pv_group); + PV_CREATE(Ki, UINT32, &pv_group); + PV_CREATE(Kd, UINT32, &pv_group); + + /* control loop */ + while (!shutdown) { + + uint32_t e, x, esum, ealt; + + /* + * make this compile time configurable: + * + * a) lock + * b) lock -> make local pv copy into priv -> unlock + * c) rcu_lock + */ + + ret = fddi_pv_group_wait_and_lock(&pv_group); + + e = fddi_pv_uint32_get(&pv_input) - x; /* comparism */ + esum = esum + e; /* I part */ + fddi_pv_uint32_set(&pv_output, + fddi_pv_uint32_get(&pv_Kp)*e + + fddi_pv_uint32_get(&pv_Ki)*Ta*esum + + fddi_pv_uint32_get(&pv_Kd)/Ta * (e ? ealt : e) + ); + ealt = e; + + /* + * a) unlock + * b) lock -> make local pv copy from priv -> unlock + * c) rcu_unlock + */ + fddi_pv_group_unlock(&pv_group); + } + + PV_DESTROY(Kd, uint32); + PV_DESTROY(Ki, uint32); + PV_DESTROY(Kp, uint32); + PV_DESTROY(output, uint32); + PV_DESTROY(input, uint32); + + fddi_pv_group_destroy(&pv_group); + fddi_pv_group_attr_destroy(&pv_group_attr); + + return ret; +} + Added: branches/fddi-mapping/tests/usecase_streaming.c ============================================================================== --- (empty file) +++ branches/fddi-mapping/tests/usecase_streaming.c Tue Oct 2 16:30:06 2007 @@ -0,0 +1,110 @@ +#include +#include +#include +#include + +//#include + +/* FIXME put into header file */ + + typedef struct ldi_attr { + } ldi_attr_t; + + typedef struct ldi { + } ldi_t; + typedef struct pv { + } pv_t; + typedef struct tpu { + } tpu_t; + + /* pv */ + int pv_uint32_create(pv_t *pv, ldi_t *ldi, const char *name); + int pv_uint32_destroy(pv_t *pv); + uint32_t pv_uint32_get(pv_t *pv); + void pv_uint32_set(pv_t *pv, uint32_t val); + + /* tpu */ + int tpu_create(tpu_t *tpu /*, FIXME */); + int tpu_destroy(tpu_t *tpu); + + /* ldi_attr */ + int ldi_attr_init_from_cmdline(ldi_attr_t *attr, int argc, char *argv[]); + int ldi_attr_destroy(ldi_attr_t *attr); + + /* ldi */ + int ldi_create(ldi_t *ldi, ldi_attr_t *attr); + int ldi_destroy(ldi_t *ldi); + int ldi_trigger_define(ldi_t *ldi, pv_t *pv); + int ldi_trigger_wait(ldi_t *ldi, uint64_t timeout_ns); + int ldi_tpu_trigger_define(ldi_t *ldi, tpu_t *tpu); + + +static int shutdown = 0; + +void +signalhandler(int sig) +{ + if ((sig == SIGPIPE) || (sig == SIGHUP)) + return; + if (sig == SIGTERM || sig == SIGINT) + shutdown = 1; +} + +int main(int argc, char *argv[]) +{ + struct sigaction action; + ldi_attr_t ldi_attr; + ldi_t ldi; + int ret; + + tpu_t tpu; + + /* setup signal handler */ + action.sa_handler = signalhandler; + sigemptyset (&action.sa_mask); + action.sa_flags = 0; + sigaction (SIGTERM, &action, 0); /* catches kill from the shell */ + sigaction (SIGINT, &action, 0); /* catches Ctrl-C from the shell */ + sigaction (SIGPIPE, &action, 0); /* catches Broken Pipe exception */ + sigaction (SIGHUP, &action, 0); /* catches HUP */ + + /* initialize ldi */ + ret = ldi_attr_init_from_cmdline(&ldi_attr, argc, argv); + if (ret) { + fprintf(stderr, "error: could not init ldi_attr\n"); + exit(EXIT_FAILURE); + } + + ret = ldi_create(&ldi, &ldi_attr); + if (ret) { + fprintf(stderr, "error: couldn't create ldi\n"); + exit(EXIT_FAILURE); + } + + ret = tpu_create(&tpu); /* FIXME: how to find out which one? */ + if (ret) { + fprintf(stderr, "error: could not register tpu\n"); + exit(EXIT_FAILURE); + } + + /* this TPU is our trigger */ + ret = ldi_tpu_trigger_define(&ldi, &tpu); + + /* control loop */ + while (!shutdown) { + + ret = ldi_trigger_wait(&ldi, 100*1000*1000); /* wait until trigger fires, with timeout in ns */ + if (ret) + continue; + + /* FIXME now what to do with the tpu payload? */ + /* FIXME how to decide when TPUs are pushed back to the pool? */ + + } + + tpu_destroy(&tpu); + + ldi_destroy(&ldi); + ldi_attr_destroy(&ldi_attr); + return ret; +}