飞利浦双串口51单片机485网关

news2024/11/27 10:26:04

主要功能将PC端的数据接收下来,分发到不同的设备,也是轮询设备数据读取回来,打包回传到PC端,数据包包头包尾识别,数据校验,接收超时处理,将协议结构化处理,协议的改动不需要改动程序,中断接收一帧完成置标志位交由上层协议程序校验并处理转发

协议格式定义,每一个位都进行了定仪

#ifndef PROTOCOL_H
#define PROTOCOL_H
#include "define.h"
//IO_EMM_31
typedef struct 
{
	uchar Stx;
	uchar Length;
	uchar ID;
	uchar TollCollectorID[3];
	uchar LoginDuration[2];
	uchar VehicleClass;
	union
	{
	 	uchar byte;
		struct
		{
			uchar Payment:4;
			uchar Axle:4;
		}BIT;
	}AxlePaymentDisplay;
	union
	{
		uint word;
		uchar byte[2];
	}TollFare;
	union
	{
		uchar byte;
		struct
		{			
			uchar reserved:1;
			uchar Exit_LSS_Rlight:1;
			uchar BarrierClose:1;
			uchar BarrierOpen:1;
			uchar Entry_LSS_Rlight:1;
			uchar Entry_LSS_Glight:1;
			uchar LaneLog:1;
			uchar zero:1;
		}BIT;
	}TMU_Control1;
	union
	{
		uchar byte;
		struct
		{
			uchar EmergencyAlarm:1;
			uchar EvasionAlarm:1;
			uchar DiscrepancyAlarm:1;
			uchar MisregistrationAlarm:1;
			uchar reserved:1;
			uchar AxleDectorFault:1;
			uchar BoothEquipmentFault:1;
			uchar zero:1;
		}BIT;
	}TMU_Control2;
	union
	{
		uchar byte;
		struct
		{
			uchar EmergencyAlarmRstBut:1;
			uchar EvalsionAlarmRstBut:1;
			uchar DiscrepancyAlarmRstBut:1;
			uchar MisregistrationAlarmRstBut:1;
			uchar AxleDetectorOVerride:1;
			uchar KeyInOverrideSelect:1;
			uchar reserved:1;
			uchar zero:1;
		}BIT;
	}ConStatus1;
	union
	{
		uchar byte;
		struct
		{
			uchar resetved:4;
			uchar TMUCommFail:1;
			uchar TMUDimmerOverAct:1;
			uchar AllSignageDimmming:1;
			uchar zero:1;
		}BIT;
	}ConStatus2;
	union
	{
		uchar byte;
		struct
		{
			uchar reserved:1;
			uchar CanopyBeacon:1;
			uchar Entry_LSS_Rlight:1;
			uchar Entry_LSS_Glight:1;
			uchar TPS_Glight:1;
			uchar TPS_Rlight:1;
			uchar DimmingNormal:1;
			uchar zero:1;
		}BIT;
	}SignageControl;
	union
	{
		uchar byte;
		struct
		{
			uchar TPSCommFail:1;
			uchar reserve2:1;
			uchar reserve1:1;
			uchar TPSTempHigher70:1;
			uchar CLSCommFail:1;
			uchar CLSPixelFaultDetect:1;
			uchar CLSTempHigher70:1;
			uchar zero:1;
		}BIT;
	}TPS_CLSFaultStatus;
	union
	{
		uchar byte;
		struct
		{
			uchar EntryCommFail:1;
			uchar ExitCommFail:1;
			uchar RlightAspectHigher50:1;
			uchar RlightAspectHigher25:1;
			uchar TempHigher70:1;
			uchar reseved:1;
			uchar Rlight:1;
			uchar zero:1;
		}BIT;
	}ExitLSSStatus;
	union
	{
		uchar byte;
		struct
		{
			uchar GlightAspectHigher50:1;
			uchar GlightAspectHigher25:1;
			uchar RlightAspectHigher50:1;
			uchar RlightAspectHigher25:1;
			uchar TempHigher70:1;
			uchar Glight:1;
			uchar Rlight:1;
			uchar zero:1;
		}BIT;
	}EntryLSSStatus;
	union
	{
		uchar byte;
		struct
		{
			uchar ShortDetect:1;
			uchar reserved:2;
			uchar KickBarAlarm:1;
			uchar CabinetOpen:1;
			uchar BarrierColse:1;
			uchar BarrierOpen:1;
			uchar zero:1;
		}BIT;
	}LocalIOInputStatus;
	union
	{
		uchar byte;
		struct
		{
			uchar Class0:1;
			uchar Class1:1;
			uchar Class2:1;
			uchar Class3:1;
			uchar Class4:1;
			uchar Class5:1;
			uchar Class6:1;
			uchar zero:1;
		}BIT;
	}AutoTollInputStatus1;
	union
	{
		uchar byte;
		struct
		{
			uchar Class7:1;
			uchar Class8:1;
			uchar Class9:1;
			uchar ClassAdd1:1;
			uchar LaneOpen:1;
			uchar LaneClose:1;
			uchar reserved:1;
			uchar zero:1;
		}BIT;
	}AutoTollInputStatus2;
	union
	{
		uchar byte;
		struct
		{
			uchar Axle1:1;
			uchar Axle2:1;
			uchar Axle3:1;
			uchar Axle4:1;
			uchar Axle5:1;
			uchar Axle6:1;
			uchar reserved:1;
			uchar zero:1;
		}BIT;
	}AutoTollInputStatus3;
	uchar Checksum;
	uchar Etx;
}IO_EMM_31;

