Example #1
0
//显示已经保存的信息
int ShowData(struct tagIndex *pInfo,  int nInfoLen)
{
    int nCurIndex = 0;
    struct tagInfo *pShowMsg = NULL;
    //获得头指针
    int i = FindHead(pInfo, nInfoLen);
    if (i == -1)
    {
        printf("没有内容!\r\n");
        printf("总剩余空间:%d\r\n", GetFreeSizeSum());
        printf("总连续空间:%d\r\n", GetWholeSizeSum());
        return 0;
    }

    FILE *fp = NULL;
    MY_FOPEN(fp, DATAFILE);

    nCurIndex = i;
    i = 0;
    while (1)
    {
        pShowMsg = (struct tagInfo *)malloc(pInfo[nCurIndex].m_nlength);
        if (pShowMsg == NULL)
        {
            exit(1);
        }
        fseek(fp, pInfo[nCurIndex].m_nOffset, SEEK_SET);
        Myfread(pShowMsg, pInfo[nCurIndex].m_nlength, fp);
        printf("--联系人[%d]--偏移地址[%p]--\r\n", i, pInfo[nCurIndex].m_nOffset);
        ShowInfoMsg(pShowMsg);
        ShowMsg("");
        if (pShowMsg != NULL)
        {
            free(pShowMsg);
            pShowMsg = NULL;
        }

        i++;
        nCurIndex = pInfo[nCurIndex].m_nNextIndex;
        if (nCurIndex == -1)
        {
            break;
        }
    }
    printf("总剩余空间:%d\r\n", GetFreeSizeSum());
    printf("总连续空间:%d\r\n", GetWholeSizeSum());

    if (fp != NULL)
    {
        fclose(fp);
        fp = NULL;
    }
    return 1;
}
Example #2
0
File: FSKModem.c Project: EQ4/FSK
/*****************************************
功能:  解调 从InDataBuf开始Lenth 这么长的数据 里,用MobileType方式,解调出数据,存在OutDataBuf里
反回时,解到哪个点放在OutLenIndix里
本函数调用的函数清单: 无
调用本函数的函数清单: main
输入参数:  *InDataBuf    采样值地址
lenth        总长度
输出参数:  *OutDataBuf   数据保存的地方
*OutLenIndix  解到哪里
函数返回值说明:    0:出错,1:没有滤波  2:需要滤波
使用的资源 
******************************************/
int    Demodulate(BYTE *OutDataBuf, short *InDataBuf,
									  unsigned long lenth,unsigned long *OutLenIndix)
{
	BYTE LoopForSmooth = 0;// 0 是第一次,1是第二次
	BYTE DemodulationResult = 0;// 找同步头和解调的结果,1为成功,0为失败

	unsigned long lLowF = 0;
	unsigned long lHighF = 0;
	int MobileType = 3; // 表示频率5.5k,解调的频率是固定的

	for(LoopForSmooth = 0;LoopForSmooth < 2; LoopForSmooth++ )
	{
		if(LoopForSmooth == 1)//两次循环,先不滤波,解不出来再滤波。
		{
			printf("start Smoothing wave\n");//
			
			lLowF = (unsigned long)((float)(2000*2/(MobileType+1))*(float)(1.0/32.0 * (float)(MobileType+1)+15.0/16.0));
			lHighF = (unsigned long)((float)(15000*2/(MobileType+1))*(float)(1.0/16.0 * (float)(MobileType+1)+7.0/8.0));

			memcpy(InDataBuf,(char*)InDataBuf+lenth*2,lenth*2);
			SmoothingWave(InDataBuf,lenth, lLowF, lHighF, 44100);
			*OutLenIndix = 0;
		}
		DisInterference(InDataBuf,lenth,MobileType);//去扰
		DemodulationResult = FindHead(InDataBuf,lenth,OutLenIndix,MobileType);//找同步头
		if( DemodulationResult == 1)//如果找到了,则解
		{
			DemodulationResult = GetAllData(OutDataBuf,InDataBuf,lenth,OutLenIndix,MobileType);//解调
		}

		if(LoopForSmooth == 0)
		{
			if(DemodulationResult == 1)//continue;//第一次解不出来,滤波后再解
			{
				printf("with no need for Smoothing wave\n");//
				return 1;//第一次就解出来了,说明是没有滤波就解出来了
			}
		}
		else if(LoopForSmooth == 1)
		{
			if(DemodulationResult == 0)
			{
				return 0;//第二次还解不出来,出错了
			}
			else
			{
				printf("need Smoothing wave\n");//
				return 2;//第二次才解出来,说明需要滤波
			}
		}

	}
	return 0;//出错了
}
Example #3
0
//显示存储信息(碎片)
void ShowSaveCount(struct tagIndex *pInfo, int nInfoLen, int nBaseOffset)
{
    int nOffset = nBaseOffset;
    int nFreeFlg = 0;
    int nCurIndex = FindHead(pInfo, nInfoLen);
    while (nOffset < nBaseOffset + DATA_SIZE)
    {
        if (CheckOffsetExits(pInfo, nInfoLen, nOffset) >= 0)
        {
            printf("■");
        }
        else
        {
            printf("□");;
        }
        nOffset++;
    }
    ShowMsg("\r\n");
}
Example #4
0
//统计
int ShowStringCount(struct tagIndex *pInfo, int nInfoLen)
{
    //只统计ascii从0x20~0x7e的字符
    int nMyAsciiAry[0x7e - 0x20] = {0};
    int nAsciiSum = 0;
    int nCurIndex = FindHead(pInfo, nInfoLen);
    char *szBuf = NULL;
    FILE *fp = NULL;
    MY_FOPEN(fp, DATAFILE);
    while (1)
    {
        char szRead[128] = {'\0'};
        fseek(fp, pInfo[nCurIndex].m_nOffset, SEEK_SET);
        Myfread(szRead, 128, fp);
        szBuf = szRead;
        while (*szBuf != '\0')
        {
            nMyAsciiAry[*szBuf - 0x20]++;
            szBuf++;
            nAsciiSum++;
        }
        nCurIndex = pInfo[nCurIndex].m_nNextIndex;
        if (nCurIndex == -1)
        {
            break;
        }
    }
    for (int i = 0; i < (0x7e - 0x20); i++)
    {
        if (nMyAsciiAry[i] != 0)
        {
            printf("联系人 [%c] 出现了%d次,出现频率为 %f%%\r\n",
                   (char)(i + 0x20),
                   nMyAsciiAry[i],
                   ((float)(nMyAsciiAry[i]) / (float)(nAsciiSum)) * 100.0f);
        }
    }
    MY_FCLOSE(fp);
    return 0;
}