本文整理汇总了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");
}
}