Example #1
0
void uart0_status_isr(void)
#endif
{
	cli(); // Disable Interrupts

	// Variable for UART data read
	uint8_t keyValue = 0x00;

#if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) // AVR
	keyValue = UDR1;
#elif defined(_mk20dx128_) || defined(_mk20dx256_) // ARM
	// UART0_S1 must be read for the interrupt to be cleared
	if ( UART0_S1 & UART_S1_RDRF )
	{
		// Only doing single byte FIFO here
		keyValue = UART0_D;
	}
#endif

	// Debug
	char tmpStr[6];
	hexToStr( keyValue, tmpStr );
	dPrintStrs( tmpStr, " " ); // Debug

	// Decipher scan value
	processKeyValue( keyValue );

	sei(); // Re-enable Interrupts
}
Example #2
0
/*====================================================================*/
int parseKeyValues(int keyValuesSize,
                   void* keyValues,
                   CICSProgramDesc* pProgramDesc) {

    char* remaining;
    char key[MAX_KEY_LEN];
    char value[MAX_VALUE_LEN];
    int rc = OK_CODE;

    if (g_pTraceParms->traceMode == TRUE_CODE) {
       traceMessage(MODULE_NAME, "Entered parseKeyValues");
    }

    /* We expect the first token encountered to be a key */
    remaining = getToken(
                    keyValues, key, MAX_KEY_LEN - 1,
                    KEYWORD_DELIM, KEYWORD_DELIM);
    while (rc == OK_CODE
           && key != NULL
           && strlen(key) > 0
           && remaining != NULL) {

        /*  Values are separated from keys by a column char */
        remaining = getValueStart(remaining);
        if (remaining != NULL) {
            switch(remaining[0]) {
               /* Case of a simple value "key":"value" */
               case VALUE_DELIM:
                  remaining = getToken(
                                 remaining, value, MAX_VALUE_LEN - 1,
                                 VALUE_DELIM, VALUE_DELIM);
                  rc = processKeyValue(key, value, pProgramDesc);
                  break;
               /* Case of an array "key":["value1",.,"valuen"]*/
               case ARRAY_START_DELIM:
                  remaining = getToken(
                                 remaining, value, MAX_VALUE_LEN - 1,
                                 ARRAY_START_DELIM, ARRAY_END_DELIM);
                  rc = processKeyArray(key, value, pProgramDesc);
                  break;
            }
            /* Look for the next key */
            remaining = getToken(remaining, key, MAX_KEY_LEN - 1,
                                 KEYWORD_DELIM, KEYWORD_DELIM);
        }
    }

    if (g_pTraceParms->traceMode == TRUE_CODE) {
        traceProgramDesc(pProgramDesc);
        traceMessage(MODULE_NAME, "Ended parseKeyValues");
    }

    return rc;
}