//IO_EMM_32
typedef struct
{
	uchar Stx;
	uchar Length;
	uchar ID;
	union
	{
		uchar byte;
		struct
		{
			uchar reserved:1;
			uchar Dimmer:3;
			uchar Normal:3;
			uchar zero:1;
		}BIT;
	}TPSSetting;
	union
	{
		uchar byte;
		struct
		{
			uchar reserved:1;
			uchar Dimmer:3;
			uchar Normal:3;
			uchar zero:1;
		}BIT;
	}CLSSetting;
	union
	{
		uchar byte;
		struct
		{
			uchar reserved:1;
			uchar Dimmer:3;
			uchar Normal:3;
			uchar zero:1;
		}BIT;
	}EntryLSSSetting;
	union
	{
		uchar byte;
		struct
		{
			uchar reserved:1;
			uchar Dimmer:3;
			uchar Normal:3;
			uchar Zero:1;
		}BIT;
	}ExitLSSSetting;
	uchar Checksum;
	uchar Etx;
}IO_EMM_32;

//IO_TMU
typedef struct
{
	uchar Stx;
	uchar Length;
	uchar ID;
	uchar TollCollectorID[3];
	uchar LoginDuration[2];
	uchar VehicleClass;
	union
	{
	 	uchar byte;
		struct
		{
			uchar Payment:4;
			uchar Axle:4;
		}BIT;
	}AxlePaymentDisplay;
	union
	{
		uchar byte;
		struct
		{			
			uchar reserved:1;
			uchar Exit_LSS_Rlight:1;
			uchar BarrierClose:1;
			uchar BarrierOpen:1;
			uchar Entry_LSS_Rlight:1;
			uchar Entry_LSS_Glight:1;
			uchar LaneLog:1;
			uchar zero:1;
		}BIT;
	}TMU_Control1;
	union
	{
		uchar byte;
		struct
		{
			uchar EmergencyAlarm:1;
			uchar EvasionAlarm:1;
			uchar DiscrepancyAlarm:1;
			uchar MisregistrationAlarm:1;
			uchar reserved:1;
			uchar AxleDectorFault:1;
			uchar BoothEquipmentFault:1;
			uchar zero:1;
		}BIT;
	}TMU_Control2;
	union
	{
		uchar byte;
		struct
		{
			uchar EmergencyAlarmRstBut:1;
			uchar EvalsionAlarmRstBut:1;
			uchar DiscrepancyAlarmRstBut:1;
			uchar MisregistrationAlarmRstBut:1;
			uchar AxleDetectorOVerride:1;
			uchar KeyInOverrideSelect:1;
			uchar reserved:1;
			uchar zero:1;
		}BIT;
	}ConStatus1;
	union
	{
		uchar byte;
		struct
		{
			uchar resetved:5;
			uchar TMUDimmerOverAct:1;
			uchar AllSignageDimming:1;
			uchar zero:1;
		}BIT;
	}ConStatus2;
	uchar Checksum;
	uchar Etx;
}IO_TMU;

//IO_TPS
typedef struct
{
	uchar Stx;
	uchar Length;
	uchar ID;
	union
	{
		uint word;
		uchar byte[2];
	}TollFare;
	union
	{
		uchar byte;
		struct
		{
			uchar DispPleasePaid:1;
			uchar DispThankyou:1;
			uchar Rlight:1;
			uchar Glight:1;
			uchar BrightnessControl:3;
			uchar reserved:1;
		}BIT;
	}LedDisplay;
	union
	{
		uchar byte;
		struct
		{
			uchar TempHigher70:1;
			uchar reserved:7;
		}BIT;
	}Status;
	uchar Checksum;
	uchar Etx;
}IO_TPS;

