Návštěvní kniha

Периодическая ошибка частотника

is set" ; break; case SerialPinChange.CDChanged: signalState = myComPort.CDHolding; Console.WriteLine "CD = " + signalState ; break; case SerialPinChange.CtsChanged: signalState = myComPort.CtsHolding; Console.WriteLine "CTS = " + signalState ; break; case SerialPinChange.DsrChanged: signalState = myComPort.DsrHolding; Console.WriteLine "DSR = " + signalState ; break; case SerialPinChange.Ring: Console.WriteLine "Ring detected" ; break; 213 Chapter 10 Handling Errors Some errors in COM-port communications raise exceptions while others raise the SerialPort object’s ErrorReceived event. Application code can also use checksums to detect errors in transmitted data. Exceptions This chapter and Chapter 9 have discussed some of the COM-port events and conditions that can raise exceptions. In general, application code can minimize the likelihood of exceptions by checking for valid ports and port states before accessing a port. When needed, a Catch block can display messages to help the user fix the problem by selecting another port, attaching a port, or taking other action. The ErrorReceived Event Several error conditions can raise SerialPort’s ErrorReceived event. The Error-Received code below is similar to the code for the PinChanged and DataRe-ceived events in this chapter. To use the ErrorReceived event, the application must assign a routine that will execute when an ErrorReceived event occurs on an open port: vb 1 Define a delegate class to handle ErrorReceived events. Friend Delegate Sub SerialErrorReceivedEventHandlerDelegate _ ByVal sender As Object, ByVal e As SerialErrorReceivedEventArgs 1 Create an instance of the delegate. Private SerialErrorReceivedEventHandler1 _ As New SerialErrorReceivedEventHandler AddressOf ErrorReceived 214 Managing Ports and Transfers in .NET vc# // Define a delegate class to handle ErrorReceived events. internal delegate void SerialErrorReceivedEventHandlerDelegate object sender, SerialErrorReceivedEventArgs e ; // Creat prom-electric.ru

Přidat nový příspěvek