Printable versions
This Page
All Pages
PDF

Index

Class
Port

Properties
List
Enabled
BaudRate
ComPort

Methods
Read
Write
Purge
Dispose

ByteArrayToString
StringToByteArray

Events
OnRead
OnWritten
OnDSR
OnCTS
OnRI
OnDCD
OnForceClose

More Properties
Parity
StopBits
ByteSize
StartTrigger
EndTrigger
BufferSize
Timeout

DSR
CTS
RI
DCD

Handshake
RTS
DTR
Break
InfraRed

MultiThreading
Parent
NoEvents

Port.StringToByteArray SerialTools v1.10 and later

If you want to read anything else than ascii strings (that is ascii value 0-127) you need to convert the received string to a byte array using this static function. The string has been received by Port.Read or Port.OnRead.

VB.NET sample:
Dim objPort As New SerialCE.Port

objPort.BaudRate = 4800
objPort.ComPort = 2
objPort.Enabled = True		' Starts serial port.

Dim binary_data() As Byte
Dim string_data As String

string_data = objPort.Read(0, 5000)
' Received binary data
binary_data = SerialCE.Port.StringToByteArray(string_data)

Note that it will not work to build your own byte array, e.g. using String.ToCharArray(). You must use this function.

VB.NET sample (which WILL NOT WORK):
Dim objPort As New SerialCE.Port

objPort.BaudRate = 4800
objPort.ComPort = 2
objPort.Enabled = True		' Starts serial port.

Dim binary_data() As Char
Dim string_data As String

string_data = objPort.Read(0, 5000)
' Received binary data !! WILL NOT WORK !!
binary_data = string_data.ToCharArray()

See also Port.ByteArrayToString.

Syntax
ByteArray = SerialCE.Port.StringToByteArray ( Str )

Part Type Description
ByteArray byte[] Byte array converted from a string.
Str String (Variant) String (Variant) to be converted.



Pocket PC
© 2016 Franson Technology AB, All rights reserved, Contact | | Affiliate | Login