summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Traut <manut@mecka.net>2012-06-07 16:00:59 +0200
committerManuel Traut <manut@mecka.net>2012-06-07 16:00:59 +0200
commite3f225cd4fb60437d94288849f7af03179d56f6b (patch)
tree7c4ef56f5c83fc6cdd6d74a0aa8011f0f39b0307
parentf5e17d19e473e501ffa964ec3ccda1970ecafbf2 (diff)
retriving digital ios inside a device works now
Signed-off-by: Manuel Traut <manut@mecka.net>
-rw-r--r--common/Makefile5
-rw-r--r--common/distrio_helper.cpp13
-rw-r--r--common/distrio_helper.h2
-rw-r--r--devices/simple_dev/Makefile2
-rw-r--r--devices/simple_dev/simple_dev.cpp2
-rw-r--r--io/bin/generic_gpio/Makefile3
-rw-r--r--io/bin/generic_gpio/generic_gpio.cpp46
-rw-r--r--manager/bin/distrio_manager.cpp1
8 files changed, 53 insertions, 21 deletions
diff --git a/common/Makefile b/common/Makefile
index c869a74..27498ac 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -7,8 +7,9 @@ DISTRIO_BASE = ../
DISTRIO_IO = $(DISTRIO_BASE)io/lib
DISTRIO_MANAGER = $(DISTRIO_BASE)manager/lib
-CFLAGS += -fPIC -I. -I$(DISTRIO_IO) -I$(DISTRIO_MANAGER)
+CFLAGS += -g -fPIC -I. -I$(DISTRIO_IO) -I$(DISTRIO_MANAGER)
CXXFLAGS += $(CFLAGS)
+LDFLAGS += -lrt
TAO_IDL := tao_idl
@@ -22,7 +23,7 @@ IDL_CLEANFILES = $(COMPONENT)C.cpp $(COMPONENT)C.inl $(COMPONENT)I.h \
$(COMPONENT)S.h $(COMPONENT)C.h $(COMPONENT)S.cpp
all: $(OBJ)
- $(LD) -shared -o $(LIB) $(OBJ)
+ $(LD) $(LDFLAGS) -shared -o $(LIB) $(OBJ)
.PHONY: idl
idl:
diff --git a/common/distrio_helper.cpp b/common/distrio_helper.cpp
index 076719c..ad0a5cd 100644
--- a/common/distrio_helper.cpp
+++ b/common/distrio_helper.cpp
@@ -56,7 +56,7 @@ out:
return ret;
}
-int register_digital (std::string _name, Distrio_Digital_i *digital)
+int register_digital (Distrio_Digital_i *digital)
{
CosNaming::Name name;
CORBA::Object_var obj, manager_obj;
@@ -73,12 +73,13 @@ int register_digital (std::string _name, Distrio_Digital_i *digital)
oid = ref.poa->activate_object (digital);
obj = digital->_this ();
name.length (1);
- name[0].id = CORBA::string_dup (_name.c_str ());
+ e = digital->name (name[0].id);
+ free (e);
name[0].kind = CORBA::string_dup ("digital_io");
ref.nc->rebind (name, obj.in ());
- } catch (CORBA::Exception &e) {
+ } catch (CORBA::Exception &exc) {
std::cerr << "CORBA bind digital io at naming service failed: "
- << e << std::endl;
+ << exc << std::endl;
return -1;
}
@@ -120,9 +121,11 @@ Distrio::Digital_ptr lookup_digital (std::string _name)
for (unsigned int i = 0; i < dig_list->length (); i++) {
::CORBA::String_var name;
Distrio::Error *e;
+
e = dig_list[i]->name (name);
free (e);
- if (! _name.compare (name)) {
+
+ if (! _name.compare (name.in ())) {
Distrio::Digital_ptr ptr = dig_list[i];
return ptr;
}
diff --git a/common/distrio_helper.h b/common/distrio_helper.h
index 3f96d93..69a6ef0 100644
--- a/common/distrio_helper.h
+++ b/common/distrio_helper.h
@@ -42,7 +42,7 @@ static corba_ref ref = {
/** initialize corba orb - argc, argv as passed to main() */
int init_corba (int argc, char **argv);
/** register a digital io with a common name at the naming service */
-int register_digital (std::string _name, Distrio_Digital_i *digital);
+int register_digital (Distrio_Digital_i *digital);
/** lookup a digital io by a common name at the manager */
Distrio::Digital_ptr lookup_digital (std::string _name);
/** register a device with a common name at the naming service */
diff --git a/devices/simple_dev/Makefile b/devices/simple_dev/Makefile
index 9ea290e..77cef22 100644
--- a/devices/simple_dev/Makefile
+++ b/devices/simple_dev/Makefile
@@ -12,7 +12,7 @@ LDFLAGS += -L$(DISTRIO_COMMON) -ldistrio_common \
-L$(DISTRIO_IO) -ldistrio_io \
-L$(DISTRIO_MANAGER) -ldistrio_manager \
-lrt -lACE -lTAO -lTAO_AnyTypeCode -lTAO_CosNaming -lTAO_PortableServer
-CFLAGS += -fPIC -I$(DISTRIO_COMMON) -I$(DISTRIO_IO) -I$(DISTRIO_MANAGER)
+CFLAGS += -g -fPIC -I$(DISTRIO_COMMON) -I$(DISTRIO_IO) -I$(DISTRIO_MANAGER)
CXXFLAGS += $(CFLAGS)
DESTDIR := /usr
diff --git a/devices/simple_dev/simple_dev.cpp b/devices/simple_dev/simple_dev.cpp
index 8f2072f..ca31b6e 100644
--- a/devices/simple_dev/simple_dev.cpp
+++ b/devices/simple_dev/simple_dev.cpp
@@ -19,7 +19,7 @@ class My_device : public Distrio_Device_i {
::CORBA::Long my_id;
};
-int main (int argc, char **argv)
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
int ret = 0;
My_device *dev;
diff --git a/io/bin/generic_gpio/Makefile b/io/bin/generic_gpio/Makefile
index c8aa810..b3e04ff 100644
--- a/io/bin/generic_gpio/Makefile
+++ b/io/bin/generic_gpio/Makefile
@@ -12,7 +12,8 @@ DISTRIO_IO := $(DISTRIO_BASE)io/lib
LDFLAGS += -L$(DISTRIO_COMMON) -ldistrio_common \
-L$(DISTRIO_IO) -ldistrio_io \
-L$(DISTRIO_MANAGER) -ldistrio_manager \
- -lACE -lTAO -lTAO_AnyTypeCode -lTAO_CosNaming -lTAO_PortableServer
+ -lACE -lTAO -lTAO_AnyTypeCode -lTAO_CosNaming -lTAO_PortableServer \
+ -lrt
CFLAGS += -fPIC -I$(DISTRIO_COMMON) -I$(DISTRIO_IO) -I$(DISTRIO_MANAGER)
CXXFLAGS += $(CFLAGS)
diff --git a/io/bin/generic_gpio/generic_gpio.cpp b/io/bin/generic_gpio/generic_gpio.cpp
index 325cb9c..1042c09 100644
--- a/io/bin/generic_gpio/generic_gpio.cpp
+++ b/io/bin/generic_gpio/generic_gpio.cpp
@@ -3,26 +3,49 @@
#include <distrio_ioI.h>
+#include <ace/Task.h>
+
#include <iostream>
-class My_digital : public Distrio_Digital_i {
+class Io_manager : public ACE_Task < ACE_MT_SYNCH > {
public:
- ::CORBA::Long id (void)
- {
- return my_id;
+ Io_manager () { }
+ ~Io_manager () { }
+
+ private:
+ int svc (void) {
+ while (1) {
+ std::cout << "check inputs" << std::endl;
+ sleep (1);
+ }
}
- void id (::CORBA::Long id)
- {
- my_id = id;
+};
+
+class My_digital : public Distrio_Digital_i {
+ public:
+ My_digital (std::string _name) { my_name = _name; }
+ ~My_digital () { };
+
+ ::CORBA::Long id (void) { return my_id; }
+
+ ::Distrio::Error *name (::CORBA::String_out _name) {
+ _name = CORBA::string_dup (my_name.c_str ());
+ std::cout << "name: " << my_name << std::endl;
+ return distrio_success ();
}
+
+ void id (::CORBA::Long id) { my_id = id; }
+
private:
+ std::string my_name;
::CORBA::Long my_id;
};
-int main (int argc, char **argv)
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
int ret = 0;
My_digital *digital;
+ Io_manager manager;
if (init_corba (argc, argv))
return -EINVAL;
@@ -30,15 +53,18 @@ int main (int argc, char **argv)
if (run_orb ())
return -EINVAL;
- digital = new My_digital ();
+ digital = new My_digital (std::string ("pin huhu"));
- if (register_digital ("pin huhu", digital)) {
+ if (register_digital (digital)) {
ret = -EINVAL;
goto out;
}
std::cout << "registered id: " << digital->id () << std::endl;
+ manager.activate ();
+ manager.wait ();
+
out:
free (digital);
return ret;
diff --git a/manager/bin/distrio_manager.cpp b/manager/bin/distrio_manager.cpp
index d9f2ea9..a0ee476 100644
--- a/manager/bin/distrio_manager.cpp
+++ b/manager/bin/distrio_manager.cpp
@@ -29,6 +29,7 @@ Distrio_Manager_i::~Distrio_Manager_i (void)
::Distrio::Error * Distrio_Manager_i::digital (
::Distrio::Digital_list_out io_list)
{
+ io_list = new ::Distrio::Digital_list ();
io_list->length (digital_list.length ());
for (unsigned int i = 0; i < digital_list.length (); i++)