Communication for solid slow control.

Fork of sscm_comm by wimbeaumont Project

Committer:
wbeaumont
Date:
Tue Sep 30 13:19:31 2014 +0000
Revision:
4:66d1a4200f67
Parent:
3:e9053e5e7175
Child:
5:357fa8928d63
added SSCM as device to be able to sent commands to the processor unit

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 2:1f9887337a1b 4 * v 1.01 inital published , tested
wbeaumont 3:e9053e5e7175 5 * v 1.20 added devnr, added range checking
wbeaumont 3:e9053e5e7175 6 * v 1.30 added \0 to cmd field
wbeaumont 4:66d1a4200f67 7 * v 1.40 added status in cmd , added SSCM as device
wbeaumont 1:288db0531b1f 8 */
wbeaumont 0:2afae79ea9ca 9
wbeaumont 4:66d1a4200f67 10 #define SSCM_COMM_LIB_HDR_VERSION "1.40"
wbeaumont 0:2afae79ea9ca 11
wbeaumont 0:2afae79ea9ca 12
wbeaumont 0:2afae79ea9ca 13 #define MAXCMDLLENGTH 256
wbeaumont 0:2afae79ea9ca 14 namespace sscm_comm {
wbeaumont 0:2afae79ea9ca 15 //public :
wbeaumont 0:2afae79ea9ca 16
wbeaumont 4:66d1a4200f67 17 enum ssc_dev{ ADC=1, DAC=2, TEMP=3,SSCCM=4};
wbeaumont 0:2afae79ea9ca 18 typedef unsigned char u8;
wbeaumont 0:2afae79ea9ca 19 typedef unsigned int u32;
wbeaumont 0:2afae79ea9ca 20 typedef struct {
wbeaumont 0:2afae79ea9ca 21 u8 module; // 1 char 0 --F
wbeaumont 0:2afae79ea9ca 22 u8 con; // 1 char 0--2
wbeaumont 0:2afae79ea9ca 23 ssc_dev dev; // 2 char 01--03
wbeaumont 2:1f9887337a1b 24 u8 devnr;
wbeaumont 3:e9053e5e7175 25 char cmd[5]; // 5 char + \0
wbeaumont 0:2afae79ea9ca 26 u8 ch; // 2 char 00 -- FF or register nr
wbeaumont 0:2afae79ea9ca 27 u32 datain; // 2 char 0000 -- FFFF
wbeaumont 0:2afae79ea9ca 28 u32 dataout;// 2 char 00 -- FF
wbeaumont 4:66d1a4200f67 29 u8 status;
wbeaumont 0:2afae79ea9ca 30 } ssc_cmd;
wbeaumont 0:2afae79ea9ca 31
wbeaumont 0:2afae79ea9ca 32 const char CMDSTART= '$';
wbeaumont 0:2afae79ea9ca 33 const char CMDSTOP= '#';
wbeaumont 0:2afae79ea9ca 34 const char SEP= ';';
wbeaumont 0:2afae79ea9ca 35
wbeaumont 0:2afae79ea9ca 36 // decode the string sent to the uP to the original cmd structure , for the moment the input string is cleared
wbeaumont 0:2afae79ea9ca 37 // param input : input string at least char [30]
wbeaumont 0:2afae79ea9ca 38 // param ssc_cmd the cmd structure to be filled
wbeaumont 0:2afae79ea9ca 39 int decode_cmd(char* input, ssc_cmd * sc);
wbeaumont 0:2afae79ea9ca 40
wbeaumont 0:2afae79ea9ca 41
wbeaumont 0:2afae79ea9ca 42 // param output the string to be sent to the SSCM
wbeaumont 0:2afae79ea9ca 43 // param sc the cmd to be sent to the SSCM
wbeaumont 0:2afae79ea9ca 44 void encode_cmd ( char *output , ssc_cmd *sc);
wbeaumont 0:2afae79ea9ca 45
wbeaumont 0:2afae79ea9ca 46 // to get info of the module nr , connector serial number for a given plane
wbeaumont 0:2afae79ea9ca 47 // param plane plane nr for which the cmd coordinates has to be known
wbeaumont 0:2afae79ea9ca 48 // param modulenr the module nr ( first nr in the cmd structure
wbeaumont 0:2afae79ea9ca 49 // param connr connector number ( 1 or 2)
wbeaumont 0:2afae79ea9ca 50 // param serailnr the serial nr of the board ( can be used for verification) .
wbeaumont 0:2afae79ea9ca 51
wbeaumont 0:2afae79ea9ca 52 void getmodulecordinate(u8 plane, u8& modulenr, u8& connr ,u8& serialnr );
wbeaumont 0:2afae79ea9ca 53
wbeaumont 2:1f9887337a1b 54 // check if ranges are correct
wbeaumont 2:1f9887337a1b 55 // v 1.20 only check ADC devnr range broadcast not supported
wbeaumont 2:1f9887337a1b 56 int check_ranges( ssc_cmd* sc );
wbeaumont 2:1f9887337a1b 57
wbeaumont 1:288db0531b1f 58 }
wbeaumont 0:2afae79ea9ca 59
wbeaumont 0:2afae79ea9ca 60
wbeaumont 0:2afae79ea9ca 61 #endif