//IO_CLS
typedef struct
{
	uchar Stx;
	uchar Length;
	uchar ID;
	uchar VehicleClass;
	union
	{
		uchar byte;
		struct
		{
			uchar Axle:3;
			uchar reserved1:1;
			uchar RelayContactClose:1;
			uchar reserved2:3;
		}BIT;
	}AxleCounterDisplay;
	union
	{
		uchar byte;
		struct
		{
			uchar reserved:4;
			uchar Brightness:3;
			uchar zero:1;
		}BIT;
	}BrightnessControl;
	union
	{
		uchar byte;
		struct
		{
			uchar TempHigher70:1;
			uchar PixelFaultDetected:1;
			uchar reserved:6;
		}BIT;
	}Status;
	uchar Checksum;
	uchar Etx;
}IO_CLS;

//IO_LSS
typedef struct
{
	uchar Stx;
	uchar Length;
	uchar ID;
	union
	{
		uchar byte;
		struct
		{
			uchar Rlight:1;
			uchar Glight:1;
			uchar reserved:6;			
		}BIT;
	}SignalDisp;
	union
	{
		uchar byte;
		struct
		{
			uchar RlightAspectHigher25:1;
			uchar RlightAspectHigher50:1;
			uchar GlightAspectHigher25:1;
			uchar GlightAspectHigher50:1;
			uchar BrightnessControl:3;
			uchar reserved:1;			
		}BIT;
	}Status1;
	union
	{
		uchar byte;
		struct
		{
			uchar TempHigher70:1;
			uchar reserved:7;
		}BIT;
	}Status2;
	uchar Checksum;
	uchar Etx;
}IO_LSS;

typedef struct
{
	uchar Dimmer;
	uchar Normal;
}BRIGHTNESS;
#endif

中断接收与发送

void IntUart0Rx( void ) interrupt 4
{
	uchar temp;
	static uchar MsgLen;
	if( RI_0 )
	{
		RI_0 = 0;
		temp = S0BUF;
		Timer1ms[TIMER_COM_DEV].Tick = 10;
		Timer1ms[TIMER_COM_DEV].Flg.BIT.Enable = 1;

		Timer[TIMER_RESPONSE].Tick = 5;

		ACC = temp;
		if( P==RB8_0 )
		{
			if( !DevStrEndFlg )
			{
				if( temp==0xaa )
				{									  
					DevStrEndFlg = 1;
					IO2Dev.RecvPtr = 0;
					IO2Dev.RecvBuf[IO2Dev.RecvPtr++] = temp;
					IO2Dev.Error.byte = 0;
				}
			}
			else
			{
				if( temp==0xab && IO2Dev.RecvPtr==MsgLen )
				{
					DevStrEndFlg = 0;
					IO2Dev.RecvBuf[IO2Dev.RecvPtr++] = temp;
					IO2Dev.Flg.BIT.Recv = 1;
					IO2Dev.RecvLen = IO2Dev.RecvPtr;
				}/*
				else if( temp==0xaa  && IO2Dev.RecvPtr!=MsgLen-1 )
				{
					IO2Dev.RecvPtr = 0;
					IO2Dev.RecvBuf[IO2Dev.RecvPtr++] = temp;
				}*/
				else if( IO2Dev.RecvPtr==2 )
				{
					IO2Dev.ID = temp;
					IO2Dev.RecvBuf[IO2Dev.RecvPtr++] = temp;
					switch( IO2Dev.ID )
					{
						case IO_TMU_ID:
							MsgLen = sizeof( IO_TMU )-1;
							break;
						case IO_TPS_ID:
							MsgLen = sizeof( IO_TPS )-1;
							break;
						case IO_CLS_ID:
							MsgLen = sizeof( IO_CLS )-1;
							break;
						case IO_ELSS_ID:
							MsgLen = sizeof( IO_LSS )-1;
							break;
						case IO_XLSS_ID:
							MsgLen = sizeof( IO_LSS )-1;
							break;
						default:
							DevStrEndFlg = 0;
					}
				}
				else if( IO2Dev.RecvPtr<RECVBUF_LEN )
				{
					IO2Dev.RecvBuf[IO2Dev.RecvPtr++] = temp;
				}
				else  //接收数据溢出
				{
					DevStrEndFlg = 0;
					IO2Dev.RecvPtr = 0;
				}
//				flg = IO2Dev.RecvPtr;
			}
		}
		else
		{
			IO2Dev.Error.BIT.Even = 1;
		}
	}
	else if( S0STAT&0x08 )//Framing Error
	{
		S0STAT &= ~0x08;
		IO2Dev.Error.BIT.Framing = 1;
	}
	else if( S0STAT&0x04 )//Break Detect
	{
		S0STAT &= ~0x04;
		IO2Dev.Error.BIT.BreakDetect = 1;
	}
	else if( S0STAT&0x02 )//Overrun Error
	{
		S0STAT &= ~0x02;
		IO2Dev.Error.BIT.Overrun = 1;
	}
}

