Index: Common.h =================================================================== diff -u -r54a28b8a2beaffe5a47a5fcc3a2e65354efa8e5e -r5d0c8a999e953e1e4d644c4928b2e6ca4947e624 --- Common.h (.../Common.h) (revision 54a28b8a2beaffe5a47a5fcc3a2e65354efa8e5e) +++ Common.h (.../Common.h) (revision 5d0c8a999e953e1e4d644c4928b2e6ca4947e624) @@ -114,7 +114,7 @@ #define SEC_PER_MIN 60 ///< Number of seconds in a minute #define FRACTION_TO_PERCENT_FACTOR 100.0F ///< Percentage factor (100) #define MIN_PER_HOUR 60 ///< Number of minutes in an hour -#define PI 3.1415927F ///< PI +#define PI 3.1415927F ///< PI #define SECONDS_IN_A_DAY 86400 ///< Number of seconds in a day #define BITS_8_FULL_SCALE 256 ///< Full scale range for 8 bit ADC or DAC #define BITS_10_FULL_SCALE 1024 ///< Full scale range for 10 bit ADC or DAC @@ -125,6 +125,44 @@ #define BITS_24_FULL_SCALE 16777216 ///< Full scale range for 24 bit ADC or DAC #define HALF 0.5F ///< Half +#define ASCII_CODE_LETTER_A 0x41 ///< ASCII code in hex for letter A. +#define ASCII_CODE_LETTER_B 0x42 ///< ASCII code in hex for letter B. +#define ASCII_CODE_LETTER_C 0x43 ///< ASCII code in hex for letter C. +#define ASCII_CODE_LETTER_D 0x44 ///< ASCII code in hex for letter D. +#define ASCII_CODE_LETTER_E 0x45 ///< ASCII code in hex for letter E. +#define ASCII_CODE_LETTER_F 0x46 ///< ASCII code in hex for letter F. +#define ASCII_CODE_LETTER_G 0x47 ///< ASCII code in hex for letter G. +#define ASCII_CODE_LETTER_H 0x48 ///< ASCII code in hex for letter H. +#define ASCII_CODE_LETTER_I 0x49 ///< ASCII code in hex for letter I. +#define ASCII_CODE_LETTER_J 0x4A ///< ASCII code in hex for letter J. +#define ASCII_CODE_LETTER_K 0x4B ///< ASCII code in hex for letter K. +#define ASCII_CODE_LETTER_L 0x4C ///< ASCII code in hex for letter L. +#define ASCII_CODE_LETTER_M 0x4D ///< ASCII code in hex for letter M. +#define ASCII_CODE_LETTER_N 0x4E ///< ASCII code in hex for letter N. +#define ASCII_CODE_LETTER_O 0x4F ///< ASCII code in hex for letter O. +#define ASCII_CODE_LETTER_P 0x50 ///< ASCII code in hex for letter P. +#define ASCII_CODE_LETTER_Q 0x51 ///< ASCII code in hex for letter Q. +#define ASCII_CODE_LETTER_R 0x52 ///< ASCII code in hex for letter R. +#define ASCII_CODE_LETTER_S 0x53 ///< ASCII code in hex for letter S. +#define ASCII_CODE_LETTER_T 0x54 ///< ASCII code in hex for letter T. +#define ASCII_CODE_LETTER_U 0x55 ///< ASCII code in hex for letter U. +#define ASCII_CODE_LETTER_V 0x56 ///< ASCII code in hex for letter V. +#define ASCII_CODE_LETTER_W 0x57 ///< ASCII code in hex for letter W. +#define ASCII_CODE_LETTER_X 0x58 ///< ASCII code in hex for letter X. +#define ASCII_CODE_LETTER_Y 0x59 ///< ASCII code in hex for letter Y. +#define ASCII_CODE_LETTER_Z 0x5A ///< ASCII code in hex for letter Z. + +#define ASCII_CODE_NUMBER_ZERO 0x30 ///< ASCII code in hex for number zero. +#define ASCII_CODE_NUMBER_ONE 0x31 ///< ASCII code in hex for number one. +#define ASCII_CODE_NUMBER_TWO 0x32 ///< ASCII code in hex for number two. +#define ASCII_CODE_NUMBER_THREE 0x33 ///< ASCII code in hex for number three. +#define ASCII_CODE_NUMBER_FOUR 0x34 ///< ASCII code in hex for number four. +#define ASCII_CODE_NUMBER_FIVE 0x35 ///< ASCII code in hex for number five. +#define ASCII_CODE_NUMBER_SIX 0x36 ///< ASCII code in hex for number six. +#define ASCII_CODE_NUMBER_SEVEN 0x37 ///< ASCII code in hex for number seven. +#define ASCII_CODE_NUMBER_EIGHT 0x38 ///< ASCII code in hex for number eight. +#define ASCII_CODE_NUMBER_NINE 0x39 ///< ASCII code in hex for number nine. + // **** Common Macros **** #define FLOAT_TO_INT_WITH_ROUND(f) ((f) < 0.0F ? (S32)((f) - FLOAT_TO_INT_ROUNDUP_OFFSET) : (S32)((f) + FLOAT_TO_INT_ROUNDUP_OFFSET)) ///< Macro converts a floating point value to an integer Index: NVDataMgmt.c =================================================================== diff -u -r72066d13a07268869cb030b11eccda77f5184f91 -r5d0c8a999e953e1e4d644c4928b2e6ca4947e624 --- NVDataMgmt.c (.../NVDataMgmt.c) (revision 72066d13a07268869cb030b11eccda77f5184f91) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision 5d0c8a999e953e1e4d644c4928b2e6ca4947e624) @@ -2225,12 +2225,15 @@ break; #ifdef _DG_ +#if 0 + // For Phase 1B case NVDATAMGMT_SCHEDULED_RUNS_RECORD: // Pass the information to the CAN bus sendDGScheduledRunsRecord( calPublishMessageCount + 1, calPublishTotalMessages, length, startPtr ); // There are no scheduled runs for HD right now. break; #endif +#endif case NVDATAMGMT_SW_CONFIG_RECORD: #ifdef _DG_ sendDGSWConfigRecord( calPublishMessageCount + 1, calPublishTotalMessages, length, startPtr ); Index: Utilities.c =================================================================== diff -u -rcd9e36f40c7b69d8fec47be5410ba7926844d06b -r5d0c8a999e953e1e4d644c4928b2e6ca4947e624 --- Utilities.c (.../Utilities.c) (revision cd9e36f40c7b69d8fec47be5410ba7926844d06b) +++ Utilities.c (.../Utilities.c) (revision 5d0c8a999e953e1e4d644c4928b2e6ca4947e624) @@ -26,13 +26,11 @@ // ********** private definitions ********** -#define INITIAL_CRC16_VAL 0xFFFF ///< Seed for 16-bit CRC function -#define INITIAL_CRC08_VAL 0x00 ///< Seed for 8-bit CRC function +#define INITIAL_CRC16_VAL 0xFFFF ///< Seed for 16-bit CRC function. +#define INITIAL_CRC08_VAL 0x00 ///< Seed for 8-bit CRC function. +#define HEX_LETTER_TO_NUMBER_CONV 0x37 ///< Hex letter (i.e. A) to number conversion. +#define STR_TO_HEX_CONV_MAX_BYTES 8 ///< String to hex conversion maximum allowed bytes. -#define ASCII_CODE_LETTER_A 0x41 ///< ASCII code in hex for letter A. -#define ASCII_CODE_NUMBER_ZERO 0x30 ///< ASCII code in hex for number zero. -#define ASCII_CODE_NUMBER_SEVEN 0x37 ///< ASCII code in hex for number seven. - #define SEMAPHORE_IN_USE_TIMEOUT_MS ( 10 * MS_PER_SECOND ) ///< Taken semaphore timeout in milliseconds. // ********** private data ********** @@ -596,35 +594,69 @@ * @details Inputs: none * @details Outputs: none * @param valuePtr pointer to hex string to convert + * @param convValuePtr pointer to the provided buffer to write the converted + * values back * @param size size of the hex string to convert - * @return converted value of hex string + * @return TRUE if the characters were accepted, otherwise FALSE *************************************************************************/ -U32 hexStrToDec( U08 const * const valuePtr, U08 size ) +BOOL hexStrToDec( U08 const * const valuePtr, U32* convValuePtr, U08 size ) { U08 ii; U08 value; - U32 result = 0; + U32 result = 0; + BOOL status = FALSE; - // Switch 0-9 - // swtich A-F - // default - // size should not be more than 8 bytes - - for ( ii = 0; ii < size; ++ii ) + if ( size <= STR_TO_HEX_CONV_MAX_BYTES ) { - if ( valuePtr[ ii ] < ASCII_CODE_LETTER_A ) + // If the provided size is less than the maximum allowed, loop through the list for conversion + for ( ii = 0; ii < size; ++ii ) { - value = ( valuePtr[ ii ] - ASCII_CODE_NUMBER_ZERO ); - result = ( result << 4 ) | value; + value = valuePtr[ ii ]; + + switch( value ) + { + case ASCII_CODE_NUMBER_ZERO: + case ASCII_CODE_NUMBER_ONE: + case ASCII_CODE_NUMBER_TWO: + case ASCII_CODE_NUMBER_THREE: + case ASCII_CODE_NUMBER_FOUR: + case ASCII_CODE_NUMBER_FIVE: + case ASCII_CODE_NUMBER_SIX: + case ASCII_CODE_NUMBER_SEVEN: + case ASCII_CODE_NUMBER_EIGHT: + case ASCII_CODE_NUMBER_NINE: + // If the hex string is a number, subtract the number from hex zero to get a number + // Shift the results by a nibble and add the calculated number. + // For instance, if the value = 0x36 - 0x30 = the value becomes 6 + value = ( value - ASCII_CODE_NUMBER_ZERO ); + result = ( result << SHIFT_BITS_BY_4 ) | value; + status = TRUE; + break; + + case ASCII_CODE_LETTER_A: + case ASCII_CODE_LETTER_B: + case ASCII_CODE_LETTER_C: + case ASCII_CODE_LETTER_D: + case ASCII_CODE_LETTER_E: + case ASCII_CODE_LETTER_F: + // If the value is from A-F for the hex values, subtract the value from 0x37. + // This converts the letters from A to F to 10 to 15. + // For instance if the read value is 0x43 ( C ) - 0x37 = 12 + value = ( value - HEX_LETTER_TO_NUMBER_CONV ); + result = ( result << SHIFT_BITS_BY_4 ) | value; + status = TRUE; + break; + + default: + // Do nothing since the character is not accepted. + break; + } } - else - { - value = ( valuePtr[ ii ] - ASCII_CODE_NUMBER_SEVEN ); - result = ( result << 4 ) | value; - } + + *convValuePtr = result; } - return result; + return status; } /*********************************************************************//** @@ -638,7 +670,7 @@ BOOL isCriticalDataSet( CRITICAL_DATA_T *data ) { BOOL result = FALSE; - CRITICAL_DATA_T d; + CRITICAL_DATA_T d; _disable_IRQ(); d = *data; Index: Utilities.h =================================================================== diff -u -refdbe5815e423124fdfa1a1efba8b61dacf170e8 -r5d0c8a999e953e1e4d644c4928b2e6ca4947e624 --- Utilities.h (.../Utilities.h) (revision efdbe5815e423124fdfa1a1efba8b61dacf170e8) +++ Utilities.h (.../Utilities.h) (revision 5d0c8a999e953e1e4d644c4928b2e6ca4947e624) @@ -106,7 +106,7 @@ BOOL setCriticalData( CRITICAL_DATA_T *data, CRITICAL_DATAS_T value ); BOOL isCriticalDataInRange( CRITICAL_DATA_T *data ); void resetCriticalData( CRITICAL_DATA_T *data ); -U32 hexStrToDec( U08 const * const valuePtr, U08 size ); +BOOL hexStrToDec( U08 const * const valuePtr, U32* convValueAddress, U08 size ); BOOL isCriticalDataSet( CRITICAL_DATA_T *data ); ///< Determines if critical data has been set. void initSemaphores( void );