Index: NVDataMgmt.c =================================================================== diff -u -r33154cde2aaf919b95e678f513131295ca937d42 -rb46d288230d4e6aa32a7a2764c3d392c4dce0121 --- NVDataMgmt.c (.../NVDataMgmt.c) (revision 33154cde2aaf919b95e678f513131295ca937d42) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision b46d288230d4e6aa32a7a2764c3d392c4dce0121) @@ -187,10 +187,10 @@ U16 crc; ///< Calibration data CRC } CALIBRATION_RECORD_T; -/// last disinfection record struct +/// Last disinfection record struct typedef struct { - char disinfectionDate [ MAX_DATE_CHARACTERS ]; ///< Disinfection date (char array) + DISINFECTION_DATE_T date; ///< Disinfection date (char array) U16 crc; ///< Disinfection date CRC } LAST_DISINFECTION_RECORD_T; #pragma pack(pop) @@ -261,10 +261,9 @@ // REMOVE THIS CODE //static U08 tempBufferForTest[5] = {'5', 'Y', 'I', 'D', 'P'}; static U08 readBufferForTest [ 36 ]; -static READ_DATA_T mytest; static CALIBRATION_DATA_T calTest; static SERVICE_DATA_T service; -static MFG_DATA_T mfgD; +static DISINFECTION_DATE_T date; // REMOVE THIS CODE /************************************************************************* @@ -310,17 +309,25 @@ /************************************************************************* * @brief getMfgData - * The getMfgData returns the data in the struct that hold manufacturing + * The getMfgData returns the data in the struct that holds manufacturing * record to buffer that the caller has provided * @details * Inputs : MFG_DATA_T* (buffer) - * Outputs : none + * Outputs : BOOL (status) * @param none - * @return none + * @return BOOL (status) *************************************************************************/ -void getMfgData ( MFG_DATA_T* buffer ) +BOOL getMfgData ( MFG_DATA_T* buffer ) { - memcpy ( buffer, (U08*)&mfgRecord.mfgData, sizeof(MFG_DATA_T) ); + BOOL status = FALSE; + + if ( buffer != NULL ) + { + memcpy ( buffer, (U08*)&mfgRecord.mfgData, sizeof(MFG_DATA_T) ); + status = TRUE; + } + + return status; } /************************************************************************* @@ -351,15 +358,22 @@ * record to buffer that the caller has provided * @details * Inputs : CALIBRATION_DATA_T* (buffer) - * Outputs : none + * Outputs : BOOL (status) * @param none - * @return none + * @return BOOL (status) *************************************************************************/ -void getCalibrationData ( CALIBRATION_DATA_T* buffer ) +BOOL getCalibrationData ( CALIBRATION_DATA_T* buffer ) { - memcpy ( buffer, (U08*)&calibrationRecord.calData, sizeof(CALIBRATION_DATA_T) ); -} + BOOL status = FALSE; + if ( buffer != NULL ) + { + memcpy ( buffer, (U08*)&calibrationRecord.calData, sizeof(CALIBRATION_DATA_T) ); + status = TRUE; + } + + return status; + } /************************************************************************* * @brief setServiceDate * The setServiceDate updates the struct that holds the calibration data, @@ -393,13 +407,21 @@ * date to buffer that the caller has provided * @details * Inputs : SERVICE_DATA_T* (buffer) - * Outputs : none + * Outputs : BOOL (status) * @param none - * @return none + * @return BOOL (status) *************************************************************************/ -void getServiceDate ( SERVICE_DATA_T* buffer ) +BOOL getServiceDate ( SERVICE_DATA_T* buffer ) { - memcpy ( buffer, (U08*)&serviceRecord.serviceData, sizeof(SERVICE_DATA_T) ); + BOOL status = FALSE; + + if ( buffer != NULL ) + { + memcpy ( buffer, (U08*)&serviceRecord.serviceData, sizeof(SERVICE_DATA_T) ); + status = TRUE; + } + + return status; } /************************************************************************* @@ -537,16 +559,16 @@ * CRC for it and if the queue is not full, it schedules a write to RTC RAM * to store the last date * @details - * Inputs : U08* (buffer) - * Outputs : none + * Inputs : DISINFECTION_DATE_T (date) + * Outputs : BOOL (status) * @param none - * @return none + * @return BOOL (status) *************************************************************************/ -BOOL setDisinfectionDate ( char date [ MAX_DATE_CHARACTERS ] ) +BOOL setDisinfectionDate ( DISINFECTION_DATE_T date ) { BOOL status = FALSE; - memcpy ( lastDisinfectionRecord.disinfectionDate, date, MAX_DATE_CHARACTERS ); - lastDisinfectionRecord.crc = crc16 ( (U08*)&lastDisinfectionRecord.disinfectionDate, sizeof(MAX_DATE_CHARACTERS) ); + memcpy ( lastDisinfectionRecord.date.disinfectionDate, date.disinfectionDate, sizeof(DISINFECTION_DATE_T) ); + lastDisinfectionRecord.crc = crc16 ( (U08*)&lastDisinfectionRecord.date.disinfectionDate, sizeof(DISINFECTION_DATE_T) ); if ( !isQueueFull() ) { @@ -563,14 +585,22 @@ * The getDisinfectionDate populates the provided buffer with the last * disinfection date * @details - * Inputs : U08* (buffer) - * Outputs : none + * Inputs : DISINFECTION_DATE_T* (buffer) + * Outputs : BOOL (status) * @param none - * @return none + * @return BOOL (status) *************************************************************************/ -void getDisinfectionDate ( U08* buffer ) +BOOL getDisinfectionDate ( DISINFECTION_DATE_T* buffer ) { - memcpy ( buffer, lastDisinfectionRecord.disinfectionDate, MAX_DATE_CHARACTERS ); + BOOL status = FALSE; + + if ( buffer != NULL ) + { + memcpy ( buffer, lastDisinfectionRecord.date.disinfectionDate, sizeof(DISINFECTION_DATE_T) ); + status = TRUE; + } + + return status; } /************************************************************************* @@ -1171,10 +1201,11 @@ //mytest.status = NVDATAMGMT_READ_IDLE; //mytest.externalBuffer = readBufferForTest; - char a[10] = {'0','3','-', '0','3','-','2','0','2','0'}; - //setDisinfectionDate ( a); + char a[10] = {'1','5','-', '1','8','-','2','0','2','1'}; + memcpy (date.disinfectionDate, a, sizeof(DISINFECTION_DATE_T)); + setDisinfectionDate (date); - writeLogData ( &logData ); + //writeLogData ( &logData ); //readLogData ( &mytest, sizeof(readBufferForTest) ); //readLogData ( &mytest, sizeof(readBufferForTest) ); @@ -1187,7 +1218,7 @@ memcpy(service.nextServiceDate, a, 10); //setServiceDate(service); - //getServiceDate ( &service ); + //getServiceDate ( 0 ); /*MFG_DATA_T test; char sys[7] = {'A', 'B', 'C', 'D', '3', '6', '7'};