From f79ee1d59423488c3de89e97e3648515a9143b36 Mon Sep 17 00:00:00 2001 From: Manuel Traut Date: Sun, 3 Jun 2012 20:12:26 +0200 Subject: add simple_dev example - registers device at the manager - fixup manager to enable device registration - extend distrio_helper to support device registration Signed-off-by: Manuel Traut --- devices/Makefile | 12 +++++++++ devices/simple_dev/Makefile | 36 +++++++++++++++++++++++++++ devices/simple_dev/distrio_simple_dev | Bin 0 -> 42865 bytes devices/simple_dev/run.sh | 9 +++++++ devices/simple_dev/simple_dev.cpp | 45 ++++++++++++++++++++++++++++++++++ 5 files changed, 102 insertions(+) create mode 100644 devices/Makefile create mode 100644 devices/simple_dev/Makefile create mode 100755 devices/simple_dev/distrio_simple_dev create mode 100755 devices/simple_dev/run.sh create mode 100644 devices/simple_dev/simple_dev.cpp (limited to 'devices') diff --git a/devices/Makefile b/devices/Makefile new file mode 100644 index 0000000..9a8528b --- /dev/null +++ b/devices/Makefile @@ -0,0 +1,12 @@ +MAKE_DIRECTORIES = simple_dev + +.PHONY: all +idl: $(MAKE_DIRECTORIES) +all: $(MAKE_DIRECTORIES) + +.PHONY: $(MAKE_DIRECTORIES) +$(MAKE_DIRECTORIES): + @$(MAKE) --keep-going --directory=$@ $(MAKECMDGOALS) + +.PHONY: $(MAKECMDGOALS) +$(MAKECMDGOALS): $(MAKE_DIRECTORIES) diff --git a/devices/simple_dev/Makefile b/devices/simple_dev/Makefile new file mode 100644 index 0000000..0d6e728 --- /dev/null +++ b/devices/simple_dev/Makefile @@ -0,0 +1,36 @@ +CC := $(CROSS_COMPILE)gcc +CXX := $(CROSS_COMPILE)g++ +LD := $(CROSS_COMPILE)g++ + +DISTRIO_MANAGER := ../../manager/lib +DISTRIO_COMMON := ../../common +DISTRIO_IO := ../../io + +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) +CXXFLAGS += $(CFLAGS) + +DESTDIR := /usr + +COMPONENT = distrio_simple_dev +EXEC = $(COMPONENT) +OBJ = simple_dev.o + +all: $(OBJ) + $(LD) $(LDFLAGS) -o $(EXEC) $(OBJ) + +clean: + rm -f *.o + rm -f $(EXEC) + +install: all + cp -a $(EXEC) $(DESTDIR)/bin + +uninstall: + rm -f $(DESTDIR)/bin/$(EXEC) + +idl: + /bin/true diff --git a/devices/simple_dev/distrio_simple_dev b/devices/simple_dev/distrio_simple_dev new file mode 100755 index 0000000..2687132 Binary files /dev/null and b/devices/simple_dev/distrio_simple_dev differ diff --git a/devices/simple_dev/run.sh b/devices/simple_dev/run.sh new file mode 100755 index 0000000..6d38011 --- /dev/null +++ b/devices/simple_dev/run.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# +# startup script for distrio simple device +# +# author: Manuel Traut + +LD_LIBRARY_PATH=../../io:../../common:../../manager/lib ./distrio_simple_dev \ + -ORBInitRef NameService=corbaloc:iiop:localhost:12345/NameService \ + $@ diff --git a/devices/simple_dev/simple_dev.cpp b/devices/simple_dev/simple_dev.cpp new file mode 100644 index 0000000..eb2dfdd --- /dev/null +++ b/devices/simple_dev/simple_dev.cpp @@ -0,0 +1,45 @@ +#include +#include + +#include + +#include + +class My_device : public Distrio_Device_i { + public: + ::CORBA::Long id (void) + { + return my_id; + } + void id (::CORBA::Long id) + { + my_id = id; + } + private: + ::CORBA::Long my_id; +}; + +int main (int argc, char **argv) +{ + int ret = 0; + My_device *dev; + + if (init_corba (argc, argv)) + return -EINVAL; + + if (run_orb ()) + return -EINVAL; + + dev = new My_device (); + + if (register_device ("simpele device", dev)) { + ret = -EINVAL; + goto out; + } + + std::cout << "registered id: " << dev->id () << std::endl; + +out: + free (dev); + return ret; +} -- cgit v1.2.3