Communication for solid slow control.

Fork of sscm_comm by wimbeaumont Project

Files at this revision

API Documentation at this revision

Comitter:
wbeaumont
Date:
Sun Oct 05 17:11:51 2014 +0000
Parent:
6:d9a96735d0fb
Child:
8:ff6ba217a089
Child:
9:a68c382dea12
Commit message:
dummy init functions added, version class added

Changed in this revision

getVersion.cpp Show annotated file Show diff for this revision Revisions of this file
getVersion.h Show annotated file Show diff for this revision Revisions of this file
sscm_comm.cpp Show annotated file Show diff for this revision Revisions of this file
sscm_comm.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/getVersion.cpp	Sun Oct 05 17:11:51 2014 +0000
@@ -0,0 +1,59 @@
+#include "getVersion.h"
+
+#define GETVERSION_SRC_VER  "0.10"
+
+#include "mbed.h"
+
+#define NULL 0
+
+void getVersion::get_dec_version( unsigned short  hexversion , unsigned char & version, unsigned char& subversion) {
+        subversion =(unsigned short)(  hexversion & 0xFF);
+        hexversion=hexversion >> 8; 
+        version =(unsigned char)(  hexversion & 0xFF);
+    }
+
+
+
+unsigned short  getVersion::get_hex_version_nr(const char * vers){    
+    float verf = strtof(vers,NULL);
+    unsigned short version=(unsigned short) verf;
+    verf=verf-version;
+    version = version<<8;
+    verf=verf*100;
+    unsigned char  sub=(unsigned char)verf;
+    version=version| sub;
+    return version;
+}   
+
+
+
+
+
+
+unsigned short getVersion::getHdrVersion(){ 
+    if( hver == NULL) return  get_hex_version_nr(GETVERSION_HDR_VER);
+    else return get_hex_version_nr(hver);
+    }
+
+    unsigned short getVersion::getSrcVersion(){
+          if( sver == NULL) return  get_hex_version_nr(GETVERSION_SRC_VER);
+    else return get_hex_version_nr(sver);
+ }
+
+
+unsigned short getVersion::getCompileTime(){
+    if ( ctime == NULL ) return 0;
+    else return 0;
+}
+    
+
+unsigned short getVersion::getCompileDate(){
+    if ( cdate == NULL ) return 0;
+    else return 0;
+}
+
+unsigned short getVersion::getCompileYear(){
+    
+    if ( cdate == NULL ) return 0;
+    else return 0;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/getVersion.h	Sun Oct 05 17:11:51 2014 +0000
@@ -0,0 +1,54 @@
+#ifndef GETVERSION_H
+#define GETVERSION_H
+
+/*  getVersion class
+ *  to get version number ( compile date etc)  of a module
+ *  to be used to verify module version used by a main program 
+ *  can be used as inheritance class
+ *  written for the SOLID SM1 control module firmware 
+ *
+ * author  Wim.Beaumont@Uantwerpen.be
+ * (C)  Universiteit Antwerpen  5 October 2014 
+ *
+ * version history 
+ * v 0.10  intial development vesion
+ *  
+ */
+
+#define GETVERSION_HDR_VER  "0.10"
+
+
+
+class getVersion {
+ 
+ const char* hver;
+ const char* sver;
+ const char* ctime;
+ const char* cdate;
+ 
+ 
+public:
+    getVersion(const char* ver_h,const char* ver_s=0, const char* time=0,const char* date=0) {
+        sver=ver_s; hver=ver_h; ctime=time;cdate=date;
+        } ;
+    getVersion(){sver=0; hver=0; ctime=0;cdate=0;};     
+    
+    // returns the version number of hdr of the  module in hex code     
+    unsigned short getHdrVersion(); 
+    // returns the version number of the  src of the  module  in hex code     
+    unsigned short getSrcVersion(); 
+    // returns the compile time  using __TIME__    in hex code 0xHHMM ver 0.1  returns always 0 
+    unsigned short getCompileTime();
+    // returns the compile date    using __DATE__     0xMMDD ver 0.1  returns always 0 
+    unsigned short getCompileDate();
+    // returns the compile year   using __DATE__  2014  0x140C ver 0.1  returns always 0 
+    unsigned short getCompileYear();
+    // takes a version nr of the type  "2.32"  and convert it to a hex nr   0x0220   ( 0x20== 33 dec) 
+    void get_dec_version( unsigned short  hexversion , unsigned char & version, unsigned char& subversion);
+    // translate  "2.32"  to 0x0222 
+    unsigned short  get_hex_version_nr(const char * vers);
+    
+};    
+
+
+#endif
\ No newline at end of file
--- a/sscm_comm.cpp	Fri Oct 03 14:15:25 2014 +0000
+++ b/sscm_comm.cpp	Sun Oct 05 17:11:51 2014 +0000
@@ -8,7 +8,7 @@
 #include "sscm_comm.h"
 
 
-#define SSCM_LIB_SRC_VERSION "3.01"
+#define SSCM_COMM_LIB_SRC_VERSION "3.31"
 
 using namespace sscm_comm;
 
@@ -81,18 +81,21 @@
     // to be implemented  
     modulenr=0;
 }    
