📄 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 + -