?? de_encode.c
字號:
//IP重發間隔 8
{
uint8 tempValue=8;
temp.param_ID=0x020C;
temp.pParam_Value=&tempValue;
temp.paramValue_Len=sizeof(tempValue);
update(&temp,tempbuff);
}
//SMS重發次數 2
{
uint8 tempValue=2;
temp.param_ID=0x020D;
temp.pParam_Value=&tempValue;
temp.paramValue_Len=sizeof(tempValue);
update(&temp,tempbuff);
}
//SMS重發間隔 60
{
uint8 tempValue=60;
temp.param_ID=0x020E;
temp.pParam_Value=&tempValue;
temp.paramValue_Len=sizeof(tempValue);
update(&temp,tempbuff);
}
//監聽電話 0 //0x0100
{
uint8 tempValue='0';
temp.param_ID=0x0100;
temp.pParam_Value=&tempValue;
temp.paramValue_Len=sizeof(tempValue);
update(&temp,tempbuff);
}
//設置ACC累計時間 占用4個字節,數值范圍0~4294967295,單位:秒。
{
uint8 buff[4];
memset(buff,0,sizeof(buff));
temp.param_ID=0x0303;
temp.pParam_Value=buff;
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
//設置累計里程 占用4個字節,數值范圍0~4294967295,單位:米。
{
uint8 buff[4];
memset(buff,0,sizeof(buff));
temp.param_ID=0x0304;
temp.pParam_Value=buff;
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
//登陸提示 不提示
{
uint8 tempValue=0;
temp.param_ID=0x030B;
temp.pParam_Value=&tempValue;
temp.paramValue_Len=sizeof(tempValue);
update(&temp,tempbuff);
}
//是否短信提示 不提示
//是否接調度屏 不接
{
uint8 tempValue=0;
temp.param_ID=0x0307;
temp.pParam_Value=&tempValue;
temp.paramValue_Len=sizeof(tempValue);
update(&temp,tempbuff);
}
temp.param_ID=0x0700; //終端硬件版本號 使用ASCII碼表示,版本號長度小于128個字節。
temp.pParam_Value=(uint8 *)HardwareVersionNO;
temp.paramValue_Len=strlen(HardwareVersionNO);
update(&temp,tempbuff);
temp.param_ID=0x0701; //終端軟件版本號 使用ASCII碼表示,版本號長度小于128個字節。
temp.pParam_Value=(uint8 *)SoftwareVersionNO;
temp.paramValue_Len=strlen(SoftwareVersionNO);
update(&temp,tempbuff);
//撥號用戶名 空32
temp.param_ID=0x0207;
temp.pParam_Value=(uint8 *)("");
temp.paramValue_Len=strlen("");
update(&temp,tempbuff);
//撥號密碼 空32
temp.param_ID=0x0208;
temp.pParam_Value=(uint8 *)("");
temp.paramValue_Len=strlen("");
update(&temp,tempbuff);
//通信方式 只使用IP方式通信
{
uint8 buff=0;
temp.param_ID=0x020A;
temp.pParam_Value=(uint8 *)(&buff);
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}//設置車速傳感器每周脈沖數 0
{
uint8 buff=0;
temp.param_ID=0x0305;
temp.pParam_Value=(uint8 *)(&buff);
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}//設置油位傳感器采樣頻率 1 10次/S
{
uint8 buff=10;
temp.param_ID=0x0308;
temp.pParam_Value=(uint8 *)(&buff);
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
//設置拍照類型 0 2
{
uint8 buff[2];
memset(buff,0,sizeof(buff));
temp.param_ID=0x0500;
temp.pParam_Value=(uint8 *)(buff);
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
//車輛特征系數 0 0x0306,2
{
uint8 buff[2];
memset(buff,0,sizeof(buff));
temp.param_ID=0x0306;
temp.pParam_Value=(uint8 *)(buff);
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
//temp.param_ID=????; //協議版本號 要求根據中心下發的主協議讀取協議版本號
//temp.pParam_Value=(uint8 *)&(pcur_IPMAINDATA->protocolVersion);
//temp.paramValue_Len=sizeof(pcur_IPMAINDATA->protocolVersion);
//update(&temp,tempbuff);
//設置的駕駛員ID 根據設置駕駛員ID指令內容格式上傳
{
uint8 buff[ALLDEVICE_LEN];
memset(buff,0,sizeof(buff));
temp.param_ID=0x0706;
temp.pParam_Value=(uint8 *)(buff);
temp.paramValue_Len=sizeof(buff);
update(&temp,tempbuff);
}
W25X32_Erase_Semphore(SETUP_PARAMS_SEC, SETUP_PARAMS_SEC);
for(itemp=0;itemp<SETUP_PARAMS_DATASIZE/pageLen;itemp++)
{
W25X32_WR(GetAddr(SETUP_PARAMS_SEC,itemp*pageLen),tempbuff+itemp*pageLen,pageLen);
OSTimeDly(3);
}
if(SETUP_PARAMS_DATASIZE%pageLen>0)
{
OSTimeDly(3);
W25X32_WR(GetAddr(SETUP_PARAMS_SEC,itemp*pageLen),tempbuff+itemp*pageLen,SETUP_PARAMS_DATASIZE%pageLen);
}
OSMemPut(IntBuffer_Big,tempbuff);
}
//清除盲區補償的首扇區。
W25X32_Erase_2_Semphore(FIRSTSEC,FIRSTSEC);
//清空ACC累計值及里程數統計的存儲扇區。
W25X32_Erase_Semphore(MILEAGE_ACC_SEC, MILEAGE_ACC_SEC);
return TRUE;
}
//恢復自定義參數出廠設置
uint8 Renew_Initializers_Custom(void)
{
uint8 * tempbuff=NULL;
OSMemQuery(IntBuffer_Big,&MemInfo);
if(MemInfo.OSNFree > (uint8)(CUSTOM_PARAMS_DATASIZE/BlockSize_Big))
{
const uint8 pageLen=0xff;
uint8 itemp=0;
tempbuff=(INT8U *)OSMemGet(IntBuffer_Big,&err);
W25X32_READ_Semphore(GetAddr(CUSTOM_PARAMS_SEC,0),CUSTOM_PARAMS_DATASIZE,tempbuff);
///////////自定義參數ID
///追蹤參數
//0x0000, //通信方式 占用1個字節:
//0x0001, //時間間隔(ACC開) 2 單位:秒,最小為0,默認為0秒
//0x0002, //時間間隔(ACC關) 2 單位:秒,最小為0,默認為0秒
//0x0003, //距離間隔 2 單位:米,最小為0,默認為0,最大為65535米
//追蹤間隔 時間間隔和距離間隔同時設為0(停止上傳)
{
INT16U len=0,moveAddr=0;
uint8 tempBuff[7];
trace_FORM.communi_Mode=0; //IP
trace_FORM.acc_In_Timeslot=0; ////ACC開時間間隔,單位:秒,最小為0,默認為0秒
trace_FORM.acc_Out_Timeslot=0;
trace_FORM.distance_Slot=0;
GetOmoveAddr(CUSTOM_PARAMS,CUSTOM_PARAMS_COUNT,0x0000,&len,&moveAddr);
memset(tempBuff,0,sizeof(tempBuff));
memcpy(tempbuff+moveAddr,tempBuff,sizeof(tempBuff));
}
//0x0004, //記錄保存里程數及ACC的當前扇區號,2個字節
//0x0005, //系統第一次啟動標志,1個字節.為0時表示已執行第一次啟動,非0表示還未執行過
///工作參數上傳設置2
//0x0006, //通信方式 占用1個字節:
//0x0007, //時間間隔(ACC開) 2 單位:秒,最小為0,默認為0秒
//0x0008, //時間間隔(ACC關) 2 單位:秒,最小為0,默認為0秒
//0x0009, //距離間隔 2 單位:米,最小為0,默認為0,最大為65535米
{
INT16U len=0,moveAddr=0;
uint8 tempBuff[7];
workParamUploadCfg2.communi_Mode=0; //IP
workParamUploadCfg2.acc_In_Timeslot=0; ////ACC開時間間隔,單位:秒,最小為0,默認為0秒
workParamUploadCfg2.acc_Out_Timeslot=0;
workParamUploadCfg2.distance_Slot=0;
GetOmoveAddr(CUSTOM_PARAMS,CUSTOM_PARAMS_COUNT,0x0006,&len,&moveAddr);
memset(tempBuff,0,sizeof(tempBuff));
memcpy(tempbuff+moveAddr,tempBuff,sizeof(tempBuff));
}
///工作參數上傳設置1
//0x000a, //通信方式。0:IP方式。1:SMS方式。1個字節
//0x000b, //最多240個,需要存儲空間480個字節。時間點的小時。時間點的小時。取值范圍0至23//時間點的分鐘。取值范圍0至59
{
INT16U len=0,moveAddr=0;
workParamUploadCfg1.communi_Mode=0; //IP
memset(workParamUploadCfg1.stru_TimePoint_FORM,0xff,sizeof(workParamUploadCfg1.stru_TimePoint_FORM));
GetOmoveAddr(CUSTOM_PARAMS,CUSTOM_PARAMS_COUNT,0x0006,&len,&moveAddr);
len=sizeof(workParamUploadCfg1.communi_Mode)+sizeof(workParamUploadCfg1.stru_TimePoint_FORM);
memcpy(tempbuff+moveAddr,(uint8 *)&workParamUploadCfg1,len);
}
//
//0x000c, //求助告警 占用1個字節,0表示未連接;1表示關閉;2表示打開;
//0x000d, //遠程控制 占用1個字節,0表示未連接;1表示關閉;2表示打開;
//恢復遠程控制為非執行狀態
{
INT16U len=0,moveAddr=0;
uint8 paramValue=1; //遠程控制(1)解除
OS_ENTER_CRITICAL();
P2_GPIOSet((1 << 0)); //輸出高電平
OS_EXIT_CRITICAL();
RemoteCtrl_Status=0;
GetOmoveAddr(CUSTOM_PARAMS,CUSTOM_PARAMS_COUNT,0x000d,&len,&moveAddr);
memcpy(tempbuff+moveAddr,¶mValue,len); //將遠程控制解除保存。
}
//0x000e, //調度屏告警 占用1個字節,0表示未連接;1表示關閉;2表示打開;
//壓縮回傳 ACC開:15秒;ACC關:120秒;壓縮條數:10條
//設置壓縮回傳參數
//0x000f, // 需壓縮回傳的數據. 00:表示定位數據.01:表示帶工作參數的定位數據
//0x0010, //壓縮的時間間隔(ACC開).單位秒,最小為1秒。
//0x0011, //壓縮的時間間隔(ACC關).單位秒,最小為1秒。
//0x0012, //每包壓縮的位置數。 表示一個數據包可以包含的壓縮位置的數量,表示范圍10~33,默認值為33。
//0x0013, //壓縮回傳的次數. 表示需要壓縮回傳的次數,當改值為FFFFH時表示連續不斷的回傳,當該值為0000H表示停止發送。
{
INT16U len=0,moveAddr=0;
uint8 tempBuff[6];
setupCompressRevert.compressRevertData=0x01; // 需壓縮回傳的數據. 00:表示定位數據.01:表示帶工作參數的定位數據
tempBuff[0]=0x01;
setupCompressRevert.accIn_CompressTimeSlot=15; //壓縮的時間間隔(ACC開).單位秒,最小為1秒。
tempBuff[1]=15;
setupCompressRevert.accOut_CompressTimeSlot=120; //壓縮的時間間隔(ACC關).單位秒,最小為1秒。
tempBuff[2]=120;
setupCompressRevert.compress_PlaceCou=10; //每包壓縮的位置數。 表示一個數據包可以包含的壓縮位置的數量,表示范圍10~33,默認值為33。
tempBuff[3]=10;
setupCompressRevert.compressRevert_Cou=0x0000; //壓縮回傳的次數. 表示需要壓縮回傳的次數,當改值為FFFFH時表示連續不斷的回傳,當該值為0000H表示停止發送。
tempBuff[4]=0;
tempBuff[5]=0;
GetOmoveAddr(CUSTOM_PARAMS,CUSTOM_PARAMS_COUNT,0x000f,&len,&moveAddr); //得到壓縮回傳5個參數的存儲首地址偏移量
memcpy(tempbuff+moveAddr,tempBuff,sizeof(tempBuff));
}
//0x0014, //盲區保存的當前地址 占用4個字節
{
INT16U len=0,moveAddr=0;
uint8 tempBuff[4];
memset(tempBuff,0,sizeof(tempBuff));
cur_BlindSection_SaveAddr=0;
GetOmoveAddr(CUSTOM_PARAMS,CUSTOM_PARAMS_COUNT,0x0014,&len,&moveAddr);
memcpy(tempbuff+moveAddr,tempBuff,sizeof(tempBuff));
}
//0x0015, //盲區回傳的當前地址 占用4個字節
{
INT16U len=0,moveAddr=0;
uint8 tempBuff[4];
memset(tempBuff,0,sizeof(tempBuff));
cur_BlindSection_RepairAddr=0;
GetOmoveAddr(CUSTOM_PARAMS,CUSTOM_PARAMS_COUNT,0x0015,&len,&moveAddr);
memcpy(tempbuff+moveAddr,tempBuff,sizeof(tempBuff));
}
////////////////////////////////////////////////////////
W25X32_Erase_Semphore(CUSTOM_PARAMS_SEC, CUSTOM_PARAMS_SEC);
for(itemp=0;itemp<CUSTOM_PARAMS_DATASIZE/pageLen;itemp++)
{
W25X32_WR(GetAddr(CUSTOM_PARAMS_SEC,itemp*pageLen),tempbuff+itemp*pageLen,pageLen);
OSTimeDly(3);
}
if(CUSTOM_PARAMS_DATASIZE%pageLen>0)
{
OSTimeDly(3);
W25X32_WR(GetAddr(CUSTOM_PARAMS_SEC,itemp*pageLen),tempbuff+itemp*pageLen,CUSTOM_PARAMS_DATASIZE%pageLen);
}
OSMemPut(IntBuffer_Big,tempbuff);
}
return TRUE;
}
/*
//實際應用則為DataBagCmd真實函數體。
void DataBagCmd(void * item,INT16U commtype)
{
switch(commtype)
{
//INT16U i=0;
case D_setupComm: //4.3.1.4 設定參數(命令ID:0004H) 15
{
SetupParam_Item * temp;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -