Beispiel #1
0
bool copyFilleFromAutosyncTemporaryDBToWorkDB(char *source)
{
    OUT_DEBUG_2("copyFilleFromAutosyncTemporaryDBToWorkDB(): source - \"%s\"\"\r\n", source);

    char source_filename[30] = DBFILE_AUTOSYNC_TEMP("");        \
    Ql_strcat(source_filename, source);


    char target_filename[30] = DBFILE_AUTOSYNC("");        \
    Ql_strcat(target_filename, source);


    // -- check source file
    s32 ret = Ql_FS_Check(source_filename);
    if (ret == QL_RET_ERR_FILENOTFOUND) {
        OUT_DEBUG_1("File \"%s\" was not found.\r\n", source_filename);
        return FALSE;
    } else if (ret < QL_RET_OK) {
        OUT_DEBUG_1("Error %d occured while checking file \"%s\".\r\n", ret, source_filename);
        return FALSE;
    }

    // -- check and remove target dir
    ret = Ql_FS_CheckDir(DB_DIR_AUTOSYNC);
    if (ret < QL_RET_OK && ret != QL_RET_ERR_FILENOTFOUND) {
        OUT_DEBUG_1("Error %d occured while checking dir \"%s\".\r\n",ret,  DB_DIR_AUTOSYNC);
        return FALSE;
    }

    // -- move source file to target dir
    ret = Ql_FS_XMove(source_filename, target_filename, QL_FS_MOVE_KILL|QL_FS_MOVE_OVERWRITE);
    if (QL_RET_OK > ret) {
        OUT_DEBUG_1("Error %d occured while moving \"%s\" to \"%s\".\r\n", ret, source_filename, target_filename);
        return FALSE;
    }

    return TRUE;
}
bool VerifyFileAndSendFirstEpoPacket(u8 *strFilePath)
{
    int ret = 0,filesize = 0;
    int sendLen = 0;
        
    if((strFilePath == NULL) || (Ql_strlen(strFilePath) == 0))
    {
         APP_DEBUG("VerifyFileAndSendFirstEpoPacket, strFilePath %s \r\n", strFilePath);             
        return FALSE;
    }
    ret = Ql_FS_Check((char*)strFilePath);
    if(ret != QL_RET_OK)
    {
        APP_DEBUG("Ql_FS_Check, strFilePath %s error \r\n", strFilePath);            
        return FALSE;
    }
    filesize = Ql_FS_GetSize((char*)strFilePath);       
    if(filesize < 0)
    {
        APP_DEBUG("Ql_FS_GetSize, filesize %d error \r\n ", filesize);            
        return FALSE;
    }       
    if (Ql_strncmp((char*)strFilePath,"RAM:", 4))
    {
        g_pEpoFile = Ql_FS_Open((char*)strFilePath, QL_FS_READ_ONLY);
    }
    else
    {
        g_pEpoFile = Ql_FS_OpenRAMFile((char*)strFilePath, QL_FS_READ_ONLY, filesize);
    }        
    // Read in the EPO file, and then verify the validity of EPO data. If the input EPO file is not in valid MTK EPO format, the
    // programmer shall terminate the process.
    if(g_pEpoFile < 0)
    {
        Ql_FS_Close(g_pEpoFile);
        APP_DEBUG("Ql_FS_OpenRAMFile, g_pEpoFile %d error \r\n ", g_pEpoFile);            
        return FALSE;
    }
    else
    {
        if (!fgEPO_Verify_File(g_pEpoFile))
        {
            Ql_FS_Close(g_pEpoFile);
            APP_DEBUG("fgEPO_Verify_File, g_pEpoFile %d error \r\n", g_pEpoFile);                    
            return FALSE;
        }
    }                    
    // Get total number of MTK_BIN_EPO packets that will be sent.
    g_i4NumSvEpoPkt =  i2EPO_Get_Num_Pkt(g_pEpoFile);       
    // Start EPO Data Transfer Protocol to send EPO data
    // fgEPO_Get_One_Pkt takes out three SAT data from the EPO file and encapsulated them in a MTK_BIN_EPO packet
    // with appropriate EPO SEQ number.
    // In order to save the total transferring time, we suggest to generate current EPO packet first, and then wait for
    // MTK_BIN_ACK_EPO acknowledge of the previous MTK_BIN_EPO packet from the GPS receiver.
    // The function fgEPO_Get_One_Pkt must be implemented by the programmer.
    g_u2LastEpoSeq = 0;
    g_u2EpoSeq = 0;
    Ql_memset(g_szPktData,0,sizeof(g_szPktData));
    if (fgEPO_Get_One_Pkt(g_u2EpoSeq, g_pEpoFile, g_szPktData))
    {
        sendLen =  MTKBIN_3EPO_PKT_LNG;
        ret = Ql_UART_Write(m_gnssUartPort,g_szPktData,sendLen);
        if (ret < sendLen)
        {
            APP_DEBUG("VerifyFileAndSendFirstEpoPacket Only part of bytes are written, %d/%d \r\n", ret, sendLen);            
            return FALSE;
        }
        // Update sequence number
        g_u2LastEpoSeq = g_u2EpoSeq;
        g_u2EpoSeq++;
        return TRUE;
    }
    else
    {
        APP_DEBUG("VerifyFileAndSendFirstEpoPacket fgEPO_Get_One_Pkt error \r\n");
        return FALSE;
    }

}