|
@@ -262,32 +262,23 @@ void UTCToBeijing(UTC8TimeType* UTC8Time,unsigned int UTCyear,unsigned char UTCm
|
|
|
}
|
|
|
#include <stdarg.h>
|
|
|
#ifdef DEBUGLOG
|
|
|
-static UINT8 DebugFileNux=0;
|
|
|
+static osMutexId_t DebugFileMux;
|
|
|
static void Debug_Write_Logfile(UINT8 * buf)
|
|
|
{
|
|
|
- int32_t err;
|
|
|
UINT32 Count;
|
|
|
OSAFILE file;
|
|
|
- while(DebugFileNux){
|
|
|
- osDelay(10/portTICK_PERIOD_MS);
|
|
|
- }
|
|
|
- DebugFileNux=1;
|
|
|
+ osMutexAcquire(DebugFileMux, osWaitForever)
|
|
|
file = OsaFopen("DebugFile","wb");
|
|
|
- if(file==NULL){
|
|
|
- DebugFileNux=0;
|
|
|
- return;
|
|
|
- }
|
|
|
- if(OsaFseek(file, 0, SEEK_END) != 0)
|
|
|
+ if(file!=NULL)
|
|
|
{
|
|
|
- OsaFclose(file);
|
|
|
- DebugFileNux=0;
|
|
|
- return;
|
|
|
- }
|
|
|
- Count = OsaFwrite(buf, 1, strlen(buf), file);
|
|
|
- if(Count != (strlen(buf))){
|
|
|
+ if(OsaFseek(file, 0, SEEK_END) == 0)
|
|
|
+ {
|
|
|
+ Count = OsaFwrite(buf, 1, strlen(buf), file);
|
|
|
+ }
|
|
|
+ OsaFclose(file);
|
|
|
}
|
|
|
- OsaFclose(file);
|
|
|
- DebugFileNux=0;
|
|
|
+ osMutexRelease(DebugFileMux);
|
|
|
+ return;
|
|
|
}
|
|
|
void Debug_printf(const UINT8 *format, ...)
|
|
|
{
|
|
@@ -306,12 +297,19 @@ void Debug_printf(const UINT8 *format, ...)
|
|
|
memset(buf,0,128+1);
|
|
|
UTC8TimeType UTC8TimeStruct;
|
|
|
UTCToBeijing((UTC8TimeType *)&UTC8TimeStruct,year,month,day,hour,minute,sec);
|
|
|
- sprintf((char *)buf,"%04d-%02d-%02d %02d:%02d:%02d ",UTC8TimeStruct.year,UTC8TimeStruct.month,UTC8TimeStruct.day,UTC8TimeStruct.hour,UTC8TimeStruct.minute,UTC8TimeStruct.second);
|
|
|
+ sprintf((char *)buf,"%02d-%02d %02d:%02d:%02d ",UTC8TimeStruct.month,UTC8TimeStruct.day,UTC8TimeStruct.hour,UTC8TimeStruct.minute,UTC8TimeStruct.second);
|
|
|
va_start(args, format);
|
|
|
vsnprintf(buf+strlen(buf), 128-strlen(buf), format, args);
|
|
|
va_end(args);
|
|
|
Debug_Write_Logfile(buf);
|
|
|
}
|
|
|
+void Debug_GetSize(UINT16 *FileSize)
|
|
|
+{
|
|
|
+ OSAFILE file;
|
|
|
+ file = OsaFopen("DebugFile","rb");
|
|
|
+ FileSize = OsaFsize(file);
|
|
|
+ OsaFclose(file);
|
|
|
+}
|
|
|
void Debug_Read_Logfile(UINT8 * rbuf,UINT16 FileSize)
|
|
|
{
|
|
|
int32_t err;
|