コード例 #1
0
ファイル: Menu_Include.c プロジェクト: glocklueng/BD_USART
void ReadEXspeed(unsigned char NumExspeed)
{
unsigned char i=0,j=0;
unsigned char Read_ChaosuData[32];

memset(Read_ChaosuData,0,sizeof(Read_ChaosuData));
data_tirexps[0]=NumExspeed;//总条数
for(i=0,j=0;i<NumExspeed;i++,j++)
	data_tirexps[1+j*32]=i+1;	
for(i=0;i<NumExspeed;i++)
	{
	Api_DFdirectory_Read(spd_warn,Read_ChaosuData,32,0,i); // 从new-->old  读取
    memcpy(&data_tirexps[i*32+2],Read_ChaosuData,31);
	}
}
コード例 #2
0
ファイル: Menu_Include.c プロジェクト: glocklueng/BD_USART
//  0   1            34             67
//(3)  1 [2-33]   2 [35-66]   3 [68-99]
void ReadPiLao(unsigned char NumPilao)
{
unsigned char i=0,j=0;
unsigned char Read_PilaoData[32];

memset(Read_PilaoData,0,sizeof(Read_PilaoData));
data_tirexps[0]=NumPilao;//总条数
for(i=0,j=0;i<NumPilao;i++,j++)
	data_tirexps[1+j*31]=i+1;	
for(i=0;i<NumPilao;i++)
	{
	Api_DFdirectory_Read(tired_warn,Read_PilaoData,31,0,i); // 从new-->old  读取
	memcpy(&data_tirexps[i*31+2],Read_PilaoData,30);
	}
}
コード例 #3
0
unsigned char Fetch_15minSpeed(unsigned char Num15)
{
unsigned char rec_num=0;
unsigned char i=0,j=0,k=0;
unsigned char Read_15minData[75];
unsigned int  kk=0;	
u8 temp_data=0,temp_time=0;
//数据格式:15 1 xx xx xx xx xx sp 2 xx xx xx xx xx sp ... ...15 xx xx xx xx xx sp
   
	if(avgspd_Mint_Wr>=15)
		{
		avgspd_Mint_Wr--;
		for(i=0;i<15;i++)
			{
			memcpy(&Speed_15min[2+i*7],Avrgspd_Mint.datetime,3);//BCD
			Speed_15min[2+i*7+3]=Temp_Gps_Gprs.Time[0];
			Speed_15min[2+i*7+4]=avgspd_Mint_Wr-14+i;//不是BCD码
			Speed_15min[2+i*7+5]=Avrgspd_Mint.avgrspd[avgspd_Mint_Wr-14+i];
			}
#if 0
//==================================================
//rt_kprintf("\r\n******当前分钟数>15********",rec_num);
rec_num=Api_DFdirectory_Query(spdpermin,0);	
//rt_kprintf("\r\n已有整小时记录条数(%d 条)",rec_num);
   if(rec_num)
    	{
    	Api_DFdirectory_Read(spdpermin,Read_15minData,70,0,0); // 从new-->old  读取
	/*rt_kprintf("\r\n(读取到)存储的最近一条整小时记录:");
	rt_kprintf("\r\n %2x/%2x/%2x   %2x:%2x\r\n",Read_15minData[0],Read_15minData[1],Read_15minData[2],Read_15minData[3],Read_15minData[4]);
		for(i=0;i<65;i++)
			{
			if(i%20==0)
				rt_kprintf("\r\n");
			rt_kprintf(" %2d",Read_15minData[i+5]);
			}
		rt_kprintf("\r\n存储的前一条数据读出完成\r\n");*/
		//判断读出的前一条记录是不是当前小时的前一个小时
		//if((Read_15minData[2]==Avrgspd_Mint.datetime[2])&&(Avrgspd_Mint.datetime[3]==(Read_15minData[3]+1)))
		temp_data=(Read_15minData[2]>>4)*10+(Read_15minData[2]&0x0f);
		temp_time=(Read_15minData[3]>>4)*10+(Read_15minData[3]&0x0f);
		//rt_kprintf("\r\n(读出)%d日,%d点\r\n",temp_data,temp_time);
		//rt_kprintf("\r\n(当前)%d日,%d点\r\n",Temp_Gps_Gprs.Date[2],Temp_Gps_Gprs.Time[0]);
   	}
   #endif
//==================================================
		
		}
コード例 #4
0
ファイル: Menu_5_8_usb.c プロジェクト: mildrock/705_1
/***********************************************************
* Function:
* Description:
* Input:
* Input:
* Output:
* Return:
* Others:
***********************************************************/
void thread_usbout_udisk( void* parameter )
{
#if 0

	void	( *msg )( void *p );
	int		fd = -1, size;
	u8		write_da[300]; //={"1234567890"};
	u8		write_data_record[50];
	u8		i		= 0;
	u16		len		= 0;
	u32		count	= 0;


	//车辆信息(  VIN 17 +  车牌号12  +  车牌分类 12 )
	memcpy( write_da, IMSI_CODE + 3, 12 );
	memcpy( write_da + 12, "00000", 5 );                                        //17位vin
	memcpy( write_da + 17, JT808Conf_struct.Vechicle_Info.Vech_Num, 12 );       //车牌号12
	memcpy( write_da + 29, JT808Conf_struct.Vechicle_Info.Vech_Type, 12 );      //车牌分类12
	//驾驶员信息 (  驾驶员代码 3 +驾驶证号码 18)
	memcpy( write_da + 41, JT808Conf_struct.Driver_Info.DriveCode, 3 );         //  驾驶员代码3
	memcpy( write_da + 44, JT808Conf_struct.Driver_Info.DriverCard_ID, 18 );    //驾驶证号码18
	// 开关量信息  1
	write_da[62] = Vehicle_sensor;
	//信息内容    条数2+内容
	write_da[63] = 0;

	msg = ( void ( * )( void* ) )parameter;

	ptr_write_packet = rt_malloc( 256 );
	if( ptr_write_packet == RT_NULL )
	{
		msg( "E内存不足" );
		return;
	}
	//ptr_write_packet=write_da;
/*查找U盘*/
	while( 1 )
	{
		if( rt_device_find( "udisk" ) == RT_NULL ) /*没有找到*/
		{
			count++;
			if( count <= 5 )
			{
				msg( "I等待U盘插入" );
			}else
			{
				msg( "EU盘不存在" ); /*指示U盘不存在*/
				usb_error = 1;
				goto end_usbdata_0;
			}
			rt_thread_delay( RT_TICK_PER_SECOND );
		}else
		{
			usb_error = 0;
			break;
		}
	}
	count = 0;

	while( 1 )
	{
		count++;
		rt_thread_delay( RT_TICK_PER_SECOND / 2 );
		usb_error = 0;
		// if(!USB_data_flag)
		//{
		if( DataOutStartFlag == 1 )
		{
			strcpy( (char*)TarName, "/udisk/ACCIDENT.TXT" );
		} else if( DataOutStartFlag == 2 )
		{
			strcpy( (char*)TarName, "/udisk/TIRED.TXT" );
		} else if( DataOutStartFlag == 3 )
		{
			strcpy( (char*)TarName, "/udisk/EXSPEED.TXT" );
		} else
		{
			break;
		}
		if( DataOutStartFlag )
		{
			fd = open( (const char*)TarName, ( O_CREAT | O_WRONLY | O_TRUNC ), 0 );
		}
		if( fd >= 0 )
		{
			//msg( "I打开文件成功" );
			rt_kprintf( "\n 打开文件成功" );

			if( DataOutStartFlag == 1 )         //疑点
			{
				write_da[64] = 1;
				//Api_DFdirectory_Read(doubt_data,write_da+65,206,0,1);
				len		= 271;                  //65+206
				size	= write( fd, write_da, len );
				rt_kprintf( "\n 导出疑点数据记录sizeof= %d ", size );
				data_fetch_comp = 1;
				msg( "I数据导出完成" );
				//goto end_usbdata_0;
			}else if( DataOutStartFlag == 2 )   //疲劳
			{

				write_da[64] = TiredDrv_write;
				if( TiredDrv_write >= 1 )
				{
					Api_DFdirectory_Read( tired_warn, write_data_record, 30, 0, TiredDrv_write );
					for( i = 0; i < TiredDrv_write; i++ )
					{
						memcpy( write_da + 65 + i * 12, write_data_record + 18 + i * 30, 12 );
					}
					//Api_DFdirectory_Read(tired_warn,write_da+65,30,0,TiredDrv_write);
				}
				len		= 65 + TiredDrv_write * 12;
				size	= write( fd, write_da, len );
				rt_kprintf( "\n 导出疲劳记录sizeof= %d ", size );
				data_fetch_comp = 1;

				msg( "I数据导出完成" );

				//goto end_usbdata_0;
			}else if( DataOutStartFlag == 3 ) //超速
			{

				write_da[64] = ExpSpdRec_write;
				if( ExpSpdRec_write >= 1 )
				{
					Api_DFdirectory_Read( spd_warn, write_data_record, 31, 0, ExpSpdRec_write );
					for( i = 0; i < ExpSpdRec_write; i++ )
					{
						memcpy( write_da + 65 + i * 13, write_data_record + 18 + i * 31, 12 );
					}
					//Api_DFdirectory_Read(spd_warn,write_da+65,31,0,TiredDrv_write);
				}
				len		= 65 + ExpSpdRec_write * 13;
				size	= write( fd, write_da, len );

				rt_kprintf( "\n 导出超速记录sizeof= %d ", size );

				data_fetch_comp = 1;
				msg( "I数据导出完成" );
				//goto end_usbdata_0;
			}
			close( fd );
			goto end_usbdata_0;
		}else
		{
			if( count >= 3 )
			{
				usb_error = 1;
				msg( "EU盘创建文件失败" );
				rt_kprintf( "\n创建文件失败" );
				break;
			}
		}
	}
end_usbdata_0:
	rt_free( ptr_write_packet );
	ptr_write_packet = RT_NULL;
#endif	
}
コード例 #5
0
void thread_usbout_udisk( void* parameter )
{

	void		( *msg )( void *p );
	int			fd = -1, size;
	u8 write_da[300];//={"1234567890"};
	u8 write_data_record[50];
	u8 i=0;
	u16 len=0;

	msg = (void (*)(void*))parameter;

	ptr_write_packet = rt_malloc(100);
	if( ptr_write_packet == RT_NULL )
	{
		msg( "E内存不足" );
		return;
	}
	ptr_write_packet=write_da;
/*查找U盘*/
	while( 1 )
	{
	if( rt_device_find( "udisk" ) == RT_NULL ) /*没有找到*/
		{
		msg( "EU盘不存在" ); /*指示U盘不存在*/
		rt_thread_delay( RT_TICK_PER_SECOND );		
		USB_insertFlag=1;
		}
	else
		{
	    USB_insertFlag=0;
		
        if(!USB_data_flag)
        	{
		    if(DataOutStartFlag==1)
		        strcpy( (char *)TarName, "/udisk/ACCIDENT.TXT" );
			else if(DataOutStartFlag==2)
				strcpy( (char *)TarName, "/udisk/TIRED.TXT" );
			else if(DataOutStartFlag==3)
				strcpy( (char *)TarName, "/udisk/EXSPEED.TXT" );
			
		    if(DataOutStartFlag)
				fd = open((const char*)TarName,(O_CREAT|O_WRONLY|O_TRUNC), 0 );			
			if( fd >= 0 )
				{
				//msg( "I打开文件成功" );
				rt_kprintf("\r\n 打开文件成功");
				//车辆信息(  VIN 17 +  车牌号12  +  车牌分类 12 )
				memcpy(write_da,JT808Conf_struct.Vechicle_Info.Vech_sim,12);
				memcpy(write_da+12,"00000",5);//17位vin
				memcpy(write_da+17,JT808Conf_struct.Vechicle_Info.Vech_Num,12);//车牌号12
				memcpy(write_da+29,JT808Conf_struct.Vechicle_Info.Vech_Type,12);//车牌分类12
				//驾驶员信息 (  驾驶员代码 3 +驾驶证号码 18)
				memcpy(write_da+41,JT808Conf_struct.Driver_Info.DriveCode,3);//  驾驶员代码3
				memcpy(write_da+44,JT808Conf_struct.Driver_Info.DriverCard_ID,18);//驾驶证号码18
                // 开关量信息  1
				write_da[62]=Vehicle_sensor;
				//信息内容    条数2+内容
				write_da[63]=0;	
				
			    if(DataOutStartFlag==1)//疑点
			    	{
			    	write_da[64]=1;
					Api_DFdirectory_Read(doubt_data,write_da+65,206,0,1);
					len=271;//65+206
					size = write( fd,write_da,len);
					rt_kprintf("\r\n 导出疑点数据记录sizeof= %d ",size); 
					data_fetch_comp=1;
					msg("I数据导出完成");
			    	}
				else if(DataOutStartFlag==2)//疲劳
					{
					write_da[64]=TiredDrv_write;
					if(TiredDrv_write>=1)
						{
						Api_DFdirectory_Read(tired_warn,write_data_record,30,0,TiredDrv_write);
						for(i=0;i<TiredDrv_write;i++)
							memcpy(write_da+65+i*12,write_data_record+18+i*30,12);
						//Api_DFdirectory_Read(tired_warn,write_da+65,30,0,TiredDrv_write);
						}
					len=65+TiredDrv_write*12;
					size = write( fd,write_da,len);
					rt_kprintf("\r\n 导出疲劳记录sizeof= %d ",size);
					data_fetch_comp=1;
					msg("I数据导出完成");
			    	}
				else if(DataOutStartFlag==3)//超速
					{
					write_da[64]=ExpSpdRec_write;
					if(ExpSpdRec_write>=1)
						{
						Api_DFdirectory_Read(spd_warn,write_data_record,31,0,ExpSpdRec_write);
						for(i=0;i<ExpSpdRec_write;i++)
							memcpy(write_da+65+i*13,write_data_record+18+i*31,12);
						//Api_DFdirectory_Read(spd_warn,write_da+65,31,0,TiredDrv_write);
						}
					len=65+ExpSpdRec_write*13;
					size = write( fd,write_da,len);
				    rt_kprintf("\r\n 导出超速记录sizeof= %d ",size);
					data_fetch_comp=1;
					msg("I数据导出完成");
			    	}
				
				}
			else
				msg( "E该文件不存在" );

			//size = write( fd,"0123456789",10);
			//rt_kprintf("\r\n sizeof= %d ",size);
			close(fd);
			DataOutOK=1;   //导出完成
			USB_data_flag=1;
        	}
		}
	rt_thread_delay(RT_TICK_PER_SECOND/2);
	}
}
コード例 #6
0
unsigned char Fetch_15minSpeed(unsigned char Num15)
{
unsigned char rec_num=0;
unsigned char i=0,j=0,k=0;
unsigned char Read_15minData[75];
unsigned int  kk=0;		 
//数据格式:15 1 xx xx xx xx xx sp 2 xx xx xx xx xx sp ... ...15 xx xx xx xx xx sp
    if(Temp_Gps_Gprs.Time[1]>=1)
    avgspd_Mint_Wr=Temp_Gps_Gprs.Time[1]-1;
	if(avgspd_Mint_Wr>=14)
		{
		//for(i=0;i<Num15;i++)
			//Speed_15min[1+j*7]=i+1;
		//avgspd_Mint_Wr=Temp_Gps_Gprs.Time[0];
		//if(Temp_Gps_Gprs.Time[1]>=1)
		    //avgspd_Mint_Wr=Temp_Gps_Gprs.Time[1]-1;
		//rt_kprintf("\r\n当前时间>=14min");
		for(i=0;i<15;i++)
			{
			memcpy(&Speed_15min[2+i*7],Avrgspd_Mint.datetime,3);//BCD
			Speed_15min[2+i*7+3]=Temp_Gps_Gprs.Time[0];
			Speed_15min[2+i*7+4]=avgspd_Mint_Wr-14+i;//不是BCD码
			Speed_15min[2+i*7+5]=Avrgspd_Mint.avgrspd[avgspd_Mint_Wr-14+i];
			}
		}
	else
		{
		rec_num=Api_DFdirectory_Query(spdpermin,0);	
		//rt_kprintf("\r\n已有整小时记录条数",rec_num);
		//rt_kprintf("\r\n当前分钟数<15,已有 %d 条,需要从前一小时内读取 %d 条",avgspd_Mint_Wr,(15-avgspd_Mint_Wr));
        if(rec_num)
        	{
        	Api_DFdirectory_Read(spdpermin,Read_15minData,70,0,0); // 从new-->old  读取
			//rt_kprintf("\r\n存储最近一条整小时记录:");
			//for(i=0;i<70;i++)
				//rt_kprintf(" %d",Read_15minData[i]);
			//rt_kprintf("\r\n");
			//判断读出的前一条记录是不是当前小时的前一个小时
			if((Read_15minData[2]==Avrgspd_Mint.datetime[2])&&(Avrgspd_Mint.datetime[3]==(Read_15minData[3]+1)))
				{
				for(i=0;i<(14-avgspd_Mint_Wr);i++)//avgspd_Mint_Wr 
					{
					//rt_kprintf(" %d",Read_15minData[64-(14-avgspd_Mint_Wr-1)+i]);//不需要读取存储的数据
					memcpy(&Speed_15min[2+i*7],Read_15minData,4);//yymmddhh
					Speed_15min[2+i*7+4]=60-(14-avgspd_Mint_Wr)+i;//mm
					Speed_15min[2+i*7+5]=Read_15minData[64-(13-avgspd_Mint_Wr)+i];//speed
					}
				k=i;
				}
			else//读出的前一条记录不是当前小时的前一个小时的数据
				{
				for(i=0;i<(14-avgspd_Mint_Wr);i++)//avgspd_Mint_Wr 
					{
					//rt_kprintf(" %d",Avrgspd_Mint.avgrspd[i]);//不需要读取存储的数据
					memcpy(&Speed_15min[2+i*7+k*7],Avrgspd_Mint.datetime,3);
					kk=(Avrgspd_Mint.datetime[3]>>4)*10+(Avrgspd_Mint.datetime[3]&0x0f)-1;
					Speed_15min[2+i*7+k*7+3]=((kk/10)<<4)+(kk%10);//
					Speed_15min[2+i*7+k*7+4]=60-(14-avgspd_Mint_Wr)+i;;
					Speed_15min[2+i*7+k*7+5]=0;
					}
				k=i;
				}
	        for(i=0;i<=avgspd_Mint_Wr;i++)
	        	{
				rt_kprintf(" %d",Avrgspd_Mint.avgrspd[i]);//不需要读取存储的数据 
				memcpy(&Speed_15min[2+i*7+k*7],Avrgspd_Mint.datetime,4);
				Speed_15min[2+i*7+k*7+4]=i;
				Speed_15min[2+i*7+k*7+5]=Avrgspd_Mint.avgrspd[i];
				}
        	}
		else //没有存过整小时的速度
			{
			//rt_kprintf("\r\n 没有整小时的数据存入 ");
			for(i=0;i<(14-avgspd_Mint_Wr);i++)//avgspd_Mint_Wr 
				{
				//rt_kprintf(" %d",Avrgspd_Mint.avgrspd[i]);//不需要读取存储的数据
				memcpy(&Speed_15min[2+i*7+k*7],Avrgspd_Mint.datetime,3);
				kk=(Avrgspd_Mint.datetime[3]>>4)*10+(Avrgspd_Mint.datetime[3]&0x0f)-1;
				Speed_15min[2+i*7+k*7+3]=((kk/10)<<4)+(kk%10);//
				Speed_15min[2+i*7+k*7+4]=60-(14-avgspd_Mint_Wr)+i;;
				Speed_15min[2+i*7+k*7+5]=0;
				}
			k=i;
			//rt_kprintf("\r\n  %d  条人为补充数据,  分钟数下标=%d",k,avgspd_Mint_Wr);
	        for(i=0;i<=avgspd_Mint_Wr;i++)
	        	{
				//rt_kprintf(" %d",Avrgspd_Mint.avgrspd[i]);//不需要读取存储的数据 
				memcpy(&Speed_15min[2+i*7+k*7],Avrgspd_Mint.datetime,4);
				Speed_15min[2+i*7+k*7+4]=i;
				Speed_15min[2+i*7+k*7+5]=Avrgspd_Mint.avgrspd[i];
				}
			}
		//rt_kprintf("\r\n 停车前15分钟车速读完");
		}