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

主要功能将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

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Python学习笔记--初始化函数

六、初始化函数 1、什么是初始化函数 初始化函数的意思是&#xff0c;当你创建一个实例的时候&#xff0c;这个函数就会被调用。 比如&#xff1a; 当代码在执行 a ClassA() 的语句时&#xff0c;就自动调用了 __init__(self) 函数。 而这个 __init__(self) 函数就是初始化…

为什么数组的下标是从0开始呢?

我们在许多的编程语言中&#xff0c;大部分的数组下标都是从零开始的&#xff0c;那为什么不是从一开始的呢&#xff1f; 首先我们&#xff0c;先要了解数组相关的定义。 数组&#xff08;Array&#xff09;是一种线性表数据结构。它用一组连续的内存空间&#xff0c;来存储一…

【Linux】虚拟机安装Linux、客户端工具及Linux常用命令(详细教程)

目录 一、导言 1、引言 2、使用场景 二、Linux安装 1、安装 2、网络配置 2.1、查看网络配置 2.2、更改网络配置 三、安装客户端工具 1、介绍 2、安装MobaXterm 3、换源 4、拍照功能 四、常用命令 一、导言 1、引言 Linux是一个开源的操作系统内核&#xff0c;它最…

粤嵌实训医疗项目--day03(Vue + SpringBoot)

往期回顾 粤嵌实训医疗项目day02&#xff08;Vue SpringBoot&#xff09;-CSDN博客 粤嵌实训医疗项目--day01&#xff08;VueSpringBoot&#xff09;-CSDN博客 目录 一、SpringBoot AOP的使用 二、用户模块-注册功能&#xff08;文件上传&#xff09; 三、用户模块-注册实现…

【SpringBoot】Docker部署

docker部署是主流的部署方式&#xff0c;极大的方便了开发部署环境&#xff0c;保持了环境的统一&#xff0c;也是实现自动化部署的前提。 1 项目的目录结构 package: 点击打包&#xff0c;生成 xxx-SNAPSHOT.jar target目录: 打包生成目录&#xff0c;生成的jar存放位置Docke…

D-Nerf:用于动态场景表示的神经辐射场

Pumarola A, Corona E, Pons-Moll G, et al. D-nerf: Neural radiance fields for dynamic scenes[C]//Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2021: 10318-10327. D-Nerf 较 NeRF 的改进 1 就是能够建模移动或变形的物体&#…

分享个包含各省、市、区的编码数据的在线静态资源脚本

在翻《SpringBootVue3》——十三尼克陈作者的大型前后端分离项目实战里面&#xff0c;在看到地址管理的部分时&#xff0c;发现了该作者记录有一个静态的地址资源脚本 这里做个记录&#xff0c;打点 一、引入js <script src"https://s.yezgea02.com/1641120061385/td…

python opencv之图像分割、计算面积

以下代码是一个基于K-means聚类算法进行图像分割的实现。通过读取一个彩色图像&#xff0c;将其转化为二维数组形式。然后使用K-means算法对像素点进行聚类&#xff0c;聚类个数为7。根据聚类后的标签值对像素点进行着色&#xff0c;并创建掩膜图像。接着使用形态学开运算和闭运…

C语言编写图形化界面-创建按钮-为其指定样式

文章目录 前置章节指定窗口样式给按钮加边框扁平化按钮复选框样式按钮自动复选框 单选按钮三态按钮自动三态按钮 默认按钮样式&#xff08;对话框Enter键&#xff09; 设置按钮位置和大小封装函数 前置章节 开始之前&#xff0c;需要学习以下章节&#xff1a; 创建窗口 窗口过…

Jupyter Notebook还有魔术命令?太好使了

在Jupyter Notebooks中&#xff0c;Magic commands&#xff08;以下简称魔术命令&#xff09;是一组便捷的功能&#xff0c;旨在解决数据分析中的一些常见问题&#xff0c;可以使用%lsmagic 命令查看所有可用的魔术命令 插播&#xff0c;更多文字总结指南实用工具科技前沿动态…

【鸿蒙软件开发】Stage模型开发概述应用/组件级配置

文章目录 前言一、基本概念1.1 UIAbility 组件1.2 ExtensionAbility 组件1.3 Context1.4 AbilityStage1.5 Stage模型开发流程应用组件开发了解进程模型了解线程模型应用配置文件 二、Stage模型应用/组件级配置2.1 为什么需要这个操作2.2 应用包名配置2.3 应用图标和标签配置2.4…

[NSSCTF 2nd] web刷题记录

文章目录 php签到MyBox非预期解预期解 php签到 源代码 <?phpfunction waf($filename){$black_list array("ph", "htaccess", "ini");$ext pathinfo($filename, PATHINFO_EXTENSION);foreach ($black_list as $value) {if (stristr($ext, …

第三章 SysML入门|系统建模语言SysML实用指南学习

仅供个人学习记录 UML与SysML的联系 可以稍微参考UML与SysML的联系 UML&#xff08;统一建模语言&#xff09;和SysML&#xff08;系统建模语言&#xff09;是两种与建模相关的语言&#xff0c;它们之间存在联系和区别。 SysML的图分类如下图所示。 SysML 图概述 这里只…

施耐德Lexium23A运行JOG停止时无减速过程解决方案

在现场调试时发现&#xff0c;如果Lexium23A工作在Pr模式下&#xff0c;无论是通过CANopen总线控制软件DI接通&#xff08;相应DI点设置为JOG运行&#xff09;还是实际的物理点接通&#xff0c;在JOG停止时&#xff0c;伺服电机会瞬间停止&#xff0c;造成机械冲击&#xff0c;…

C语言char的取值范围以及溢出情况

char 的取值范围 有符号&#xff1a; 1111 1111 ~ 1000 0000 — 0000 0000 ~ 0111 1111 -127 ~ -0 0 ~ 127 -128 ~ 127&#xff08;因为不需要两个 0 所以给负值增加了一位&#xff09; char 的溢出情况

VScode 自定义主题各参数解析

参考链接&#xff1a; vscode自定义颜色时各个参数的作用(史上最全)vscode编辑器&#xff0c;自己喜欢的颜色 由于 VScode 搜索高亮是在是太不起眼了&#xff0c;根本看不到此时选中到哪个搜索匹配了&#xff0c;所以对此进行了配置&#xff0c;具体想增加更多可配置项可参考…

python随手小练8(南农作业题)

题目1: 输入3 门课程 a,b,c 的成绩,求 3 门成绩的总和平均值(整数,四舍五人)以及最高和最低值。如果3门课程考试成绩分别以权重 0.50.3 和0.2计人总评成绩(整数先求总和再四舍五入),则最终总评成绩是多少? 具体操作&#xff1a; a float(input("a:")) b float(in…

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

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

[python 刷题] 974 Subarray Sums Divisible by K

[python 刷题] 974 Subarray Sums Divisible by K 题目如下&#xff1a; Given an integer array nums and an integer k, return the number of non-empty subarrays that have a sum divisible by k. A subarray is a contiguous part of an array. 依旧是 prefix sum 的变种…

Hadoop3.0大数据处理学习3(MapReduce原理分析、日志归集、序列化机制、Yarn资源调度器)

MapReduce原理分析 什么是MapReduce 前言&#xff1a;如果想知道一堆牌中有多少张红桃&#xff0c;直接的方式是一张张的检查&#xff0c;并数出有多少张红桃。 而MapReduce的方法是&#xff0c;给所有的节点分配这堆牌&#xff0c;让每个节点计算自己手中有几张是红桃&#…