Communication for solid slow control.

Fork of sscm_comm by wimbeaumont Project

Committer:
wbeaumont
Date:
Tue Sep 23 19:21:20 2014 +0000
Revision:
0:2afae79ea9ca
Child:
1:288db0531b1f
functions to be used for the communication between the SOLID slow control module and C programs

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