-    
- char libversion_com[150]={'e','m','p','t','y','\0'};
 
 
-char*   get_sscm_com_version(){
-    sprintf(libversion_com,"sscmhw namespacelib versions  src : %s header:  %s date:%s %s \n\r",
-            SSCM_LIB_SRC_VERSION,SSCM_COMM_LIB_HDR_VERSION ,  __DATE__,__TIME__);
-    return libversion_com;
-    
-}   
+/*
 
-   
+u16 sscm_comm::getSrcVersion(){
+    return get_hex_version_nr(SSCM_COMM_LIB_SRC_VERSION );   
+}
 
+u16 sscm_comm::getHdrVersion(){
+       return get_hex_version_nr(SSCM_COMM_LIB_HDR_VERSION );   
+}    
+*/ 
 void sscm_comm::get_mppc_dac_chnr(u8 plane,  u8 x , u8 y, u8& ch,u8& modulenr, u8& connr ,u8&dacch, u8& serialnr  ) {};
 void sscm_comm::get_mppc_adc_chnr(u8 plane,  u8 x , u8 y, u8& ch,u8& modulenr, u8& connr , u8& adcdevnr, u8& adcchnr , u8& serialnr  ){};
+
+
+
+sscm_comm::getsscmVersion::getsscmVersion():getVersion( SSCM_COMM_LIB_HDR_VERSION,SSCM_COMM_LIB_SRC_VERSION, __TIME__, __DATE__){};
--- a/sscm_comm.h	Fri Oct 03 14:15:25 2014 +0000
+++ b/sscm_comm.h	Sun Oct 05 17:11:51 2014 +0000
@@ -7,16 +7,20 @@
  *  v 1.40 added status in cmd , added SSCM as device 
  *  v 2.00 corrected the type for data in data out
  *  v 3.00 added x, y , removed ch (replaced by x 
+ *  v 3.01 corrected name SSCCM to SSCM 
+ *  v 3.20 added version functions
+ *  v 3.30 version functions moved to getVersion class 
  */
 
-#define SSCM_COMM_LIB_HDR_VERSION "3.00"
+#define SSCM_COMM_LIB_HDR_VERSION "3.31"
+
+#include "getVersion.h"
 
 
-#define MAXCMDLLENGTH 256
-namespace sscm_comm {
+namespace sscm_comm    {
 //public :    
 
-enum ssc_dev{ ADC=1, DAC=2, TEMP=3,SSCCM=4};
+enum ssc_dev{ ADC=1, DAC=2, TEMP=3,SSCM=4};
 typedef  unsigned char u8;
 typedef  unsigned short u16;
 typedef struct {
@@ -59,10 +63,21 @@
 // check if ranges are correct 
 // v 1.20  only check ADC devnr range broadcast not supported
 int  check_ranges( ssc_cmd* sc );
-// returns a string with the hdr and src version nr and compile time
-char* get_sscm_com_version();
+
+// returns the version and sub version nr.  
+// param hexversion  : 16 bits   MSB byt contains the version nr, LSB byte contains the subversion nr (hex) 
+// param version  : will  be set to the version 
+// param subversion : will be set to the subversion 
+void get_dec_version( u16 hexversion , u8& version, u8& subversion);
+
+// reuse vesion class
 
-}
+class getsscmVersion:
+     public  getVersion
 
+    { 
+    public: getsscmVersion()   ;
+};
 
+};
 #endif