diff options
Diffstat (limited to '')
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/Makefile.in | 25 | ||||
-rw-r--r-- | src/buffer.cpp | 2 | ||||
-rw-r--r-- | src/buffer.hpp | 2 | ||||
-rw-r--r-- | src/buffermanager.cpp | 2 | ||||
-rw-r--r-- | src/buffermanager.hpp | 2 | ||||
-rw-r--r-- | src/define_ultimate_fct.h | 2 | ||||
-rw-r--r-- | src/global.hpp | 2 | ||||
-rw-r--r-- | src/gloseq.cpp | 2 | ||||
-rw-r--r-- | src/gloseq.hpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 23 | ||||
-rw-r--r-- | src/main.hpp | 2 | ||||
-rw-r--r-- | src/optmanager.cpp | 23 | ||||
-rw-r--r-- | src/optmanager.hpp | 10 | ||||
-rw-r--r-- | src/regboost.cpp | 6 | ||||
-rw-r--r-- | src/regboost.hpp | 2 | ||||
-rw-r--r-- | src/reglinux.cpp | 2 | ||||
-rw-r--r-- | src/reglinux.hpp | 2 | ||||
-rw-r--r-- | src/rules.cpp | 2 | ||||
-rw-r--r-- | src/rules.hpp | 2 | ||||
-rw-r--r-- | src/ruleserror.hpp | 2 | ||||
-rw-r--r-- | src/serialboost.cpp | 22 | ||||
-rw-r--r-- | src/serialboost.hpp | 2 | ||||
-rw-r--r-- | src/seriallinux.cpp | 2 | ||||
-rw-r--r-- | src/seriallinux.hpp | 2 | ||||
-rw-r--r-- | src/serialprop.cpp | 2 | ||||
-rw-r--r-- | src/serialprop.hpp | 2 | ||||
-rw-r--r-- | src/symlink.cpp | 118 | ||||
-rw-r--r-- | src/symlink.hpp | 48 | ||||
-rw-r--r-- | src/ultimate.cpp | 2 | ||||
-rw-r--r-- | src/ultimate.hpp | 2 |
31 files changed, 274 insertions, 50 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index bf11705..26da352 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,8 +11,7 @@ ext_src += seriallinux.cpp #echo have not boost endif -aeroup_SOURCES = \ - main.cpp \ +aeroup_SOURCES = main.cpp \ ultimate.cpp \ serialprop.cpp \ optmanager.cpp \ @@ -20,9 +19,11 @@ aeroup_SOURCES = \ buffer.cpp \ buffermanager.cpp \ rules.cpp \ + symlink.cpp \ ${ext_src} aeroup_CPPFLAGS = -W -Wall -std=c++11 aeroup_LDFLAGS = #LIBS += #-DSERIAL_BOOST_LIB + diff --git a/src/Makefile.in b/src/Makefile.in index 25f19e1..51fb0db 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -95,8 +95,8 @@ am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am__aeroup_SOURCES_DIST = main.cpp ultimate.cpp serialprop.cpp \ optmanager.cpp gloseq.cpp buffer.cpp buffermanager.cpp \ - rules.cpp serialboost.cpp regboost.cpp reglinux.cpp \ - seriallinux.cpp + rules.cpp symlink.cpp serialboost.cpp regboost.cpp \ + reglinux.cpp seriallinux.cpp @BOOST_TRUE@am__objects_1 = aeroup-serialboost.$(OBJEXT) \ @BOOST_TRUE@ aeroup-regboost.$(OBJEXT) @BOOST_FALSE@am__objects_2 = aeroup-reglinux.$(OBJEXT) \ @@ -106,7 +106,7 @@ am_aeroup_OBJECTS = aeroup-main.$(OBJEXT) aeroup-ultimate.$(OBJEXT) \ aeroup-serialprop.$(OBJEXT) aeroup-optmanager.$(OBJEXT) \ aeroup-gloseq.$(OBJEXT) aeroup-buffer.$(OBJEXT) \ aeroup-buffermanager.$(OBJEXT) aeroup-rules.$(OBJEXT) \ - $(am__objects_3) + aeroup-symlink.$(OBJEXT) $(am__objects_3) aeroup_OBJECTS = $(am_aeroup_OBJECTS) aeroup_LDADD = $(LDADD) aeroup_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(aeroup_LDFLAGS) \ @@ -268,8 +268,7 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ ext_src = $(am__append_1) $(am__append_2) #echo have not boost -aeroup_SOURCES = \ - main.cpp \ +aeroup_SOURCES = main.cpp \ ultimate.cpp \ serialprop.cpp \ optmanager.cpp \ @@ -277,6 +276,7 @@ aeroup_SOURCES = \ buffer.cpp \ buffermanager.cpp \ rules.cpp \ + symlink.cpp \ ${ext_src} aeroup_CPPFLAGS = -W -Wall -std=c++11 @@ -395,6 +395,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aeroup-serialboost.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aeroup-seriallinux.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aeroup-serialprop.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aeroup-symlink.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aeroup-ultimate.Po@am__quote@ .cpp.o: @@ -523,6 +524,20 @@ aeroup-rules.obj: rules.cpp @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aeroup_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o aeroup-rules.obj `if test -f 'rules.cpp'; then $(CYGPATH_W) 'rules.cpp'; else $(CYGPATH_W) '$(srcdir)/rules.cpp'; fi` +aeroup-symlink.o: symlink.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aeroup_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT aeroup-symlink.o -MD -MP -MF $(DEPDIR)/aeroup-symlink.Tpo -c -o aeroup-symlink.o `test -f 'symlink.cpp' || echo '$(srcdir)/'`symlink.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aeroup-symlink.Tpo $(DEPDIR)/aeroup-symlink.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='symlink.cpp' object='aeroup-symlink.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aeroup_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o aeroup-symlink.o `test -f 'symlink.cpp' || echo '$(srcdir)/'`symlink.cpp + +aeroup-symlink.obj: symlink.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aeroup_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT aeroup-symlink.obj -MD -MP -MF $(DEPDIR)/aeroup-symlink.Tpo -c -o aeroup-symlink.obj `if test -f 'symlink.cpp'; then $(CYGPATH_W) 'symlink.cpp'; else $(CYGPATH_W) '$(srcdir)/symlink.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aeroup-symlink.Tpo $(DEPDIR)/aeroup-symlink.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='symlink.cpp' object='aeroup-symlink.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aeroup_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o aeroup-symlink.obj `if test -f 'symlink.cpp'; then $(CYGPATH_W) 'symlink.cpp'; else $(CYGPATH_W) '$(srcdir)/symlink.cpp'; fi` + aeroup-serialboost.o: serialboost.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(aeroup_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT aeroup-serialboost.o -MD -MP -MF $(DEPDIR)/aeroup-serialboost.Tpo -c -o aeroup-serialboost.o `test -f 'serialboost.cpp' || echo '$(srcdir)/'`serialboost.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/aeroup-serialboost.Tpo $(DEPDIR)/aeroup-serialboost.Po diff --git a/src/buffer.cpp b/src/buffer.cpp index 9c0ffec..d342c30 100644 --- a/src/buffer.cpp +++ b/src/buffer.cpp @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 28/12/2013 07:06:20 * Revision: none * Compiler: gcc diff --git a/src/buffer.hpp b/src/buffer.hpp index eae7080..538dfce 100644 --- a/src/buffer.hpp +++ b/src/buffer.hpp @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 28/12/2013 07:01:58 * Revision: none * Compiler: gcc diff --git a/src/buffermanager.cpp b/src/buffermanager.cpp index 72ae576..46d412f 100644 --- a/src/buffermanager.cpp +++ b/src/buffermanager.cpp @@ -22,7 +22,7 @@ * Description: take the parsed, tokenized lines and manage them. * send also some rules test * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 30/12/2013 12:12:46 * Revision: none * Compiler: gcc diff --git a/src/buffermanager.hpp b/src/buffermanager.hpp index 0b14781..2042329 100644 --- a/src/buffermanager.hpp +++ b/src/buffermanager.hpp @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 30/12/2013 12:07:43 * Revision: none * Compiler: gcc diff --git a/src/define_ultimate_fct.h b/src/define_ultimate_fct.h index 36fe030..85450ba 100644 --- a/src/define_ultimate_fct.h +++ b/src/define_ultimate_fct.h @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 30/12/2013 12:50:40 * Revision: none * Compiler: gcc diff --git a/src/global.hpp b/src/global.hpp index be20d98..da114c1 100644 --- a/src/global.hpp +++ b/src/global.hpp @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 20/12/2013 00:09:35 * Revision: none * Compiler: gcc diff --git a/src/gloseq.cpp b/src/gloseq.cpp index 370b522..7bdf70a 100644 --- a/src/gloseq.cpp +++ b/src/gloseq.cpp @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 27/12/2013 10:38:49 * Revision: none * Compiler: gcc diff --git a/src/gloseq.hpp b/src/gloseq.hpp index 3487f6b..83d80d0 100644 --- a/src/gloseq.hpp +++ b/src/gloseq.hpp @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 27/12/2013 10:40:44 * Revision: none * Compiler: gcc diff --git a/src/main.cpp b/src/main.cpp index 920a89b..68d919f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,7 +23,7 @@ * lib getopt needed this is for unix users * * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 20/12/2013 00:57:44 * Revision: none * Compiler: gcc @@ -80,6 +80,7 @@ main ( int argc, char *argv[] ) {"verify", required_argument, NULL, 'i'}, {"uploadGlo", required_argument, NULL, 'u'}, {"uploadGloc", no_argument, NULL, 'U'}, + {"symlink", no_argument, NULL, 'k'}, {"verbose", no_argument, NULL, 'v'}, {"thread", no_argument, NULL, 1 }, {"version", no_argument, &version, 1 }, @@ -88,7 +89,7 @@ main ( int argc, char *argv[] ) }; /* getopt_long stores the option index here. */ int option_index = 0; - c = getopt_long (argc, argv, "o:t:c:G:S:u:U:i:vh", + c = getopt_long (argc, argv, "o:t:c:G:S:u:U:k:i:vh", long_options, &option_index); /* Detect the end of the options. */ @@ -145,6 +146,10 @@ main ( int argc, char *argv[] ) manager.subRoutine(FLAG_UP_GLOC); break; + case 'k': + manager.addItemSymlink(optarg); + break; + case 'v': VERBOSE_AERO = true; break; @@ -196,6 +201,12 @@ main ( int argc, char *argv[] ) { return(EXIT_FAILURE); } + catch( Symlink::Bad_Symlink ) + { + cerr << "Error : Bad Symlink input\n" + << "'$man aeroup' section 'Improved management driver' may be help you\n"; + return(EXIT_FAILURE); + } catch(...) { //return(EXIT_FAILURE); @@ -221,14 +232,16 @@ aeroHelp() << " -c, --color=R,G,B,serialPort Send a color command on dev serialPort.\n" << " R,G,B can be hex (0x#), dec (#) value,\n" << " in range of [0-255] (8bit).\n" - << " -G, --getSerial=serialPort get serial number on dev serialPort, and print it to standard output.\n" + << " -G, --getSerial=serialPort Get serial number on dev serialPort, and print it to standard output.\n" << " -S, --setSerial=serialNumber,serialPort Set serialNumber on dev serialPort. the 32 bits serialNumber value\n" << " can be writen in hex (0x#) or dec (#).\n" << " -i, --verify=gloFile Verify that syntax glo file is valid.\n" - << " -u, --uploadGloc=gloFile,serialPort Verify that syntax glo file is valid, and if this is the case\n" + << " -k --symlink Return the serial name used as symlink of kernel name by udev.\n" + << " More info in the AeroUp man.\n" + << " -u, --uploadGloc=gloFile,serialPort Verify that syntax glo file is valid, and if this is the case,\n" << " upload it on dev serialPort.\n" << " -P, --thread Multithread mode, not implemented yet...\n" - << " -U, --uploadGloc=glocFile,serialPort not implemented yet...\n" + << " -U, --uploadGloc=glocFile,serialPort Not implemented yet...\n" << " -v Verbose mode.\n" << " -h, --help Print help.\n" << " --version Print version.\n\n" diff --git a/src/main.hpp b/src/main.hpp index d66dfff..351cd10 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 21/12/2013 03:56:20 * Revision: none * Compiler: gcc diff --git a/src/optmanager.cpp b/src/optmanager.cpp index 9ea843f..6a82787 100644 --- a/src/optmanager.cpp +++ b/src/optmanager.cpp @@ -27,7 +27,7 @@ * for the time being, the value is set to max. * we could test string before conversion. * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 23/12/2013 23:31:46 * Revision: none * Compiler: gcc @@ -112,6 +112,13 @@ OptManager::start() sendGetSerial(*iter); } + // Symlink + for (vector<string>::iterator iter = symlinkList.begin(); + iter != symlinkList.end(); ++iter) + { + sendSymlink(*iter); + } + // Set serial number for (vector<optSerial>::iterator iter = setSerialList.begin(); iter != setSerialList.end(); ++iter) @@ -179,6 +186,20 @@ OptManager::sendGetSerial( std::string port_name) } /* + * Method: OptManager :: sendSymlink + */ + void +OptManager::sendSymlink( std::string port_name) +{ + string sym_out; + Ultimate prop(port_name); + string serial_number = prop.getSerial(); + sym_out = Symlink::getSym(serial_number); + cout << sym_out << endl; + + +} +/* * Method: OptManager :: sendSetSerial */ void diff --git a/src/optmanager.hpp b/src/optmanager.hpp index 3252a91..2b89933 100644 --- a/src/optmanager.hpp +++ b/src/optmanager.hpp @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 23/12/2013 22:59:22 * Revision: none * Compiler: gcc @@ -39,9 +39,11 @@ #include <getopt.h> #include <string> #include <vector> + #include "global.hpp" #include "ultimate.hpp" #include "gloInterface.hpp" +#include "symlink.hpp" #define MAX_LEN_OPT 2 @@ -50,6 +52,7 @@ #define FLAG_UP_GLOC 0x4 #define FLAG_COLOR 0x8 #define FLAG_VERIFY 0x10 +#define FLAG_SYMLINK 0x20 /* * Class: OptManager @@ -74,6 +77,9 @@ class OptManager void addItemVerify(std::string glo_file) {verifyList.push_back(glo_file);} + void addItemSymlink(std::string port_name) + {symlinkList.push_back(port_name);} + void subRoutine(const short int FLAG); private: @@ -82,6 +88,7 @@ class OptManager void sendStart(std::string port_name); void sendColor(uint8_t red, uint8_t green, uint8_t blue, std::string port_name); void sendGetSerial(std::string port_name); + void sendSymlink(std::string port_name); void sendSetSerial(uint32_t i_serialNumber, std::string port); void sendVerify(std::string fileName); void sendUpGlo(std::string fileName, std::string port); @@ -134,6 +141,7 @@ class OptManager std::vector<std::string> verifyList; std::vector<optSerial> setSerialList; std::vector<std::string> getSerialList; + std::vector<std::string> symlinkList; // end of Structures and variables for opts containers }; /* ----- end of class OptManager ----- */ diff --git a/src/regboost.cpp b/src/regboost.cpp index bf3cf87..453bf08 100644 --- a/src/regboost.cpp +++ b/src/regboost.cpp @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 19/12/2013 05:22:37 * Revision: none * Compiler: gcc @@ -34,7 +34,7 @@ using namespace std; -using namespace boost; +//using namespace boost; RegBoost::RegBoost ( ) { @@ -47,7 +47,7 @@ RegBoost::isValidSyntax ( string &rline ) { for (int i = 0; i < REG_TAB_LEN; i++) { - if ( regex_match(rline.begin(), rline.end(), reg_tab[i]) ) + if ( boost::regex_match(rline.begin(), rline.end(), reg_tab[i]) ) { #ifdef DEBUG cout << rline << " -> ok" << endl; diff --git a/src/regboost.hpp b/src/regboost.hpp index 956be25..3fe5c80 100644 --- a/src/regboost.hpp +++ b/src/regboost.hpp @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 19/12/2013 05:23:16 * Revision: none * Compiler: gcc diff --git a/src/reglinux.cpp b/src/reglinux.cpp index 854d1b4..60d3f20 100644 --- a/src/reglinux.cpp +++ b/src/reglinux.cpp @@ -21,7 +21,7 @@ * * Description: Regex lib (linux version) * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 18/01/2014 01:16:04 * Revision: none * Compiler: gcc diff --git a/src/reglinux.hpp b/src/reglinux.hpp index 16ffd43..742adcc 100644 --- a/src/reglinux.hpp +++ b/src/reglinux.hpp @@ -21,7 +21,7 @@ * * Description: Regex lib (linux version) * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 18/01/2014 01:16:31 * Revision: none * Compiler: gcc diff --git a/src/rules.cpp b/src/rules.cpp index 741a2cd..c209fba 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 31/12/2013 18:33:14 * Revision: none * Compiler: gcc diff --git a/src/rules.hpp b/src/rules.hpp index a658fce..3c7c7e8 100644 --- a/src/rules.hpp +++ b/src/rules.hpp @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 31/12/2013 18:32:35 * Revision: none * Compiler: gcc diff --git a/src/ruleserror.hpp b/src/ruleserror.hpp index d84192d..3bf3d56 100644 --- a/src/ruleserror.hpp +++ b/src/ruleserror.hpp @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 06/01/2014 10:04:32 * Revision: none * Compiler: gcc diff --git a/src/serialboost.cpp b/src/serialboost.cpp index 821fed8..bd55630 100644 --- a/src/serialboost.cpp +++ b/src/serialboost.cpp @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 20/12/2013 00:06:15 * Revision: none * Compiler: gcc @@ -32,7 +32,7 @@ #include <serialboost.hpp> using namespace std; -using namespace boost; +//using namespace boost; /* @@ -53,7 +53,7 @@ SerialBoost::SerialBoost ( std::string port_name ): throw; } - typedef asio::serial_port_base asio_serial; + typedef boost::asio::serial_port_base asio_serial; port.set_option(asio_serial::baud_rate(19200)); port.set_option(asio_serial::flow_control(asio_serial::flow_control::none)); port.set_option(asio_serial::parity( asio_serial::parity::none)); @@ -88,7 +88,7 @@ SerialBoost::~SerialBoost ( ) void SerialBoost::sendChar(char c) { - port.write_some(asio::buffer(&c, 1)); + port.write_some(boost::asio::buffer(&c, 1)); } /* @@ -100,7 +100,7 @@ SerialBoost::sendChar(char c) void SerialBoost::sendChar(unsigned char c) { - port.write_some(asio::buffer(&c, 1)); + port.write_some(boost::asio::buffer(&c, 1)); } @@ -117,7 +117,7 @@ SerialBoost::sendChar(unsigned char c) void SerialBoost::sendString(char* s, int nb_char) { - port.write_some(asio::buffer(s, nb_char)); + port.write_some(boost::asio::buffer(s, nb_char)); } /* @@ -129,7 +129,7 @@ SerialBoost::sendString(char* s, int nb_char) void SerialBoost::sendString(unsigned char* s, int nb_char) { - port.write_some(asio::buffer(s, nb_char)); + port.write_some(boost::asio::buffer(s, nb_char)); } /* @@ -141,7 +141,7 @@ SerialBoost::sendString(unsigned char* s, int nb_char) void SerialBoost::sendString(const char* s, int nb_char) { - port.write_some(asio::buffer(s, nb_char)); + port.write_some(boost::asio::buffer(s, nb_char)); } /* @@ -153,7 +153,7 @@ SerialBoost::sendString(const char* s, int nb_char) void SerialBoost::sendString(string s) { - port.write_some(asio::buffer(s.c_str(),s.size())); + port.write_some(boost::asio::buffer(s.c_str(),s.size())); } /** @@ -173,7 +173,7 @@ SerialBoost::readLine() string result; for(;;) { - asio::read(port, asio::buffer(&c,1)); + boost::asio::read(port, boost::asio::buffer(&c,1)); switch(c) { case '\r': @@ -194,7 +194,7 @@ SerialBoost::readLine() */ void SerialBoost::getString(char* s, int nb_char) { - asio::read(port, asio::buffer(s, nb_char)); + boost::asio::read(port, boost::asio::buffer(s, nb_char)); } diff --git a/src/serialboost.hpp b/src/serialboost.hpp index 0b5dd9d..18aa1a6 100644 --- a/src/serialboost.hpp +++ b/src/serialboost.hpp @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 20/12/2013 00:06:28 * Revision: none * Compiler: gcc diff --git a/src/seriallinux.cpp b/src/seriallinux.cpp index 27ba784..9d20618 100644 --- a/src/seriallinux.cpp +++ b/src/seriallinux.cpp @@ -22,7 +22,7 @@ * Description: Serial lib linux (termios version) * used if haven't boost * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 17/01/2014 03:31:32 * Revision: none * Compiler: gcc diff --git a/src/seriallinux.hpp b/src/seriallinux.hpp index 82b7475..b515725 100644 --- a/src/seriallinux.hpp +++ b/src/seriallinux.hpp @@ -22,7 +22,7 @@ * Description: Serial lib linux (termios version) * used if haven't boost * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 17/01/2014 03:31:35 * Revision: none * Compiler: gcc diff --git a/src/serialprop.cpp b/src/serialprop.cpp index 309a75c..bbcef9a 100644 --- a/src/serialprop.cpp +++ b/src/serialprop.cpp @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 21/12/2013 01:39:53 * Revision: none * Compiler: gcc diff --git a/src/serialprop.hpp b/src/serialprop.hpp index d335c46..a78a0b2 100644 --- a/src/serialprop.hpp +++ b/src/serialprop.hpp @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 19/12/2013 23:25:14 * Revision: none * Compiler: gcc diff --git a/src/symlink.cpp b/src/symlink.cpp new file mode 100644 index 0000000..2d1216a --- /dev/null +++ b/src/symlink.cpp @@ -0,0 +1,118 @@ +/* + * Filename: Symlink.cpp + * + * Description: Return a beautiful Symlink for udev + * + * Version: 0.3.0.1 + * Created: 19/01/2014 14:51:05 + * Revision: none + * Compiler: gcc + * + * Author: BARATTERO Laurent, laurentba<at>larueluberlu.net + * Organization: La rue Luberlu + */ + +#include "symlink.hpp" + +static uint32_t serialNumber; +static uint8_t id_prob; +static uint8_t num; +static std::stringstream ss; + +const uint8_t BALL = 0x62; // 'b' +const uint8_t STAFF = 0x73; // 's' +const uint8_t CLUB = 0x63; // 'c' +const uint8_t POI = 0x70; // 'p' +const uint32_t PROB_MASK = 0x0000ff00; +const uint32_t NUM_MASK = 0x000000ff; + + /* + * Name: Symlink::getSym + * Description: return Symlink + */ + std::string +Symlink::getSym(std::string serial_str) +{ + /* test entry */ + if(EOF == sscanf(serial_str.c_str(), "%d", &serialNumber)) + { + throw Symlink::Bad_Symlink(); + } + //if (serialNumber > 0xffffffff) + if (serialNumber > 0x0) + { + throw Symlink::Bad_Symlink(); + } + + ss << std::hex << serial_str ; + ss >> serialNumber; + + // comment + //std::cout << serial_str; + //std::cout << serialNumber; + + if((serialNumber & 0xffff0000) != 0) + Symlink::badSerNum(); + + id_prob = ((PROB_MASK & serialNumber) >> 8 ); + num = (NUM_MASK & serialNumber); + + + ss << num; + std::string x; + ss >> x; + std::cout << x; + + // now we use serial_str for output + serial_str = Symlink::whatProp(id_prob); + serial_str += std::to_string(num); + + //std::cout << serial_str; + + return serial_str; +} + + + /* + * Name: Symlink::whatProp + * Description: send error ( for future) + */ + void +Symlink::badSerNum() +{ + throw Symlink::Bad_Symlink(); + +} + + + /* + * Name: Symlink::whatProp + * Description: addr to symlink + */ + std::string +Symlink::whatProp(uint8_t id) +{ + switch (id) + { + case BALL: + return "Ball"; + break; + + case STAFF: + return "Staff"; + break; + + case CLUB: + return "Club"; + break; + + case POI: + return "Poi"; + break; + + default: + //UdevLink::badSerNum(); + return "AeroProb"; + break; + } /* ----- end switch ----- */ +} diff --git a/src/symlink.hpp b/src/symlink.hpp new file mode 100644 index 0000000..6bfe035 --- /dev/null +++ b/src/symlink.hpp @@ -0,0 +1,48 @@ +/* + * Filename: Symlink.hpp + * + * Description: Return a beautiful Symlink for udev + * + * Version: 0.3.0.1 + * Created: 19/01/2014 14:51:08 + * Revision: none + * Compiler: gcc + * + * Author: BARATTERO Laurent, laurentba<at>larueluberlu.net + * Organization: La rue Luberlu + */ + +#ifndef Symlink_INC +#define Symlink_INC + +#include <stdlib.h> +#include <string> +#include <exception> +#include <sstream> +#include <unistd.h> +#include <iostream> + +/* + * Name: Symlink + * Description: Symlink declaration + */ +namespace Symlink +{ +// extern uint16_t BALL; +// extern uint16_t STAFF; +// extern uint16_t CLUB; +// extern uint16_t POI; + + + +// const uint32_t PROB_MASK; +// const uint32_t NUM_MASK; + + std::string getSym(std::string serial_str); + std::string whatProp(uint8_t id); + void badSerNum(); + + class Bad_Symlink{}; +} + +#endif /* ----- #ifndef symlink_INC ----- */ diff --git a/src/ultimate.cpp b/src/ultimate.cpp index 63df51e..0293ea2 100644 --- a/src/ultimate.cpp +++ b/src/ultimate.cpp @@ -21,7 +21,7 @@ * * Description: Interface for Ultimate props * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 19/12/2013 20:28:22 * Revision: none * Compiler: gcc diff --git a/src/ultimate.hpp b/src/ultimate.hpp index 355bd14..77c5055 100644 --- a/src/ultimate.hpp +++ b/src/ultimate.hpp @@ -21,7 +21,7 @@ * * Description: * - * Version: 0.2 + * Version: 0.3.0.1 * Created: 19/12/2013 20:28:34 * Revision: none * Compiler: gcc |