//串行口0的发送中断程序
void IntUart0Tx( void ) interrupt 7
{
	Uart0SendData();
}

以指针提取数据
在这里插入图片描述

#include "Emm2IO.h"
#include "com.h"
#include "protocol.h"
#include "systemtask.h"
#include "IOCheck.h"

IO_EMM_31 IOEmm31;
extern BUF_DEF Emm2IO;
extern IO_TMU IOTmu;
extern IO_TPS IOTps;
extern IO_CLS IOCls;
extern IO_LSS IOEntryLss;
extern IO_LSS IOExitLss;
extern BRIGHTNESS TpsBrightness,ClsBrightness,EntryLssBrightness,ExitLssBrightness;

extern IO_CHECK_DEF IoCheck;
extern TIMER_DEF Timer[TIMER_NUM];
extern uchar flg;
void Emm2IOInit( void )
{
	//31
	IOEmm31.Stx = 0xaa;
	IOEmm31.Length = 0x18;
	IOEmm31.ID = 0x20;
	IOEmm31.ConStatus1.byte = 0;
	IOEmm31.ConStatus2.byte = 0x10;
	IOEmm31.TPS_CLSFaultStatus.byte = 0x11;
	IOEmm31.ExitLSSStatus.byte = 0x03;
	IOEmm31.EntryLSSStatus.byte = 0x00;
	IOEmm31.LocalIOInputStatus.byte = 0x00;
	IOEmm31.AutoTollInputStatus1.byte = 0x00;
	IOEmm31.AutoTollInputStatus2.byte = 0x00;
	IOEmm31.AutoTollInputStatus3.byte = 0x00;
	IOEmm31.Etx = 0xab;

	Emm2IO.Flg.byte = 0;
	Emm2IO.SendLen = 0;
	Emm2IO.RecvLen = 0;
	Emm2IO.SendPtr = 0;
	Emm2IO.RecvPtr = 0;

	Timer[TIMER_STOP].Flg.BIT.TimeOut = 0;
	Timer[TIMER_STOP].Tick = 500;
	Timer[TIMER_STOP].Flg.BIT.Enable = 1;
}
//从Emm2IOController31的接收数据中取出需要的内容放到设备缓冲区中
void CopyEmm31ToDev( IO_EMM_31 *IoEmm31Ptr )
{
	//TMU
	IOTmu.TollCollectorID[0] = IoEmm31Ptr->TollCollectorID[0];
	IOTmu.TollCollectorID[1] = IoEmm31Ptr->TollCollectorID[1];
	IOTmu.TollCollectorID[2] = IoEmm31Ptr->TollCollectorID[2];
	IOTmu.LoginDuration[0] = IoEmm31Ptr->LoginDuration[0];
	IOTmu.LoginDuration[1] = IoEmm31Ptr->LoginDuration[1];
	IOTmu.VehicleClass = IoEmm31Ptr->VehicleClass;
	IOTmu.AxlePaymentDisplay.byte = IoEmm31Ptr->AxlePaymentDisplay.byte;
	IOTmu.TMU_Control1.byte = IoEmm31Ptr->TMU_Control1.byte;
	IOTmu.TMU_Control2.byte = IoEmm31Ptr->TMU_Control2.byte;
	//TPS
	IOTps.TollFare.byte[0] = IoEmm31Ptr->TollFare.byte[0];
	IOTps.TollFare.byte[1] = IoEmm31Ptr->TollFare.byte[1];
	IOTps.LedDisplay.BIT.Glight = IoEmm31Ptr->SignageControl.BIT.TPS_Glight;
	IOTps.LedDisplay.BIT.Rlight = IoEmm31Ptr->SignageControl.BIT.TPS_Rlight;
	if( (((IoEmm31Ptr->TollFare.byte[0]&0xf0)>>4) == 0x000c) && (IoEmm31Ptr->AxlePaymentDisplay.BIT.Payment == 0x0b) )
	{
		IOTps.LedDisplay.BIT.DispPleasePaid = 1;
		IOTps.LedDisplay.BIT.DispThankyou = 0;
	}
	else if( (((IoEmm31Ptr->TollFare.byte[0]&0xf0)>>4) == 0x0000c) && (IoEmm31Ptr->AxlePaymentDisplay.BIT.Payment != 0x0b) )
	{
		IOTps.LedDisplay.BIT.DispPleasePaid = 0;
		IOTps.LedDisplay.BIT.DispThankyou = 1;
	}
	else if( ((IoEmm31Ptr->TollFare.byte[0]&0xf0)>>4) == 0x0000b )
	{
		IOTps.LedDisplay.BIT.DispPleasePaid = 0;
		IOTps.LedDisplay.BIT.DispThankyou = 0;
	}
	else
	{
		IOTps.LedDisplay.BIT.DispPleasePaid = 0;
		IOTps.LedDisplay.BIT.DispThankyou = 0;
	}
	//CLS
	IOCls.VehicleClass = IoEmm31Ptr->VehicleClass;
	if( IoEmm31Ptr->AxlePaymentDisplay.BIT.Axle>0 && IoEmm31Ptr->AxlePaymentDisplay.BIT.Axle<7 )
	{
		IOCls.AxleCounterDisplay.BIT.Axle = IoEmm31Ptr->AxlePaymentDisplay.BIT.Axle;
	}
	else
	{
		IOCls.AxleCounterDisplay.BIT.Axle = 0;
	}
	IOCls.AxleCounterDisplay.BIT.RelayContactClose = IoEmm31Ptr->SignageControl.BIT.CanopyBeacon;
	//EntryLSS
	IOEntryLss.SignalDisp.BIT.Rlight = IoEmm31Ptr->SignageControl.BIT.Entry_LSS_Rlight;
	if( IoEmm31Ptr->SignageControl.BIT.Entry_LSS_Glight && IOEmm31.LocalIOInputStatus.BIT.BarrierOpen &&
		!IOEmm31.LocalIOInputStatus.BIT.BarrierColse )
	{
		IOEntryLss.SignalDisp.BIT.Glight = 1;
		IOEntryLss.SignalDisp.BIT.Rlight = 0;
	}
	else
	{
		IOEntryLss.SignalDisp.BIT.Glight = 0;
		IOEntryLss.SignalDisp.BIT.Rlight = 1;
	}
	//ExitLSS
	if( IoEmm31Ptr->SignageControl.BIT.DimmingNormal )
	{
		IOTps.LedDisplay.BIT.BrightnessControl = TpsBrightness.Dimmer;
		IOCls.BrightnessControl.BIT.Brightness = ClsBrightness.Dimmer;
		IOEntryLss.Status1.BIT.BrightnessControl = EntryLssBrightness.Dimmer;
		IOExitLss.Status1.BIT.BrightnessControl = ExitLssBrightness.Dimmer;
	}
	else
	{
		IOTps.LedDisplay.BIT.BrightnessControl = TpsBrightness.Normal;
		IOCls.BrightnessControl.BIT.Brightness = ClsBrightness.Normal;
		IOEntryLss.Status1.BIT.BrightnessControl = EntryLssBrightness.Normal;
		IOExitLss.Status1.BIT.BrightnessControl = ExitLssBrightness.Normal;
	}
}
//从接收的Emm2IOController31的数据更新Emm31缓冲区
void CopyEmm31ToEmm31Buf( IO_EMM_31 *IoEmm31Ptr )
{
	uchar *Sptr,*Dptr,i;
	Sptr = (uchar*)IoEmm31Ptr;
	Dptr = (uchar*)&IOEmm31;
	for( i=0; i<11; i++ )
	{
		*(Dptr+i+3) = *(Sptr+i+3);
	}
	*(Dptr+16) = *(Sptr+16);
}
//更新各设备的亮度值
void CopyEmm32ToDev( IO_EMM_32 *IoEmm32Ptr )
{
	//TPS
	TpsBrightness.Dimmer = IoEmm32Ptr->TPSSetting.BIT.Dimmer;
	TpsBrightness.Normal = IoEmm32Ptr->TPSSetting.BIT.Normal;
	//CLS
	ClsBrightness.Dimmer = IoEmm32Ptr->CLSSetting.BIT.Dimmer;
	ClsBrightness.Normal = IoEmm32Ptr->CLSSetting.BIT.Normal;
	//EntryLSS
	EntryLssBrightness.Dimmer = IoEmm32Ptr->EntryLSSSetting.BIT.Dimmer;
	EntryLssBrightness.Normal = IoEmm32Ptr->EntryLSSSetting.BIT.Normal;
	//ExitLSS
	ExitLssBrightness.Dimmer = IoEmm32Ptr->ExitLSSSetting.BIT.Dimmer;
	ExitLssBrightness.Normal = IoEmm32Ptr->ExitLSSSetting.BIT.Normal;
}
//判断是否已从EMM接收完整的数据包,并进行处理
void Emm2IOMain( void )
{
	uchar ver,*ptr;
	IO_EMM_31 *IoEmm31Ptr;
	IO_EMM_32 *IoEmm32Ptr;
	if( Emm2IO.Flg.BIT.Recv )
	{
		Emm2IO.Flg.BIT.Recv = 0;

		Timer[TIMER_STOP].Tick = 500;
		Timer[TIMER_STOP].Flg.BIT.Enable = 1;

		if( Emm2IO.Error.byte == 0 )
		{
			ver = Checksum( &Emm2IO.RecvBuf[1],Emm2IO.RecvLen-3 );
			if( Emm2IO.ID==EMM_IO31_ID )
			{
				IoEmm31Ptr = (IO_EMM_31 *)Emm2IO.RecvBuf;
				if( ver==IoEmm31Ptr->Checksum )
				{
					CopyEmm31ToDev( IoEmm31Ptr );
					CopyEmm31ToEmm31Buf( IoEmm31Ptr );
					ptr = (uchar*)&IOEmm31;
					ptr++;
//					IOEmm31.AutoTollInputStatus3.byte = IoCheck.SaveState.byte[3];
//					IOEmm31.LocalIOInputStatus.byte = IoCheck.SaveState.byte[0];
//					IOEmm31.AutoTollInputStatus1.byte = IoCheck.SaveState.byte[1];
//					IOEmm31.AutoTollInputStatus2.byte = IoCheck.SaveState.byte[2];
//					IOEmm31.AutoTollInputStatus3.byte = IoCheck.SaveState.byte[3];
					ver = Checksum( ptr,sizeof(IO_EMM_31)-3 );
					IOEmm31.Checksum = ver;
					CopyToUart1SendBuf( (uchar*)&IOEmm31, sizeof(IO_EMM_31) );
				}
			}
			else if( Emm2IO.ID==EMM_IO32_ID )
			{
				IoEmm32Ptr = (IO_EMM_32 *)Emm2IO.RecvBuf;
				if( ver==IoEmm32Ptr->Checksum )
				{
					CopyEmm32ToDev( IoEmm32Ptr );
					CopyToUart1SendBuf( (uchar*)IoEmm32Ptr, sizeof(IO_EMM_32) );
				}
			}
		}
		else
		{
			Emm2IO.Error.byte = 0;
		}
		Emm2IO.RecvPtr = 0;
		Emm2IO.ID = 0;
	}
	//When no polling with EMM > 5 seconds.
	if( Timer[TIMER_STOP].Flg.BIT.TimeOut )
	{
		Timer[TIMER_STOP].Flg.BIT.TimeOut = 0;
		//TMU
		IOTmu.TollCollectorID[0] = 0x0b;
		IOTmu.TollCollectorID[1] = 0xbb;
		IOTmu.TollCollectorID[2] = 0xbb;
		IOTmu.LoginDuration[0] = 0xbb;
		IOTmu.LoginDuration[1] = 0xbb;
		IOTmu.VehicleClass = 0xbb;
		IOTmu.AxlePaymentDisplay.byte = 0xbb;
		IOTmu.TMU_Control1.byte = 0x00;
		IOTmu.TMU_Control2.byte = 0x40;
		//TPS
		IOTps.TollFare.word = 0xbbbb;
		IOTps.LedDisplay.BIT.Rlight = 1;
		IOTps.LedDisplay.BIT.Glight = 0;
		IOTps.LedDisplay.BIT.DispPleasePaid = 0;
		IOTps.LedDisplay.BIT.DispThankyou = 0;
		//CLS
		IOCls.VehicleClass = 0xbb;
		IOCls.AxleCounterDisplay.byte = 0x00;
		//Entry Lss
		IOEntryLss.SignalDisp.byte = 0x01;
		//Exit Lss
		IOExitLss.SignalDisp.byte = 0x01;
	}
}

