Communication for solid slow control.

Fork of sscm_comm by wimbeaumont Project

Committer:
wbeaumont
Date:
Wed Sep 24 09:12:42 2014 +0000
Revision:
2:1f9887337a1b
Parent:
1:288db0531b1f
Child:
3:e9053e5e7175
added devnr , added rangecheck ( partially)

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