Communication for solid slow control.
Fork of sscm_comm by
getVersion.cpp@7:6d3c421026df, 2014-10-05 (annotated)
- Committer:
- wbeaumont
- Date:
- Sun Oct 05 17:11:51 2014 +0000
- Revision:
- 7:6d3c421026df
dummy init functions added, version class added
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wbeaumont | 7:6d3c421026df | 1 | #include "getVersion.h" |
wbeaumont | 7:6d3c421026df | 2 | |
wbeaumont | 7:6d3c421026df | 3 | #define GETVERSION_SRC_VER "0.10" |
wbeaumont | 7:6d3c421026df | 4 | |
wbeaumont | 7:6d3c421026df | 5 | #include "mbed.h" |
wbeaumont | 7:6d3c421026df | 6 | |
wbeaumont | 7:6d3c421026df | 7 | #define NULL 0 |
wbeaumont | 7:6d3c421026df | 8 | |
wbeaumont | 7:6d3c421026df | 9 | void getVersion::get_dec_version( unsigned short hexversion , unsigned char & version, unsigned char& subversion) { |
wbeaumont | 7:6d3c421026df | 10 | subversion =(unsigned short)( hexversion & 0xFF); |
wbeaumont | 7:6d3c421026df | 11 | hexversion=hexversion >> 8; |
wbeaumont | 7:6d3c421026df | 12 | version =(unsigned char)( hexversion & 0xFF); |
wbeaumont | 7:6d3c421026df | 13 | } |
wbeaumont | 7:6d3c421026df | 14 | |
wbeaumont | 7:6d3c421026df | 15 | |
wbeaumont | 7:6d3c421026df | 16 | |
wbeaumont | 7:6d3c421026df | 17 | unsigned short getVersion::get_hex_version_nr(const char * vers){ |
wbeaumont | 7:6d3c421026df | 18 | float verf = strtof(vers,NULL); |
wbeaumont | 7:6d3c421026df | 19 | unsigned short version=(unsigned short) verf; |
wbeaumont | 7:6d3c421026df | 20 | verf=verf-version; |
wbeaumont | 7:6d3c421026df | 21 | version = version<<8; |
wbeaumont | 7:6d3c421026df | 22 | verf=verf*100; |
wbeaumont | 7:6d3c421026df | 23 | unsigned char sub=(unsigned char)verf; |
wbeaumont | 7:6d3c421026df | 24 | version=version| sub; |
wbeaumont | 7:6d3c421026df | 25 | return version; |
wbeaumont | 7:6d3c421026df | 26 | } |
wbeaumont | 7:6d3c421026df | 27 | |
wbeaumont | 7:6d3c421026df | 28 | |
wbeaumont | 7:6d3c421026df | 29 | |
wbeaumont | 7:6d3c421026df | 30 | |
wbeaumont | 7:6d3c421026df | 31 | |
wbeaumont | 7:6d3c421026df | 32 | |
wbeaumont | 7:6d3c421026df | 33 | unsigned short getVersion::getHdrVersion(){ |
wbeaumont | 7:6d3c421026df | 34 | if( hver == NULL) return get_hex_version_nr(GETVERSION_HDR_VER); |
wbeaumont | 7:6d3c421026df | 35 | else return get_hex_version_nr(hver); |
wbeaumont | 7:6d3c421026df | 36 | } |
wbeaumont | 7:6d3c421026df | 37 | |
wbeaumont | 7:6d3c421026df | 38 | unsigned short getVersion::getSrcVersion(){ |
wbeaumont | 7:6d3c421026df | 39 | if( sver == NULL) return get_hex_version_nr(GETVERSION_SRC_VER); |
wbeaumont | 7:6d3c421026df | 40 | else return get_hex_version_nr(sver); |
wbeaumont | 7:6d3c421026df | 41 | } |
wbeaumont | 7:6d3c421026df | 42 | |
wbeaumont | 7:6d3c421026df | 43 | |
wbeaumont | 7:6d3c421026df | 44 | unsigned short getVersion::getCompileTime(){ |
wbeaumont | 7:6d3c421026df | 45 | if ( ctime == NULL ) return 0; |
wbeaumont | 7:6d3c421026df | 46 | else return 0; |
wbeaumont | 7:6d3c421026df | 47 | } |
wbeaumont | 7:6d3c421026df | 48 | |
wbeaumont | 7:6d3c421026df | 49 | |
wbeaumont | 7:6d3c421026df | 50 | unsigned short getVersion::getCompileDate(){ |
wbeaumont | 7:6d3c421026df | 51 | if ( cdate == NULL ) return 0; |
wbeaumont | 7:6d3c421026df | 52 | else return 0; |
wbeaumont | 7:6d3c421026df | 53 | } |
wbeaumont | 7:6d3c421026df | 54 | |
wbeaumont | 7:6d3c421026df | 55 | unsigned short getVersion::getCompileYear(){ |
wbeaumont | 7:6d3c421026df | 56 | |
wbeaumont | 7:6d3c421026df | 57 | if ( cdate == NULL ) return 0; |
wbeaumont | 7:6d3c421026df | 58 | else return 0; |
wbeaumont | 7:6d3c421026df | 59 | } |