主程序循环,
在这里插入图片描述
代码多年前写,基于飞利浦双串口单片机,程序结构是大循环前后台标志,就算现在用上了linux、rtos等的方式,程序接收处理方式差别不大,只是实现起来更简单

下面是完整工程连接
链接:https://pan.baidu.com/s/1bXOrMRH6Gf7kcjra4uANtA?pwd=1234
提取码:1234

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1146517.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Python 算法高级篇:图的表示与存储优化

Python 算法高级篇&#xff1a;图的表示与存储优化 引言 1. 什么是图&#xff1f;2. 图的基本概念3. 图的表示方法3.1. 临接矩阵表示临接矩阵的优点&#xff1a;临接矩阵的缺点&#xff1a; 3.2. 邻接表表示邻接表的优点&#xff1a;邻接表的缺点&#xff1a; 4. 优化的存储方法…

开机流程、模块管理

一、开机流程 Linux系统组成 kernel 实现进程管理、内存管理、网络管理、驱动程序、文件系统、安全功能等功能rootfs 包括程序和 glibc 库 ​ 程序&#xff1a;二进制执行文件​ 库&#xff1a;函数集合, function, 调用接口&#xff08;头文件负责描述&#xff09; 开机流程…

13.6性能测试理论

一.什么是性能测试 1.定义: 测试人员借助性能测试工具(LoadRunner等),模拟系统在不同场景下(使用高峰期等),对应的性能指标是否达到预期. 2.性能测试和功能测试的区别: a.功能测试依靠人工,性能测试依靠工具. b)功能测试要求软件能正常运行,不管什么场景,性能测试要求软件…

