当前位置: 首页>>代码示例>>C#>>正文


C# ComPort.SetComPortSpec方法代码示例

本文整理汇总了C#中ComPort.SetComPortSpec方法的典型用法代码示例。如果您正苦于以下问题:C# ComPort.SetComPortSpec方法的具体用法?C# ComPort.SetComPortSpec怎么用?C# ComPort.SetComPortSpec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ComPort的用法示例。


在下文中一共展示了ComPort.SetComPortSpec方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ControlSystem

		/// <summary>
		/// Constructor of the Control System Class. Make sure the constructor always exists.
		/// If it doesn't exit, the code will not run on your 3-Series processor.
		/// </summary>
		public ControlSystem() : base()
		{
			// subscribe to control system events
			CrestronEnvironment.SystemEventHandler += new SystemEventHandler(CrestronEnvironment_SystemEventHandler);
			CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
			CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler);
			
			// Set the number of threads which you want to use in your program - At this point the threads cannot be created but we should
			// define the max number of threads which we will use in the system.
			// the right number depends on your project; do not make this number unnecessarily large
			Thread.MaxNumberOfUserThreads = 20;


            if (this.SupportsComPort)
            {
                MyCOMPort = this.ComPorts[1];
                MyCOMPort.SerialDataReceived += new ComPortDataReceivedEvent(myComPort_SerialDataReceived);

                if (MyCOMPort.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Error("COM Port couldn't be registered. Cause: {0}", MyCOMPort.DeviceRegistrationFailureReason);

                if (MyCOMPort.Registered)
                    MyCOMPort.SetComPortSpec(ComPort.eComBaudRates.ComspecBaudRate9600,
                                             ComPort.eComDataBits.ComspecDataBits8,
                                             ComPort.eComParityType.ComspecParityNone,
                                             ComPort.eComStopBits.ComspecStopBits1,
                                             ComPort.eComProtocolType.ComspecProtocolRS232,
                                             ComPort.eComHardwareHandshakeType.ComspecHardwareHandshakeNone,
                                             ComPort.eComSoftwareHandshakeType.ComspecSoftwareHandshakeNone,
                                         false);
            }

			// ensure this processor has ethernet then setup the EISC
			if (this.SupportsEthernet)
			{
				myEISC = new EthernetIntersystemCommunications(eISCIPID, eISCIP, this);
				if (myEISC.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
				{
					ErrorLog.Error(">>> The EISC was not registered: {0}", myEISC.RegistrationFailureReason);
				}
				else
				{
					// Device has been registered. Now register for the event handlers
					myEISC.OnlineStatusChange += new OnlineStatusChangeEventHandler(myEISC_OnlineStatusChange);
					myEISC.SigChange += new SigEventHandler(myEISC_SigChange);
					ErrorLog.Notice(">>> The EISC has been registered successfully");
				}
			}
			else
			{
				ErrorLog.Error(">>> This processor does not support ethernet, so this program will not run");
			}


		}
开发者ID:kurtjcu,项目名称:Crestron.SimpleSharp.RMC3-EISC-TV,代码行数:59,代码来源:Controlsystem.cs


注:本文中的ComPort.SetComPortSpec方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。