SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 191 | Next

Jan Axelson

"Serial Port Complete: COM Ports, USB Virtual COM Ports, and Ports for Embedded Systems"

yes
ReadDecimal Decimal. yes
ReadDouble Double. yes
ReadInt16 Int16. yes
ReadInt32 Int32. yes
ReadInt64 Int64. yes
ReadSByte SByte. yes
ReadSingle Single. yes
ReadString String prefixed with length. yes
ReadUInt16 UInt16. yes
ReadUInt32 UInt32. yes
ReadUint64 UInt64. yes
StreamReader Read Integer containing a character code.
Char array or subarray.
Waits for at
least 1 Char
ReadBlock Char array or subarray. yes
ReadLine String up to a NewLine. (Discards NewLine.) yes
Chapter 9
166
 Byte[] dataToSend = new Byte[5];
dataToSend[0] = (byte)'C';
dataToSend[1] = (byte)'M';
dataToSend[2] = (byte)'D';
dataToSend[3] = (byte)'1';
dataToSend[4] = 10;
myComPort.Write(dataToSend, 0, 5);
But the WriteLine method offers an easier way. The method converts each character
in the String to a code and writes the codes, followed by a LF character, to
the port:
 dim dataToSend as String
dataToSend = "CMD1"
myComPort.WriteLine(dataToSend)
 String dataToSend;
dataToSend = "CMD1";
myComPort.WriteLine(dataToSend);
The SerialPort class provides methods for reading and writing individual Bytes
or Chars; arrays or portions of arrays of Bytes or Chars; Strings; Strings + New-
Line characters; formatted Strings; Boolean values, numeric types such as Decimal,
Int16, and others; and text representations of numeric values. When
reading data, most methods block (don??™t return) until at least one byte or Char
is available or a timeout occurs.


Pages:
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203