[双指针] (二) LeetCode 202.快乐数 和 11.盛最多水的容器

[双指针] (二) LeetCode 202.快乐数 和 11.盛最多水的容器 快乐数 202. 快乐数 题目解析 (1) 判断一个数是不是快乐数 (2) 快乐数的定义&#xff1a;将整数替换为每个位上的和&#xff1b;如果最终结果为1&#xff0c;就是快乐数 (3) 这个数可能变为1&#xff0c;也可能无…

ESP-IDF编程指南

ESP-IDF 编程指南 - ESP32-C3 - — ESP-IDF 编程指南 v5.1 文档 (espressif.com) ESP-IDF 入门指南 | 乐鑫科技 (espressif.com) ESP-IDF 物联网开发框架 | 乐鑫科技 (espressif.com.cn)

【Git企业开发】第二节.Git 的分支管理

作者简介&#xff1a;大家好&#xff0c;我是未央&#xff1b; 博客首页&#xff1a;未央.303 系列专栏&#xff1a;Git企业级开发 每日一句&#xff1a;人的一生&#xff0c;可以有所作为的时机只有一次&#xff0c;那就是现在&#xff01;&#xff01;&#xff01;&#xff0…

一款功能强大的iOS设备管理软件Mazing 3中文版免费2024最新下载

