Communication for solid slow control.
Fork of sscm_comm by
sscm_comm.h@8:ff6ba217a089, 2014-10-07 (annotated)
- Committer:
- wbeaumont
- Date:
- Tue Oct 07 13:20:15 2014 +0000
- Revision:
- 8:ff6ba217a089
- Parent:
- 7:6d3c421026df
added fdatain ,fdataout in the structure not to be used for communication with the module
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 | 6:d9a96735d0fb | 9 | * v 3.00 added x, y , removed ch (replaced by x |
wbeaumont | 7:6d3c421026df | 10 | * v 3.01 corrected name SSCCM to SSCM |
wbeaumont | 7:6d3c421026df | 11 | * v 3.20 added version functions |
wbeaumont | 7:6d3c421026df | 12 | * v 3.30 version functions moved to getVersion class |
wbeaumont | 8:ff6ba217a089 | 13 | * v 3.40 added fdatain and fdataout for float communication |
wbeaumont | 1:288db0531b1f | 14 | */ |
wbeaumont | 0:2afae79ea9ca | 15 | |
wbeaumont | 8:ff6ba217a089 | 16 | #define SSCM_COMM_LIB_HDR_VERSION "3.40" |
wbeaumont | 7:6d3c421026df | 17 | |
wbeaumont | 7:6d3c421026df | 18 | #include "getVersion.h" |
wbeaumont | 0:2afae79ea9ca | 19 | |
wbeaumont | 0:2afae79ea9ca | 20 | |
wbeaumont | 7:6d3c421026df | 21 | namespace sscm_comm { |
wbeaumont | 0:2afae79ea9ca | 22 | //public : |
wbeaumont | 0:2afae79ea9ca | 23 | |
wbeaumont | 7:6d3c421026df | 24 | enum ssc_dev{ ADC=1, DAC=2, TEMP=3,SSCM=4}; |
wbeaumont | 0:2afae79ea9ca | 25 | typedef unsigned char u8; |
wbeaumont | 5:357fa8928d63 | 26 | typedef unsigned short u16; |
wbeaumont | 0:2afae79ea9ca | 27 | typedef struct { |
wbeaumont | 0:2afae79ea9ca | 28 | u8 module; // 1 char 0 --F |
wbeaumont | 0:2afae79ea9ca | 29 | u8 con; // 1 char 0--2 |
wbeaumont | 0:2afae79ea9ca | 30 | ssc_dev dev; // 2 char 01--03 |
wbeaumont | 2:1f9887337a1b | 31 | u8 devnr; |
wbeaumont | 6:d9a96735d0fb | 32 | char cmd[5]; // 4 char + \0 |
wbeaumont | 6:d9a96735d0fb | 33 | u8 ch; // identify the channel or register address for the firmware |
wbeaumont | 6:d9a96735d0fb | 34 | u8 x; // char 00 -- 32 x coordinate MPPC not used for the firmware ,so not coded in the string |
wbeaumont | 6:d9a96735d0fb | 35 | u8 y; // y coordinate MPPC not used for the communication to the SSCM y coordinate MPPC |
wbeaumont | 5:357fa8928d63 | 36 | u16 datain; // 2 char 0000 -- FFFF |
wbeaumont | 5:357fa8928d63 | 37 | u16 dataout;// 2 char 00 -- FF |
wbeaumont | 8:ff6ba217a089 | 38 | float fdatain ; |
wbeaumont | 8:ff6ba217a089 | 39 | float fdataout; |
wbeaumont | 4:66d1a4200f67 | 40 | u8 status; |
wbeaumont | 0:2afae79ea9ca | 41 | } ssc_cmd; |
wbeaumont | 0:2afae79ea9ca | 42 | |
wbeaumont | 0:2afae79ea9ca | 43 | const char CMDSTART= '$'; |
wbeaumont | 0:2afae79ea9ca | 44 | const char CMDSTOP= '#'; |
wbeaumont | 0:2afae79ea9ca | 45 | const char SEP= ';'; |
wbeaumont | 0:2afae79ea9ca | 46 | |
wbeaumont | 0:2afae79ea9ca | 47 | // decode the string sent to the uP to the original cmd structure , for the moment the input string is cleared |
wbeaumont | 0:2afae79ea9ca | 48 | // param input : input string at least char [30] |
wbeaumont | 0:2afae79ea9ca | 49 | // param ssc_cmd the cmd structure to be filled |
wbeaumont | 0:2afae79ea9ca | 50 | int decode_cmd(char* input, ssc_cmd * sc); |
wbeaumont | 0:2afae79ea9ca | 51 | |
wbeaumont | 0:2afae79ea9ca | 52 | |
wbeaumont | 0:2afae79ea9ca | 53 | // param output the string to be sent to the SSCM |
wbeaumont | 0:2afae79ea9ca | 54 | // param sc the cmd to be sent to the SSCM |
wbeaumont | 0:2afae79ea9ca | 55 | void encode_cmd ( char *output , ssc_cmd *sc); |
wbeaumont | 0:2afae79ea9ca | 56 | |
wbeaumont | 0:2afae79ea9ca | 57 | // to get info of the module nr , connector serial number for a given plane |
wbeaumont | 0:2afae79ea9ca | 58 | // param plane plane nr for which the cmd coordinates has to be known |
wbeaumont | 0:2afae79ea9ca | 59 | // param modulenr the module nr ( first nr in the cmd structure |
wbeaumont | 0:2afae79ea9ca | 60 | // param connr connector number ( 1 or 2) |
wbeaumont | 0:2afae79ea9ca | 61 | // param serailnr the serial nr of the board ( can be used for verification) . |
wbeaumont | 0:2afae79ea9ca | 62 | |
wbeaumont | 0:2afae79ea9ca | 63 | void getmodulecordinate(u8 plane, u8& modulenr, u8& connr ,u8& serialnr ); |
wbeaumont | 6:d9a96735d0fb | 64 | void get_mppc_dac_chnr(u8 plane, u8 x , u8 y, u8& ch,u8& modulenr, u8& connr ,u8&dacch, u8& serialnr ); |
wbeaumont | 6:d9a96735d0fb | 65 | void get_mppc_adc_chnr(u8 plane, u8 x , u8 y, u8& ch,u8& modulenr, u8& connr , u8& adcdevnr, u8& adcchnr , u8& serialnr ); |
wbeaumont | 2:1f9887337a1b | 66 | // check if ranges are correct |
wbeaumont | 2:1f9887337a1b | 67 | // v 1.20 only check ADC devnr range broadcast not supported |
wbeaumont | 2:1f9887337a1b | 68 | int check_ranges( ssc_cmd* sc ); |
wbeaumont | 7:6d3c421026df | 69 | |
wbeaumont | 7:6d3c421026df | 70 | // returns the version and sub version nr. |
wbeaumont | 7:6d3c421026df | 71 | // param hexversion : 16 bits MSB byt contains the version nr, LSB byte contains the subversion nr (hex) |
wbeaumont | 7:6d3c421026df | 72 | // param version : will be set to the version |
wbeaumont | 7:6d3c421026df | 73 | // param subversion : will be set to the subversion |
wbeaumont | 7:6d3c421026df | 74 | void get_dec_version( u16 hexversion , u8& version, u8& subversion); |
wbeaumont | 7:6d3c421026df | 75 | |
wbeaumont | 7:6d3c421026df | 76 | // reuse vesion class |
wbeaumont | 2:1f9887337a1b | 77 | |
wbeaumont | 7:6d3c421026df | 78 | class getsscmVersion: |
wbeaumont | 7:6d3c421026df | 79 | public getVersion |
wbeaumont | 0:2afae79ea9ca | 80 | |
wbeaumont | 7:6d3c421026df | 81 | { |
wbeaumont | 7:6d3c421026df | 82 | public: getsscmVersion() ; |
wbeaumont | 7:6d3c421026df | 83 | }; |
wbeaumont | 0:2afae79ea9ca | 84 | |
wbeaumont | 7:6d3c421026df | 85 | }; |
wbeaumont | 0:2afae79ea9ca | 86 | #endif |