Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: src/command.cpp
- Revision:
- 25:8bcc8bea0e31
- Parent:
- 21:fe0ea1860c9f
- Child:
- 30:d8721a46ee03
diff -r 078f62c8d0ed -r 8bcc8bea0e31 src/command.cpp --- a/src/command.cpp Fri Jan 18 20:17:55 2019 +0000 +++ b/src/command.cpp Sun Jan 20 16:56:52 2019 +0000 @@ -503,164 +503,6 @@ // Update bufloc to the end of the command string bufloc = endofc; -} - -/************************************************************ -* Routine: validateChannel -* Input: channel -* Returns: none -* Description: -* Verifies that the channel number is a valid value between -* 1 and MAX_BOARDS, setting commandError if the check fails -**************************************************************/ -void validateChannel(int channel) -{ - if ((channel < 1) || (channel > MAX_BOARDS)) - { - sprintf(strbuf, " Invalid channel/board: %d (range is 1 - %d)", channel, MAX_BOARDS); - sendSerial(strbuf); - commandError = 1; - } -} - -/************************************************************ -* Routine: setPairVariable -* Input: *avariable,*bvariable -* Returns: none -* Description: -* sets a single channel variable -**************************************************************/ -void setPairVariable(float *avariable, float *bvariable, float limitlo, float limithi) -{ - if (!readback) - { - if (validateEntry(SET, limitlo, limithi, avariable)) - { - *bvariable = *avariable; - } - } -} - -/************************************************************ -* Routine: testMenu -* Input: none -* Returns: none -* Description: -* testMenu -**************************************************************/ -void testMenu(void) -{ - int ival; - int ch, dac; - //float fval; - unsigned int data; - - char commandString[80] = { 0 }; - - - commandError = 0; - parseCommand(GET, commandString); - - if (!strcmp(commandString, "LEDS")) // duh do I have to tell you? - { - //testLEDs(); - return; - } - - if (!strcmp(commandString, "SELFTEST")) - { - if ((rxbuf[bufloc] == 0x0D) || (rxbuf[bufloc] == 0)) - { - //ival = DEFAULT_SELFTEST_BOARDS; - ival = 0; - } - else - { - ival = getival(SET); - - if ((ival < 1) || (ival > MAX_BOARDS)) - { - sprintf(strbuf, " Invalid number of channels/boards (range is 1 - %d)", MAX_BOARDS); - sendSerial(strbuf); - commandError = 1; - return; - } - } - - //selfTest(ival); - return; - } - - if (!strcmp(commandString, "HVEN")) // high voltage enable - { - ival = getival(SET); - //hv_en = ival; - return; - } - - if (!strcmp(commandString, "DAC")) - { - ch = getival(SET); - getDelimiter(); - dac = getival(SET); - getDelimiter(); - data = getival(SET); - - validateChannel(ch); - if (commandError) return; - ch--; - - //sendData((unsigned int)ch, (unsigned int)dac, data); - sprintf(strbuf, " ch: %u dac: %u value: %u", ch + 1, dac, data); - sendSerial(strbuf); - return; - } - - if (!strcmp(commandString, "DINIT")) - { - //initDACs(); - return; - } - - if (!strcmp(commandString, "FINIT")) - { - //formatParameterSector(); - return; - } - - if (!strcmp(commandString, "CINIT")) - { - //initCalParameters(); - sprintf(strbuf, " All calibration parameters set to default values"); - sendSerial(strbuf); - return; - } - - if (strcmp(commandString, "")) - { - commandError = 1; - } -}//end void testMenu - -unsigned int checkRegisterCompatibility(unsigned int reg) -{ - int i; - - unsigned int boardsEnabled = 0; - - for (i = 0; i < MAX_BOARDS; i++) - { - //if (ch[i][reg].enabled == 1) - //{ - // Set the corresponding bit - boardsEnabled |= (1 << i); - //} - } - - // Invert the bits because 0 == enabled on the SPI write - boardsEnabled = ~boardsEnabled; - - return (boardsEnabled ^ boardEnableBits) & 0x000003FF; } /************************************************************ @@ -690,6 +532,25 @@ { menuRedraw(NO_PROMPT); } + else if (!strcmp(commandString, "MAXB")) + // MAXB is used to get/set the max_boards value. + // The integer value of max_boards is used to select the appropriate lookup table. + { + if (readback) + { + sprintf(strbuf, " %d", max_boards); + sendSerial(strbuf); + } + else if (running == 1) + { + sprintf(strbuf, " Parameters may not be updated while running!"); + sendSerial(strbuf); + } + else + { + max_boards = commandData; + } + } else if (!strcmp(commandString, "BRDS")) // BRDS is used to get/set the wr_out value. // The integer value of boardsActive is used to change wr_out via setBoardEnables(boardsActive). @@ -804,7 +665,7 @@ //setDacsToZeroVolts(); testing = FALSE; } - else if ((rxbuf[bufloc] > '0') && (rxbuf[bufloc] < '0' + MAX_BOARDS)) + else if ((rxbuf[bufloc] > '0') && (rxbuf[bufloc] < '0' + max_boards)) { ival = atoi(&rxbuf[bufloc]); //ival--; @@ -818,7 +679,7 @@ else { // Compare the board enable flags between registers - boardEnables = checkRegisterCompatibility(ival); + //boardEnables = checkRegisterCompatibility(ival); // If board enable flags match, change the register set if (boardEnables == 0) @@ -846,18 +707,6 @@ my12 = 0; //hv_en = OFF; } - else if(!strcmp(commandString, "TEST")) - { - if (running == 1) - { - sprintf(strbuf, " Parameters may not be updated while running!"); - sendSerial(strbuf); - } - else - { - testMenu(); - } - } else if(!strcmp(commandString, "CAL")) { if (running == 1)