Mazing 3中文版是一款功能强大的iOS设备管理软件&#xff0c;它可以帮助用户备份和管理他们的iPhone、iPad或iPod Touch上的数据。除此之外&#xff0c;它还可以将备份数据转移到新的设备中、管理应用程序、导入和导出媒体文件等。本文将详细介绍iMazing的功能和安全性&#xf…

解读deepLabV3+时遇到的问题总结

环境问题 python &#xff1a;3.10.12 ModuleNotFoundError: No module named ‘torchvision.models.utils 起初pip以下这个包&#xff0c;也没有解决问题&#xff1b;后来发现是版本的问题。 #from torchvision.models.utils import load_state_dict_from_url from torch.…

机器人入门(四)—— 创建你的第一个虚拟小车

机器人入门&#xff08;四&#xff09;—— 创建你的第一个虚拟小车 一、小车建立过程1.1 dd_robot.urdf —— 建立身体1.2 dd_robot2.urdf —— 添加轮子1.3 dd_robot3.urdf —— 添加万向轮1.4 dd_robot4.urdf —— 添加颜色1.5 dd_robot5.urdf —— 添加碰撞检测(Collision …

印度财团欲代工iPhone,路虎是前车之鉴,印度制造仍在梦中

随着印度财团塔塔收购纬创即将落寞&#xff0c;印度电子与科技国务部长强德拉谢克&#xff08;Rajeev Chandrasekhar&#xff09;为塔塔站台&#xff0c;表示两年内塔塔将制造iPhone并出口海外市场&#xff0c;印度制造将由此起飞。 一、印度制造在路虎上梦破 塔塔集团收购路虎…

