Casio Naurtech CETerm Ver.5.5 Scripting Guide Instrukcja Użytkownika Strona 115

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 164
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 114
NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE
CETerm Scripting Guide Page 115
var sp = Device.SerialPort( portIndex );
// Port configuration
sp.EventMask = EV_RXCHAR | EV_DSR;
sp.XOFFOutputFlowControl = false;
sp.XOFFInputFlowControl = false;
// See Appendix 4 for contants
sp.BaudRate = CBR_9600;
sp.DataBits = 8;
sp.StopBits = ONESTOPBIT;
sp.ParityMode = NOPARITY;
// Set read timeouts
sp.ReadTotalTimeoutConstant = 100;
sp.ReadIntervalTimeout = 50;
sp.ReadTotalTimeoutMultiplier = 10;
// Set write timeouts
sp.WriteTotalTimeoutConstant = 100;
sp.WriteTotalTimeoutMultiplier = 0;
// Open port
return sp.Open( GENERIC_READ | GENERIC_WRITE );
}
5.8.4 Using WaitForEvent to Detect Data and State Changes
Section 4.0 describes why scripts cannot run continuously within CETerm. While
a script is blocking on a SerialPort.Read command waiting for data, CETerm
cannot respond to user input or perform other actions. Because of this, you must
keep read timeouts short to maintain a responsive program. Although you could
“poll” the serial port frequently to read newly arrived data, this is an inefficient
technique. The better technique is to use the SerialPort.WaitForEvent
method to run an event handler when data arrives or other states change.
To use WaitForEvent, you first configure the types of events you want to
detect. These are set as flag values in the EventMask property. For example,
to report events for the arrival of data and a change of the DSR state you would
use
var portIndex = 5;
var sp = Device.SerialPort( portIndex );
sp.EventMask = EV_RXCHAR | EV_DSR; // See Appendix 4
Przeglądanie stron 114
1 2 ... 110 111 112 113 114 115 116 117 118 119 120 ... 163 164

Komentarze do niniejszej Instrukcji

Brak uwag