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