手把手教你:如何用Java多线程模拟银行叫号服务

大家好&#xff0c;我是小米&#xff01;今天&#xff0c;我将和大家一起探讨一个非常有趣的话题——Java多线程模拟银行叫号服务。这不仅是一个有趣的编程练习&#xff0c;还可以帮助我们更好地理解多线程编程和并发控制。在这篇文章中&#xff0c;我将带领大家一步步实现一个…

cmd基本命令

一、cmd黑框是什么 cmd 是 Windows 命令提示符&#xff08;cmd.exe&#xff09;是 Windows NT 及以后的 Windows 系统下的一个用于运行 Windows 控制面板程序或某些 DOS 程序的shell程序&#xff1b;或在 Windows CE 下只用于运行控制面板程序的外壳程序。 二、打开步骤 wind…

Tornado downloadable工程和Tornado bootable工程

目录 Tornado downloadable工程Tornado bootable工程 Tornado downloadable工程和Tornado bootable工程是两个不同类型的Tornado项目。 Tornado downloadable工程 Tornado downloadable工程是指可以通过下载安装程序来安装的Tornado项目,通常用于Web应用程序。这种工程通常包…

相亲APP哪个好用?找对象的相亲软件哪个能脱单?

现在市面上的相亲APP非常多&#xff0c;质量也参差不齐&#xff0c;需要我们自己去辨别才能找到靠谱的&#xff0c;但是这很浪费时间。所以今天就分享几个我用过靠谱的相亲APP给大家参考&#xff0c;也算是提供一点经验。 1、一伴婚恋 这款相亲软件的优势在于&#xff0c;每个…

IOC课程整理-19 Spring Environment 抽象

1. 理解 Spring Environment 抽象 2. Spring Environment 接口使用场景 3. Environment 占位符处理 4. 理解条件配置 Spring Profiles 5. Spring 4 重构 Profile 6. 依赖注入 Environment 7. 依赖查找 Environment 8. 依赖注入 Value 9. Spring 类型转换在 Environment 中的运用…

使用dirhunt无需暴力破解即可扫描Web目录

Dirhunt 是一个针对搜索和分析目录进行优化的网络爬虫。如果服务器启用了“index of”模式&#xff0c;则该工具可以找到有趣的东西。如果未启用目录列表&#xff0c;Dirhunt 也很有用。它可以检测带有虚假 404 错误的目录、创建空索引文件以隐藏内容的目录等等。 Dirhunt 不使…

万字解析设计模式之工厂方法模式与简单工厂模式

一、概述 1.1简介 在java中&#xff0c;万物皆对象&#xff0c;这些对象都需要创建&#xff0c;如果创建的时候直接new该对象&#xff0c;就会对该对象耦合严重&#xff0c;假如我们要更换对象&#xff0c;所有new对象的地方都需要修改一遍&#xff0c;这显然违背了软件设计的…

麒麟KYLINOS2303版本上使用KDE桌面共享软件

原文链接&#xff1a;麒麟KYLINOS2303版本上使用KDE桌面共享软件 hello&#xff0c;大家好啊&#xff0c;今天给大家推荐一个在麒麟KYLINOS桌面操作系统2303版本上使用KDE桌面共享软件的文章&#xff0c;通过安装KDE桌面共享软件&#xff0c;可以让远程vnc客户端连接访问本机桌…

飞鼠异地组网工具基本使用教程

飞飞鼠异地组网工具基本使用教程 一、飞鼠工具介绍1.1 飞鼠工具简介1.2 飞鼠工具特点1.3 飞鼠工具使用场景1.4 飞鼠工具官网1.5 飞鼠工具版本介绍1.6 飞鼠工具节点类型 二、本次实践介绍2.1 本次实践简介2.2 本次环境规划 三、Docker环境安装工作3.1 master节点安装Docker3.2 子…

2023年【湖南省安全员-C证】新版试题及湖南省安全员-C证证考试

题库来源&#xff1a;安全生产模拟考试一点通公众号小程序 湖南省安全员-C证新版试题是安全生产模拟考试一点通总题库中生成的一套湖南省安全员-C证证考试&#xff0c;安全生产模拟考试一点通上湖南省安全员-C证作业手机同步练习。2023年【湖南省安全员-C证】新版试题及湖南省…