Communication for solid slow control.

Fork of sscm_comm by wimbeaumont Project

Committer:
wbeaumont
Date:
Sun Oct 05 17:11:51 2014 +0000
Revision:
7:6d3c421026df
Parent:
6:d9a96735d0fb
Child:
8:ff6ba217a089
Child:
9:a68c382dea12
dummy init functions added, version class added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wbeaumont 0:2afae79ea9ca 1 #ifndef SSCM_COMM_H
wbeaumont 0:2afae79ea9ca 2 #define SSCM_COMM_H
wbeaumont 1:288db0531b1f 3 /*
wbeaumont 5:357fa8928d63 4 * v 1.01 inital published , tested
wbeaumont 5:357fa8928d63 5 * v 1.20 added devnr, added range checking
wbeaumont 5:357fa8928d63 6 * v 1.30 added \0 to cmd field
wbeaumont 5:357fa8928d63 7 * v 1.40 added status in cmd , added SSCM as device
wbeaumont 5:357fa8928d63 8 * v 2.00 corrected the type for data in data out
wbeaumont 6:d9a96735d0fb 9 * v 3.00 added x, y , removed ch (replaced by x
wbeaumont 7:6d3c421026df 10 * v 3.01 corrected name SSCCM to SSCM
wbeaumont 7:6d3c421026df 11 * v 3.20 added version functions
wbeaumont 7:6d3c421026df 12 * v 3.30 version functions moved to getVersion class
wbeaumont 1:288db0531b1f 13 */
wbeaumont 0:2afae79ea9ca 14
wbeaumont 7:6d3c421026df 15 #define SSCM_COMM_LIB_HDR_VERSION "3.31"
wbeaumont 7:6d3c421026df 16
wbeaumont 7:6d3c421026df 17 #include "getVersion.h"
wbeaumont 0:2afae79ea9ca 18
wbeaumont 0:2afae79ea9ca 19
wbeaumont 7:6d3c421026df 20 namespace sscm_comm {
wbeaumont 0:2afae79ea9ca 21 //public :
wbeaumont 0:2afae79ea9ca 22
wbeaumont 7:6d3c421026df 23 enum ssc_dev{ ADC=1, DAC=2, TEMP=3,SSCM=4};
wbeaumont 0:2afae79ea9ca 24 typedef unsigned char u8;
wbeaumont 5:357fa8928d63 25 typedef unsigned short u16;
wbeaumont 0:2afae79ea9ca 26 typedef struct {
wbeaumont 0:2afae79ea9ca 27 u8 module; // 1 char 0 --F
wbeaumont 0:2afae79ea9ca 28 u8 con; // 1 char 0--2
wbeaumont 0:2afae79ea9ca 29 ssc_dev dev; // 2 char 01--03
wbeaumont 2:1f9887337a1b 30 u8 devnr;
wbeaumont 6:d9a96735d0fb 31 char cmd[5]; // 4 char + \0
wbeaumont 6:d9a96735d0fb 32 u8 ch; // identify the channel or register address for the firmware
wbeaumont 6:d9a96735d0fb 33 u8 x; // char 00 -- 32 x coordinate MPPC not used for the firmware ,so not coded in the string
wbeaumont 6:d9a96735d0fb 34 u8 y; // y coordinate MPPC not used for the communication to the SSCM y coordinate MPPC
wbeaumont 5:357fa8928d63 35 u16 datain; // 2 char 0000 -- FFFF
wbeaumont 5:357fa8928d63 36 u16 dataout;// 2 char 00 -- FF
wbeaumont 4:66d1a4200f67 37 u8 status;
wbeaumont 0:2afae79ea9ca 38 } ssc_cmd;
wbeaumont 0:2afae79ea9ca 39
wbeaumont 0:2afae79ea9ca 40 const char CMDSTART= '$';
wbeaumont 0:2afae79ea9ca 41 const char CMDSTOP= '#';
wbeaumont 0:2afae79ea9ca 42 const char SEP= ';';
wbeaumont 0:2afae79ea9ca 43
wbeaumont 0:2afae79ea9ca 44 // decode the string sent to the uP to the original cmd structure , for the moment the input string is cleared
wbeaumont 0:2afae79ea9ca 45 // param input : input string at least char [30]
wbeaumont 0:2afae79ea9ca 46 // param ssc_cmd the cmd structure to be filled
wbeaumont 0:2afae79ea9ca 47 int decode_cmd(char* input, ssc_cmd * sc);
wbeaumont 0:2afae79ea9ca 48
wbeaumont 0:2afae79ea9ca 49
wbeaumont 0:2afae79ea9ca 50 // param output the string to be sent to the SSCM
wbeaumont 0:2afae79ea9ca 51 // param sc the cmd to be sent to the SSCM
wbeaumont 0:2afae79ea9ca 52 void encode_cmd ( char *output , ssc_cmd *sc);
wbeaumont 0:2afae79ea9ca 53
wbeaumont 0:2afae79ea9ca 54 // to get info of the module nr , connector serial number for a given plane
wbeaumont 0:2afae79ea9ca 55 // param plane plane nr for which the cmd coordinates has to be known
wbeaumont 0:2afae79ea9ca 56 // param modulenr the module nr ( first nr in the cmd structure
wbeaumont 0:2afae79ea9ca 57 // param connr connector number ( 1 or 2)
wbeaumont 0:2afae79ea9ca 58 // param serailnr the serial nr of the board ( can be used for verification) .
wbeaumont 0:2afae79ea9ca 59
wbeaumont 0:2afae79ea9ca 60 void getmodulecordinate(u8 plane, u8& modulenr, u8& connr ,u8& serialnr );
wbeaumont 6:d9a96735d0fb 61 void get_mppc_dac_chnr(u8 plane, u8 x , u8 y, u8& ch,u8& modulenr, u8& connr ,u8&dacch, u8& serialnr );
wbeaumont 6:d9a96735d0fb 62 void get_mppc_adc_chnr(u8 plane, u8 x , u8 y, u8& ch,u8& modulenr, u8& connr , u8& adcdevnr, u8& adcchnr , u8& serialnr );
wbeaumont 2:1f9887337a1b 63 // check if ranges are correct
wbeaumont 2:1f9887337a1b 64 // v 1.20 only check ADC devnr range broadcast not supported
wbeaumont 2:1f9887337a1b 65 int check_ranges( ssc_cmd* sc );
wbeaumont 7:6d3c421026df 66
wbeaumont 7:6d3c421026df 67 // returns the version and sub version nr.
wbeaumont 7:6d3c421026df 68 // param hexversion : 16 bits MSB byt contains the version nr, LSB byte contains the subversion nr (hex)
wbeaumont 7:6d3c421026df 69 // param version : will be set to the version
wbeaumont 7:6d3c421026df 70 // param subversion : will be set to the subversion
wbeaumont 7:6d3c421026df 71 void get_dec_version( u16 hexversion , u8& version, u8& subversion);
wbeaumont 7:6d3c421026df 72
wbeaumont 7:6d3c421026df 73 // reuse vesion class
wbeaumont 2:1f9887337a1b 74
wbeaumont 7:6d3c421026df 75 class getsscmVersion:
wbeaumont 7:6d3c421026df 76 public getVersion
wbeaumont 0:2afae79ea9ca 77
wbeaumont 7:6d3c421026df 78 {
wbeaumont 7:6d3c421026df 79 public: getsscmVersion() ;
wbeaumont 7:6d3c421026df 80 };
wbeaumont 0:2afae79ea9ca 81
wbeaumont 7:6d3c421026df 82 };
wbeaumont 0:2afae79ea9ca 83 #endif