![](/media/cache/profiles/bb1d545891bbbebcf457ed1cad5394f8.50x50_q85.png)
Solid experiment slow control.
Dependencies: AD5384 SWSPI S_SCTRL_SMlib T_adt7320 adc_ad9249 mbed sscm_comm
Fork of sscm by
main.cpp@6:dbc657396b7b, 2014-10-07 (annotated)
- Committer:
- NickRyder
- Date:
- Tue Oct 07 21:42:17 2014 +0000
- Revision:
- 6:dbc657396b7b
- Parent:
- 5:1be2795321e2
Tidied up.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wbeaumont | 0:dcd70d1b89b1 | 1 | #include "mbed.h" |
wbeaumont | 1:f792767b2223 | 2 | /* SOLID SM1 Slow Control firmware |
wbeaumont | 1:f792767b2223 | 3 | * |
wbeaumont | 1:f792767b2223 | 4 | |
wbeaumont | 1:f792767b2223 | 5 | * V 1.0? initial version release |
wbeaumont | 1:f792767b2223 | 6 | * v 1.11 version , added status field |
wbeaumont | 1:f792767b2223 | 7 | * v 1.13 corrected error in ADC register write |
wbeaumont | 2:d18b1a1643e8 | 8 | * v 1.14 added heartbeat off / in |
wbeaumont | 3:badf265a8898 | 9 | * v 1.20 added DAC |
wbeaumont | 3:badf265a8898 | 10 | * v 1.30 added Temperature probe support |
wbeaumont | 3:badf265a8898 | 11 | * v 1.31 bug correction ,for selecting the probe the devnr has to be used |
wbeaumont | 3:badf265a8898 | 12 | * v 1.35 added version read for software modules (comm, T , ADC , DAC SWSPI) |
wbeaumont | 3:badf265a8898 | 13 | * v 1.36 added ini1 ini2 srst commands for DAC |
wbeaumont | 3:badf265a8898 | 14 | * v 1.37 new get Version class |
wbeaumont | 1:f792767b2223 | 15 | */ |
wbeaumont | 0:dcd70d1b89b1 | 16 | |
wbeaumont | 3:badf265a8898 | 17 | #define VERSION "1.37" |
wbeaumont | 0:dcd70d1b89b1 | 18 | |
wbeaumont | 2:d18b1a1643e8 | 19 | |
wbeaumont | 3:badf265a8898 | 20 | #include "SWSPI_BI.h" |
wbeaumont | 0:dcd70d1b89b1 | 21 | #include "solid_sctrl_def.h" |
wbeaumont | 0:dcd70d1b89b1 | 22 | #include "S_SCTRL_SM1_PinDef.h" |
wbeaumont | 0:dcd70d1b89b1 | 23 | #include "S_SCTRL_SM1_hwfunct.h" |
wbeaumont | 2:d18b1a1643e8 | 24 | #include "AD9249.h" |
wbeaumont | 2:d18b1a1643e8 | 25 | #include "AD5384.h" |
wbeaumont | 3:badf265a8898 | 26 | #include "adt7320.h" |
wbeaumont | 3:badf265a8898 | 27 | #include "getVersion.h" |
wbeaumont | 0:dcd70d1b89b1 | 28 | |
wbeaumont | 0:dcd70d1b89b1 | 29 | #define DEBUGPF(x) printf((x)); |
wbeaumont | 0:dcd70d1b89b1 | 30 | |
wbeaumont | 0:dcd70d1b89b1 | 31 | |
wbeaumont | 0:dcd70d1b89b1 | 32 | #define MAXCMDLLENGTH 256 |
wbeaumont | 0:dcd70d1b89b1 | 33 | |
wbeaumont | 0:dcd70d1b89b1 | 34 | #include "sscm_comm.h" |
wbeaumont | 0:dcd70d1b89b1 | 35 | using namespace sscm_comm ; |
wbeaumont | 0:dcd70d1b89b1 | 36 | |
wbeaumont | 0:dcd70d1b89b1 | 37 | Serial pc(USBTX,USBRX); |
wbeaumont | 0:dcd70d1b89b1 | 38 | |
wbeaumont | 0:dcd70d1b89b1 | 39 | char cmdin[MAXCMDLLENGTH]; |
wbeaumont | 0:dcd70d1b89b1 | 40 | u8 cmdready; |
wbeaumont | 0:dcd70d1b89b1 | 41 | bool cmdstart=false; |
wbeaumont | 0:dcd70d1b89b1 | 42 | |
wbeaumont | 0:dcd70d1b89b1 | 43 | void pc_callback() { |
wbeaumont | 0:dcd70d1b89b1 | 44 | // Note: you need to actually read from the serial to clear the RX interrupt |
wbeaumont | 0:dcd70d1b89b1 | 45 | static unsigned char cnt; |
wbeaumont | 0:dcd70d1b89b1 | 46 | char c; |
NickRyder | 4:4f7a57fac239 | 47 | c = pc.getc(); |
NickRyder | 4:4f7a57fac239 | 48 | if (c == CMDSTART && !cmdready) { |
NickRyder | 4:4f7a57fac239 | 49 | cnt = 0; |
NickRyder | 4:4f7a57fac239 | 50 | cmdstart = true; |
NickRyder | 4:4f7a57fac239 | 51 | cmdready = false; |
NickRyder | 4:4f7a57fac239 | 52 | } |
NickRyder | 4:4f7a57fac239 | 53 | if (cmdstart) { |
NickRyder | 4:4f7a57fac239 | 54 | cmdin[cnt] = c; |
NickRyder | 4:4f7a57fac239 | 55 | cnt++; |
NickRyder | 4:4f7a57fac239 | 56 | if (c == CMDSTOP) { |
NickRyder | 4:4f7a57fac239 | 57 | cmdready = true; |
NickRyder | 4:4f7a57fac239 | 58 | } |
NickRyder | 4:4f7a57fac239 | 59 | } |
wbeaumont | 0:dcd70d1b89b1 | 60 | //printf("%c:",c ); |
wbeaumont | 0:dcd70d1b89b1 | 61 | } |
wbeaumont | 0:dcd70d1b89b1 | 62 | |
wbeaumont | 0:dcd70d1b89b1 | 63 | int main() { |
wbeaumont | 0:dcd70d1b89b1 | 64 | pc.attach(pc_callback); |
wbeaumont | 0:dcd70d1b89b1 | 65 | ssc_cmd cmd; |
NickRyder | 4:4f7a57fac239 | 66 | bool heartbeat = true; |
wbeaumont | 0:dcd70d1b89b1 | 67 | int i = 0; |
NickRyder | 4:4f7a57fac239 | 68 | HWlines hwl; |
NickRyder | 4:4f7a57fac239 | 69 | assignports(&hwl); |
NickRyder | 4:4f7a57fac239 | 70 | setdefault(hwl); |
wbeaumont | 3:badf265a8898 | 71 | // reuse getVesion |
NickRyder | 5:1be2795321e2 | 72 | getVersion gv(VERSION, VERSION, __TIME__, __DATE__); |
wbeaumont | 3:badf265a8898 | 73 | getVersion gvc; |
wbeaumont | 3:badf265a8898 | 74 | getsscmVersion gvsscm; |
NickRyder | 4:4f7a57fac239 | 75 | SWSPI spi(hwl.mosi[0], hwl.miso[0], hwl.sclk[0]); // mosi, miso, sclk |
NickRyder | 4:4f7a57fac239 | 76 | SWSPI spi2(hwl.mosi[1], hwl.miso[1], hwl.sclk[1]); // mosi, miso, sclk |
wbeaumont | 0:dcd70d1b89b1 | 77 | |
NickRyder | 4:4f7a57fac239 | 78 | SWSPI_BI spi_adc(hwl.msio[0], hwl.direction[0], hwl.stio_mo[0], |
NickRyder | 4:4f7a57fac239 | 79 | hwl.sclk[0]); // msio, dir , sclk |
NickRyder | 4:4f7a57fac239 | 80 | SWSPI_BI spi_adc2(hwl.msio[1], hwl.direction[1], hwl.stio_mo[1], |
NickRyder | 4:4f7a57fac239 | 81 | hwl.sclk[1]); // msio, dir , sclk |
wbeaumont | 0:dcd70d1b89b1 | 82 | // initalize ADC classes |
NickRyder | 4:4f7a57fac239 | 83 | AD9249 adc[2][2] = {AD9249(&spi_adc, hwl.csb1[0]), |
NickRyder | 4:4f7a57fac239 | 84 | AD9249(&spi_adc, hwl.csb2[0]), |
NickRyder | 4:4f7a57fac239 | 85 | AD9249(&spi_adc2, hwl.csb1[1]), |
NickRyder | 4:4f7a57fac239 | 86 | AD9249(&spi_adc2, hwl.csb2[1])}; |
NickRyder | 4:4f7a57fac239 | 87 | AD5384 dac[2][1] = {AD5384(&spi, hwl.dac_cs[0]), |
NickRyder | 4:4f7a57fac239 | 88 | AD5384(&spi2, hwl.dac_cs[1])}; |
wbeaumont | 0:dcd70d1b89b1 | 89 | |
NickRyder | 4:4f7a57fac239 | 90 | adt7320 temp[2][3] = {adt7320(&spi, hwl.t_cs[0]), |
NickRyder | 4:4f7a57fac239 | 91 | adt7320(&spi, hwl.tc_cs1[0]), |
NickRyder | 4:4f7a57fac239 | 92 | adt7320(&spi, hwl.tc_cs2[0]), |
NickRyder | 4:4f7a57fac239 | 93 | adt7320(&spi2, hwl.t_cs[1]), |
NickRyder | 4:4f7a57fac239 | 94 | adt7320(&spi2, hwl.tc_cs1[1]), |
NickRyder | 4:4f7a57fac239 | 95 | adt7320(&spi2, hwl.tc_cs2[1])}; |
NickRyder | 4:4f7a57fac239 | 96 | |
NickRyder | 4:4f7a57fac239 | 97 | pc.printf("\nSOLID SLOW CONTROL for SM1 version %s %s %s \n\r", VERSION, |
NickRyder | 4:4f7a57fac239 | 98 | __DATE__, __TIME__); |
NickRyder | 4:4f7a57fac239 | 99 | cmdready = false; |
wbeaumont | 0:dcd70d1b89b1 | 100 | while (1) { |
wbeaumont | 0:dcd70d1b89b1 | 101 | wait(0.5); |
wbeaumont | 3:badf265a8898 | 102 | char cmdoutstr[100]; |
wbeaumont | 0:dcd70d1b89b1 | 103 | if (cmdready) { |
NickRyder | 4:4f7a57fac239 | 104 | cmdready = false; |
NickRyder | 4:4f7a57fac239 | 105 | int decresult = decode_cmd(cmdin, &cmd); |
NickRyder | 4:4f7a57fac239 | 106 | printf("decode result = %d \n\r", decresult); |
NickRyder | 4:4f7a57fac239 | 107 | if (decresult) { |
NickRyder | 4:4f7a57fac239 | 108 | cmd.status = abs(decresult); |
NickRyder | 4:4f7a57fac239 | 109 | encode_cmd(cmdoutstr, &cmd); |
NickRyder | 4:4f7a57fac239 | 110 | continue; |
NickRyder | 4:4f7a57fac239 | 111 | } |
wbeaumont | 0:dcd70d1b89b1 | 112 | u8 do8; // dataout |
wbeaumont | 0:dcd70d1b89b1 | 113 | u16 do16; |
NickRyder | 4:4f7a57fac239 | 114 | cmd.status = 1; // use it for the moment as error handling , |
NickRyder | 4:4f7a57fac239 | 115 | switch (cmd.dev) { |
NickRyder | 4:4f7a57fac239 | 116 | case ADC: |
NickRyder | 4:4f7a57fac239 | 117 | cmd.status = 2; |
NickRyder | 4:4f7a57fac239 | 118 | pc.printf("ADC cmd = %s \n\r", cmd.cmd); |
NickRyder | 4:4f7a57fac239 | 119 | pc.printf("check now ranges %d %d \n\r", cmd.con, |
NickRyder | 4:4f7a57fac239 | 120 | cmd.devnr); |
NickRyder | 4:4f7a57fac239 | 121 | if (!strcmp(cmd.cmd, "spa1")) { |
NickRyder | 5:1be2795321e2 | 122 | adc[cmd.con - 1][cmd.devnr - 1].setPattern1(cmd.datain); |
NickRyder | 4:4f7a57fac239 | 123 | cmd.dataout = cmd.datain; |
NickRyder | 4:4f7a57fac239 | 124 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 125 | } |
NickRyder | 4:4f7a57fac239 | 126 | if (!strcmp(cmd.cmd, "spa2")) { |
NickRyder | 5:1be2795321e2 | 127 | adc[cmd.con - 1][cmd.devnr - 1].setPattern2(cmd.datain); |
NickRyder | 4:4f7a57fac239 | 128 | cmd.dataout = cmd.datain; |
NickRyder | 4:4f7a57fac239 | 129 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 130 | } |
NickRyder | 4:4f7a57fac239 | 131 | if (!strcmp(cmd.cmd, "rpa1")) { |
NickRyder | 5:1be2795321e2 | 132 | adc[cmd.con - 1][cmd.devnr - 1].readPattern1(do16); |
NickRyder | 4:4f7a57fac239 | 133 | cmd.dataout=do16; |
NickRyder | 4:4f7a57fac239 | 134 | cmd.status=0; |
NickRyder | 4:4f7a57fac239 | 135 | } |
NickRyder | 4:4f7a57fac239 | 136 | if (!strcmp(cmd.cmd, "rpa2")) { |
NickRyder | 5:1be2795321e2 | 137 | adc[cmd.con - 1][cmd.devnr - 1].readPattern2(do16); |
NickRyder | 4:4f7a57fac239 | 138 | cmd.dataout=do16; |
NickRyder | 4:4f7a57fac239 | 139 | cmd.status=0; |
NickRyder | 4:4f7a57fac239 | 140 | } |
NickRyder | 4:4f7a57fac239 | 141 | if (!strcmp(cmd.cmd, "rr08")) { |
NickRyder | 5:1be2795321e2 | 142 | adc[cmd.con - 1][cmd.devnr - 1].readReg8(cmd.ch, do8); |
NickRyder | 4:4f7a57fac239 | 143 | cmd.dataout = (u16) do8; |
NickRyder | 5:1be2795321e2 | 144 | cmd.status= 0 ; |
NickRyder | 4:4f7a57fac239 | 145 | } |
NickRyder | 4:4f7a57fac239 | 146 | if (!strcmp(cmd.cmd, "rr16")) { |
NickRyder | 5:1be2795321e2 | 147 | adc[cmd.con - 1][cmd.devnr - 1].readReg16(cmd.ch, do16); |
NickRyder | 5:1be2795321e2 | 148 | cmd.dataout = (u32) do16; |
NickRyder | 5:1be2795321e2 | 149 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 150 | } |
NickRyder | 4:4f7a57fac239 | 151 | if (!strcmp(cmd.cmd, "sr08")) { |
NickRyder | 5:1be2795321e2 | 152 | adc[cmd.con - 1][cmd.devnr - 1].setReg8(cmd.ch, (u8) cmd.datain); |
NickRyder | 4:4f7a57fac239 | 153 | cmd.dataout = cmd.datain; |
NickRyder | 4:4f7a57fac239 | 154 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 155 | } |
NickRyder | 4:4f7a57fac239 | 156 | if (!strcmp(cmd.cmd, "sr16")) { |
NickRyder | 5:1be2795321e2 | 157 | adc[cmd.con - 1][cmd.devnr - 1].setReg16(cmd.ch, (u16) cmd.datain); |
NickRyder | 4:4f7a57fac239 | 158 | cmd.dataout = cmd.datain; |
NickRyder | 5:1be2795321e2 | 159 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 160 | } |
NickRyder | 4:4f7a57fac239 | 161 | if (!strcmp(cmd.cmd, "ghrv")) { |
NickRyder | 5:1be2795321e2 | 162 | do16 = adc[cmd.con - 1][cmd.devnr - 1].getHdrVersion(); |
NickRyder | 4:4f7a57fac239 | 163 | cmd.dataout = do16; |
NickRyder | 4:4f7a57fac239 | 164 | cmd.status=0; |
NickRyder | 4:4f7a57fac239 | 165 | } |
NickRyder | 4:4f7a57fac239 | 166 | if (!strcmp(cmd.cmd, "gscv")) { |
NickRyder | 5:1be2795321e2 | 167 | do16 = adc[cmd.con - 1][cmd.devnr - 1].getSrcVersion(); |
NickRyder | 4:4f7a57fac239 | 168 | cmd.dataout = do16; |
NickRyder | 5:1be2795321e2 | 169 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 170 | } |
NickRyder | 4:4f7a57fac239 | 171 | if (!strcmp(cmd.cmd, "ini1")) { |
NickRyder | 5:1be2795321e2 | 172 | adc[cmd.con - 1][cmd.devnr - 1].init1(); |
NickRyder | 4:4f7a57fac239 | 173 | cmd.dataout = cmd.datain; |
NickRyder | 4:4f7a57fac239 | 174 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 175 | } |
NickRyder | 4:4f7a57fac239 | 176 | if (!strcmp(cmd.cmd, "ini2")) { |
NickRyder | 5:1be2795321e2 | 177 | adc[cmd.con - 1][cmd.devnr - 1].init2(); |
NickRyder | 4:4f7a57fac239 | 178 | cmd.dataout = cmd.datain; |
NickRyder | 4:4f7a57fac239 | 179 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 180 | } |
NickRyder | 4:4f7a57fac239 | 181 | break; |
wbeaumont | 2:d18b1a1643e8 | 182 | case DAC : |
NickRyder | 4:4f7a57fac239 | 183 | cmd.status = 2; |
NickRyder | 4:4f7a57fac239 | 184 | if (!strcmp(cmd.cmd, "sdac")) { |
NickRyder | 5:1be2795321e2 | 185 | dac[cmd.con - 1][cmd.devnr - 1].set_dac(cmd.ch, cmd.datain); |
NickRyder | 4:4f7a57fac239 | 186 | cmd.dataout = cmd.datain; |
NickRyder | 4:4f7a57fac239 | 187 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 188 | } |
NickRyder | 4:4f7a57fac239 | 189 | if (!strcmp(cmd.cmd, "rdac")) { |
NickRyder | 5:1be2795321e2 | 190 | do16=dac[cmd.con - 1][cmd.devnr - 1].get_dac(cmd.ch); |
NickRyder | 5:1be2795321e2 | 191 | cmd.dataout = do16; |
NickRyder | 5:1be2795321e2 | 192 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 193 | } |
NickRyder | 4:4f7a57fac239 | 194 | if (!strcmp(cmd.cmd, "ini1")) { |
NickRyder | 5:1be2795321e2 | 195 | dac[cmd.con - 1][cmd.devnr - 1].init1(); |
NickRyder | 4:4f7a57fac239 | 196 | cmd.dataout = cmd.datain; |
NickRyder | 4:4f7a57fac239 | 197 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 198 | } |
NickRyder | 4:4f7a57fac239 | 199 | if (!strcmp(cmd.cmd, "ini2")) { |
NickRyder | 5:1be2795321e2 | 200 | dac[cmd.con - 1][cmd.devnr - 1].init2(); |
NickRyder | 4:4f7a57fac239 | 201 | cmd.dataout = cmd.datain; |
NickRyder | 4:4f7a57fac239 | 202 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 203 | } |
NickRyder | 4:4f7a57fac239 | 204 | if (!strcmp(cmd.cmd, "srst")) { |
NickRyder | 5:1be2795321e2 | 205 | dac[cmd.con - 1][cmd.devnr - 1].soft_rst(); |
NickRyder | 4:4f7a57fac239 | 206 | cmd.dataout = cmd.datain; |
NickRyder | 4:4f7a57fac239 | 207 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 208 | } |
NickRyder | 4:4f7a57fac239 | 209 | if (!strcmp(cmd.cmd, "ghrv")) { |
NickRyder | 5:1be2795321e2 | 210 | do16 = dac[cmd.con - 1][cmd.devnr - 1].getHdrVersion(); |
NickRyder | 4:4f7a57fac239 | 211 | cmd.dataout = do16; |
NickRyder | 4:4f7a57fac239 | 212 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 213 | } |
NickRyder | 4:4f7a57fac239 | 214 | if (!strcmp(cmd.cmd, "gscv")) { |
NickRyder | 5:1be2795321e2 | 215 | do16 = dac[cmd.con - 1][cmd.devnr - 1].getSrcVersion(); |
NickRyder | 4:4f7a57fac239 | 216 | cmd.dataout = do16; |
NickRyder | 4:4f7a57fac239 | 217 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 218 | } |
NickRyder | 4:4f7a57fac239 | 219 | break; |
NickRyder | 4:4f7a57fac239 | 220 | case TEMP: |
NickRyder | 5:1be2795321e2 | 221 | cmd.status = 2; |
NickRyder | 4:4f7a57fac239 | 222 | if (!strcmp(cmd.cmd, "rtpd")) { |
NickRyder | 5:1be2795321e2 | 223 | do16 = temp[cmd.con - 1][cmd.devnr - 1].get_T(); |
NickRyder | 4:4f7a57fac239 | 224 | cmd.dataout = do16; |
NickRyder | 4:4f7a57fac239 | 225 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 226 | } |
NickRyder | 4:4f7a57fac239 | 227 | if (!strcmp(cmd.cmd, "gtid")) { |
NickRyder | 5:1be2795321e2 | 228 | do8 = temp[cmd.con - 1][cmd.devnr - 1].getId(); |
NickRyder | 4:4f7a57fac239 | 229 | cmd.dataout = do8; |
NickRyder | 4:4f7a57fac239 | 230 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 231 | } |
NickRyder | 4:4f7a57fac239 | 232 | if (!strcmp(cmd.cmd, "rtcr")) { |
NickRyder | 5:1be2795321e2 | 233 | do16 = temp[cmd.con - 1][cmd.devnr - 1].get_TcritSP(); |
NickRyder | 4:4f7a57fac239 | 234 | cmd.dataout = do16; |
NickRyder | 4:4f7a57fac239 | 235 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 236 | } |
NickRyder | 4:4f7a57fac239 | 237 | if (!strcmp(cmd.cmd, "stcr")) { |
NickRyder | 5:1be2795321e2 | 238 | temp[cmd.con - 1][cmd.devnr - 1].set_TcritSP(cmd.datain); |
NickRyder | 4:4f7a57fac239 | 239 | cmd.dataout = cmd.datain; |
NickRyder | 4:4f7a57fac239 | 240 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 241 | } |
NickRyder | 4:4f7a57fac239 | 242 | if (!strcmp(cmd.cmd, "ghrv")) { |
NickRyder | 5:1be2795321e2 | 243 | do16 = temp[cmd.con - 1][cmd.devnr - 1].getHdrVersion(); |
NickRyder | 4:4f7a57fac239 | 244 | cmd.dataout = do16; |
NickRyder | 5:1be2795321e2 | 245 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 246 | } |
NickRyder | 5:1be2795321e2 | 247 | if (!strcmp(cmd.cmd, "gscv")) { |
NickRyder | 5:1be2795321e2 | 248 | do16 = temp[cmd.con - 1][cmd.devnr - 1].getSrcVersion(); |
NickRyder | 4:4f7a57fac239 | 249 | cmd.dataout = do16; |
NickRyder | 5:1be2795321e2 | 250 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 251 | } |
NickRyder | 4:4f7a57fac239 | 252 | if (!strcmp(cmd.cmd, "ini1")) { |
NickRyder | 5:1be2795321e2 | 253 | temp[cmd.con - 1][cmd.devnr - 1].init1(); |
NickRyder | 4:4f7a57fac239 | 254 | cmd.dataout = cmd.datain; |
NickRyder | 4:4f7a57fac239 | 255 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 256 | } |
NickRyder | 4:4f7a57fac239 | 257 | if (!strcmp(cmd.cmd, "ini2")) { |
NickRyder | 5:1be2795321e2 | 258 | temp[cmd.con - 1][cmd.devnr - 1].init2(); |
NickRyder | 4:4f7a57fac239 | 259 | cmd.dataout = cmd.datain; |
NickRyder | 4:4f7a57fac239 | 260 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 261 | } |
NickRyder | 4:4f7a57fac239 | 262 | break; |
wbeaumont | 3:badf265a8898 | 263 | case SSCM: |
NickRyder | 4:4f7a57fac239 | 264 | cmd.status = 2; |
NickRyder | 4:4f7a57fac239 | 265 | if (!strcmp(cmd.cmd, "t_hb")) { |
NickRyder | 4:4f7a57fac239 | 266 | heartbeat = !heartbeat; |
NickRyder | 5:1be2795321e2 | 267 | cmd.status = 2; |
NickRyder | 4:4f7a57fac239 | 268 | } |
NickRyder | 4:4f7a57fac239 | 269 | if (!strcmp(cmd.cmd, "gmpv")) { |
NickRyder | 4:4f7a57fac239 | 270 | do16 = gv.getHdrVersion(); |
NickRyder | 4:4f7a57fac239 | 271 | cmd.dataout = do16; |
NickRyder | 5:1be2795321e2 | 272 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 273 | } |
NickRyder | 4:4f7a57fac239 | 274 | if (!strcmp(cmd.cmd, "gvhv")) { |
NickRyder | 4:4f7a57fac239 | 275 | do16 = gvc.getHdrVersion(); |
NickRyder | 4:4f7a57fac239 | 276 | cmd.dataout = do16; |
NickRyder | 4:4f7a57fac239 | 277 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 278 | } |
NickRyder | 4:4f7a57fac239 | 279 | if (!strcmp(cmd.cmd, "msnr")) { |
NickRyder | 4:4f7a57fac239 | 280 | do8 = get_serialnr(&hwl); |
NickRyder | 4:4f7a57fac239 | 281 | cmd.dataout = (u16) do8; |
NickRyder | 4:4f7a57fac239 | 282 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 283 | } |
NickRyder | 4:4f7a57fac239 | 284 | if (!strcmp(cmd.cmd, "gchv")) { |
NickRyder | 4:4f7a57fac239 | 285 | do16 = gvsscm.getHdrVersion(); |
NickRyder | 4:4f7a57fac239 | 286 | cmd.dataout = do16; |
NickRyder | 4:4f7a57fac239 | 287 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 288 | } |
NickRyder | 4:4f7a57fac239 | 289 | if (!strcmp(cmd.cmd, "gcsv")) { |
NickRyder | 4:4f7a57fac239 | 290 | do16 = gvsscm.getSrcVersion(); |
NickRyder | 4:4f7a57fac239 | 291 | cmd.dataout = do16; |
NickRyder | 4:4f7a57fac239 | 292 | cmd.status = 0; |
NickRyder | 4:4f7a57fac239 | 293 | } |
NickRyder | 4:4f7a57fac239 | 294 | break; |
NickRyder | 4:4f7a57fac239 | 295 | default: |
NickRyder | 5:1be2795321e2 | 296 | cmd.status = 1; |
wbeaumont | 1:f792767b2223 | 297 | break; |
NickRyder | 4:4f7a57fac239 | 298 | } // end switch |
NickRyder | 4:4f7a57fac239 | 299 | encode_cmd(cmdoutstr, &cmd); |
NickRyder | 4:4f7a57fac239 | 300 | pc.printf("%s", cmdoutstr); |
NickRyder | 4:4f7a57fac239 | 301 | } else {//end if cmdready |
NickRyder | 4:4f7a57fac239 | 302 | if (heartbeat) printf("%03d>%s\n\r", (i++ % 1000), cmdin); |
NickRyder | 4:4f7a57fac239 | 303 | } |
wbeaumont | 0:dcd70d1b89b1 | 304 | }// end while |
wbeaumont | 0:dcd70d1b89b1 | 305 | } |