Communication for solid slow control.

Fork of sscm_comm by wimbeaumont Project

Committer:
wbeaumont
Date:
Wed Sep 24 10:29:42 2014 +0000
Revision:
3:e9053e5e7175
Parent:
2:1f9887337a1b
Child:
4:66d1a4200f67
added /0 to cmd  ,  check connector range

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