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