Serial Port Complete - Latest Microcontroller projects

(lily) #1
Using .NET’s SerialPort Class

Table 9-2: Applications have many choices when reading from a SerialPort object.


9:   
+!
#   7

SerialPort Read Byte array or subarray.
Char array or subarray.

Wa i t s f o r a t
least 1 Byte
or Char
ReadByte Byte. yes
ReadChar Char. yes
ReadExisting String. no
ReadLine String to first NewLine. (Discards NewLine.) yes
ReadTo String to first specified Char. (Discards
specified Char.)

yes

BinaryReader Read Integer containing a character code.
Byte array or subarray.
Char array or subarray.

yes

ReadBoolean Boolean. yes
ReadByte Byte. yes
ReadBytes Byte array. yes
ReadChar Char. yes
ReadChars Char array. 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.

Wa i t s f o r a t
least 1 Char
ReadBlock Char array or subarray. yes
ReadLine String up to a NewLine. (Discards NewLine.) yes
Free download pdf