Commit 05817aa6 authored by Peter Zumbruch's avatar Peter Zumbruch
Browse files

- changed output format

- refactored apfelApiSubCommandsFooter to apiSubCommandsFooter,
   and moved it to api.c
parent 4b92ae6d
......@@ -473,14 +473,14 @@ int16_t apfelReadDac_Inline(char port, uint8_t pinSetIndex, uint8_t sideSelectio
}
#endif
// check validity for correct header (10) and trailing bits (111)
/* Error */
if ( APFEL_READ_CHECK_VALUE != (value & APFEL_READ_CHECK_MASK))
{
if (0 == quiet)
{
CommunicationError_p(ERRA, -1, 1,
PSTR("|port|pinSet|side|chipId|dac:|%c|%x|%x|%x|%x|: validity check failed, raw value:0x%x"), port, pinSetIndex,
PSTR("port:%c pinSet:%x side:%x chip:%x dac:%x - read validity check failed, raw value:0x%x"), port, pinSetIndex,
sideSelection, chipId, dacNr, value);
/* Error */
}
return -10;
}
......@@ -492,10 +492,10 @@ int16_t apfelReadDac_Inline(char port, uint8_t pinSetIndex, uint8_t sideSelectio
createExtendedSubCommandReceiveResponseHeader(ptr_uartStruct, commandKeyNumber_APFEL,
apfelApiCommandKeyNumber_DAC, apfelApiCommandKeywords);
snprintf_P(uart_message_string, BUFFER_SIZE - 1, PSTR("%s|port|pinSet|side|chipId|dac:|%c|%x|%x|%x|%x| 0x"),
snprintf_P(uart_message_string, BUFFER_SIZE - 1, PSTR("%sport:%c pinSet:%x side:%x chip:%x dac:%x "),
uart_message_string, port, pinSetIndex, sideSelection, chipId, dacNr);
apiShowValue(uart_message_string, &value, apiVarType_UINT16);
apfelApiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
apiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
}
return value;
}
......@@ -586,12 +586,9 @@ void apfelListIds_Inline(char port, uint8_t pinSetIndex, uint8_t sideSelection,
{
createExtendedSubCommandReceiveResponseHeader(ptr_uartStruct, commandKeyNumber_APFEL,
apfelApiCommandKeyNumber_LIST, apfelApiCommandKeywords);
snprintf_P(uart_message_string, BUFFER_SIZE - 1, PSTR("%s|port|pinSet|side|chipId |%c|%x|%x|%x|"),
snprintf_P(uart_message_string, BUFFER_SIZE - 1, PSTR("%sport:%c pinSet:%x side:%x chip:%x "),
uart_message_string, port, pinSetIndex, sideSelection, chipId);
if (all)
{
strncat_P(uart_message_string, (result[chipId >> 3] & 1 << (chipId % 8 )) ? PSTR(" yes") : PSTR(" no"), BUFFER_SIZE - 1);
}
strncat_P(uart_message_string, (result[chipId >> 3] & 1 << (chipId % 8 )) ? PSTR("yes") : PSTR("no"), BUFFER_SIZE - 1);
UART0_Send_Message_String_p(NULL, 0);
}
}
......@@ -640,7 +637,7 @@ void apfelApi_Inline(void)
createReceiveHeader(ptr_uartStruct, uart_message_string, BUFFER_SIZE);
strncat_P(uart_message_string, PSTR("Oscilloscope Test Frame "),BUFFER_SIZE-1);
apiShowValue(uart_message_string, &apfelOscilloscopeTestFrameMode, apiVarType_BOOL_OnOff);
apfelApiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
apiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
break;
}
}
......@@ -697,7 +694,7 @@ void apfelApi_Inline(void)
}
createReceiveHeader(ptr_uartStruct, uart_message_string, BUFFER_SIZE);
apiShowValue(uart_message_string, &value, apiVarType_UINT16);
apfelApiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
apiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
}
break;
case 5: /* write sequence */
......@@ -1017,7 +1014,7 @@ void apfelApi_Inline(void)
strncat_P(uart_message_string, PSTR(" "),BUFFER_SIZE-1);
apiShowValue(uart_message_string, &apfelTrigger.pinNumber, apiVarType_UINT8);
apfelApiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
apiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
break;
}
}
......
......@@ -259,45 +259,12 @@ uint8_t apfelApiSubCommands(struct uartStruct *ptr_uartStruct, int16_t subComman
/* not a recursive call */
if (0 < parameterIndex)
{
apfelApiSubCommandsFooter( result );
apiSubCommandsFooter( result );
}
#endif
return result;
}
void apfelApiSubCommandsFooter( uint16_t result )
{
switch (result)
{
case apiCommandResult_SUCCESS_WITH_OUTPUT:
UART0_Send_Message_String_p(uart_message_string, BUFFER_SIZE - 1);
break;
case apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT:
/* verbose response to commands*/
if (debugLevelVerboseDebug <= globalDebugLevel && ((globalDebugSystemMask >> debugSystemAPFEL) & 1))
{
strncat_P(uart_message_string, PSTR("OK"), BUFFER_SIZE - 1);
UART0_Send_Message_String_p(uart_message_string, BUFFER_SIZE - 1);
}
else
{
clearString(uart_message_string, BUFFER_SIZE);
}
break;
case apiCommandResult_FAILURE_NOT_A_SUB_COMMAND:
CommunicationError_p(ERRA, SERIAL_ERROR_no_valid_command_name, true, PSTR("not a sub command"));
break;
case apiCommandResult_SUCCESS_QUIET:
case apiCommandResult_FAILURE_QUIET:
clearString(uart_message_string, BUFFER_SIZE);
/* printouts elsewhere generated */
break;
case apiCommandResult_FAILURE:
default:
CommunicationError_p(ERRA, dynamicMessage_ErrorIndex, true, PSTR("command failed"));
break;
}
}
#if 0
apiCommandResult apfelApiSubCommandShowStatus (void){return apiCommandResult_SUCCESS_QUIET;}
......
......@@ -57,7 +57,6 @@ extern apfelApiConfig* ptr_apfelApiConfiguration;
void apfelApi(struct uartStruct *ptr_uartStruct);
uint8_t apfelApiSubCommands(struct uartStruct *ptr_uartStruct, int16_t subCommandIndex, uint8_t parameterIndex);
void apfelApiSubCommandsFooter( uint16_t result );
void apfelApiShowStatus( uint8_t status[], uint8_t size );
void apfelApiShowStatusApiSettings(void);
......
......@@ -476,7 +476,7 @@ void apfel_Inline()
snprintf_P(uart_message_string, BUFFER_SIZE - 1, PSTR("%sport/pinSet/side/dac/chipId:'%c/%x/%x/%x/%x"),
uart_message_string, port, pinSetIndex, sideSelection, dacNr, chipId);
apiShowValue(uart_message_string, &value, apiVarType_UINT16);
apfelApiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
apiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
return 0;
}
......@@ -614,7 +614,7 @@ void apfel_Inline()
case 0:
createReceiveHeader(ptr_uartStruct, uart_message_string, BUFFER_SIZE);
apiShowValue(uart_message_string, &apfelOsziTestMode, apiVarType_BOOL_OnOff);
apfelApiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
apiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
break;
}
}
......@@ -671,7 +671,7 @@ void apfel_Inline()
}
createReceiveHeader(ptr_uartStruct, uart_message_string, BUFFER_SIZE);
apiShowValue(uart_message_string, &value, apiVarType_UINT16);
apfelApiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
apiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
}
break;
case 5: /* write sequence */
......
......@@ -476,7 +476,7 @@ void apfel_Inline()
snprintf_P(uart_message_string, BUFFER_SIZE - 1, PSTR("%sport/pinSet/side/dac/chipId:'%c/%x/%x/%x/%x"),
uart_message_string, port, pinSetIndex, sideSelection, dacNr, chipId);
apiShowValue(uart_message_string, &value, apiVarType_UINT16);
apfelApiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
apiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
return 0;
}
......@@ -614,7 +614,7 @@ void apfel_Inline()
case 0:
createReceiveHeader(ptr_uartStruct, uart_message_string, BUFFER_SIZE);
apiShowValue(uart_message_string, &apfelOsziTestMode, apiVarType_BOOL_OnOff);
apfelApiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
apiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
break;
}
}
......@@ -671,7 +671,7 @@ void apfel_Inline()
}
createReceiveHeader(ptr_uartStruct, uart_message_string, BUFFER_SIZE);
apiShowValue(uart_message_string, &value, apiVarType_UINT16);
apfelApiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
apiSubCommandsFooter(apiCommandResult_SUCCESS_WITH_OUTPUT);
}
break;
case 5: /* write sequence */
......
......@@ -431,7 +431,7 @@ void spiApiSubCommandsFooter( uint16_t result )
case apiCommandResult_SUCCESS_WITH_OUTPUT:
UART0_Send_Message_String_p(uart_message_string, BUFFER_SIZE - 1);
break;
case apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT:
case apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT__OK:
/* verbose response to commands*/
if (debugLevelVerboseDebug <= globalDebugLevel && ((globalDebugSystemMask >> debugSystemSPI) & 1))
{
......@@ -491,7 +491,7 @@ uint8_t spiApiSubCommandWrite(struct uartStruct *ptr_uartStruct, uint16_t parame
}
else
{
result = apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT;
result = apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT__OK;
}
}
}
......@@ -525,7 +525,7 @@ uint8_t spiApiSubCommandAdd(struct uartStruct *ptr_uartStruct)
default:
if ( apiCommandResult_FAILURE > spiApiAddToWriteArray(ptr_uartStruct, 2))
{
return apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT;
return apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT__OK;
}
else
{
......@@ -639,7 +639,7 @@ uint8_t spiApiSubCommandTransmit(void)
spiApiSubCommandShowWriteBuffer(ptr_uartStruct);
return apiCommandResult_SUCCESS_QUIET;
}
return apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT;
return apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT__OK;
}
uint8_t spiApiSubCommandWriteBuffer(void)
......@@ -682,7 +682,7 @@ uint8_t spiApiSubCommandWriteBuffer(void)
}
else
{
result = apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT;
result = apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT__OK;
}
}
......@@ -699,7 +699,7 @@ uint8_t spiApiSubCommandReset(void)
spiInit();
spiApiInit();
spiEnable(true);
return apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT;
return apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT__OK;
}
uint8_t spiApiSubCommandPurge(void)
......@@ -707,19 +707,19 @@ uint8_t spiApiSubCommandPurge(void)
spiApiSubCommandPurgeWriteBuffer();
spiApiSubCommandPurgeReadBuffer();
return apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT;
return apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT__OK;
}
uint8_t spiApiSubCommandPurgeWriteBuffer(void)
{
spiPurgeWriteData();
return apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT;
return apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT__OK;
}
uint8_t spiApiSubCommandPurgeReadBuffer(void)
{
spiPurgeReadData();
return apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT;
return apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT__OK;
}
uint8_t spiApiSubCommandRead(void)
......@@ -1568,7 +1568,7 @@ uint8_t spiApiAddNumericParameterToByteArray(const char string[], uint8_t index)
return result;
}
}
return apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT;
return apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT__OK;
}
uint8_t spiApiAddNumericStringToByteArray(const char string[])
......@@ -1663,7 +1663,7 @@ uint8_t spiApiAddNumericStringToByteArray(const char string[])
return apiCommandResult_FAILURE_QUIET;
}
return apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT;
return apiCommandResult_SUCCESS_WITH_OPTIONAL_OUTPUT__OK;
}
/* uint8_t spiApiShowBufferContent(spiByteDataArray *buffer, int16_t nRequestedBytes, int8_t commandKeywordIndex, int8_t subCommandKeywordIndex, PGM_P commandKeywords[])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment