*Serial*

Back to the start
Back to the libraries overview


Overview (Serial)
BitRate (Serial)
CD (Serial)
CommID (Serial)
CommPort (Serial)
CTS (Serial)
CTSHandshaking (Serial)
Databits (Serial)
DSR (Serial)
DTREnable (Serial)
EnableOnComm (Serial)
EventType (Serial)
InBufferCount (Serial)
InputArray (Serial)
InputString (Serial)
MaxInputLen (Serial)
MaxOutputLen (Serial)
New1 (Serial)
New2 (Serial)
OnCom Event (Serial)
Output (Serial)
Output2 (Serial)
Parity (Serial)
PortOpen (Serial)
RI (Serial)
RTSEnable (Serial)
StopBits (Serial)
TimeOut (Serial)
XonXoffHandshaking (Serial)


Overview (Serial) Top

The Serial library adds support for serial port communication.
Many Bluetooth enabled devices support virtual serial ports using Bluetooth. This library can be used in this case also.
Before using these features you need to add a reference for SerialDesktop.dll (for the desktop) or SerialPPC.dll (for the mobile device).
When distributing applications using this library, two additional files should be distributed as well:
? DBComm.dll (for the desktop)
? CFSerialClass.dll (for the device)


These two files can be found on the desktop inside the Basic4ppc Desktop folder (in the Libraries folder).
The Serial library allows input and output of strings or array of bytes.
The SerialTerminal example demonstrates string I/O.
A property named EnableOnComm determines whether the OnCom event will be fired whenever the serial port is receiving data (string or binary).


Credits:
The CFSerialClass.dll was written by Richard Grier - http://www.hardandsoftware.com/
The DBComm.dll was written by Cory Smith - http://www.gotdotnet.com
Both libraries can be distributed freely (as objects).


BitRate (Serial) Top

Gets or sets the bitrate used.
Syntax: BitRate

Example:
serial1.BitRate = 9600


CD (Serial) Top

Returns the value of the Carrier Detect line.
Syntax: CD


CommID (Serial) Top

Returns the windows handle that identifies the communications device.
Syntax: CommID


CommPort (Serial) Top

Gets or sets the communications port number.
Syntax: CommPort
Example:
serial1.CommPort = 4


CTS (Serial) Top

Returns the value of the Clear To Send line.
Syntax: CTS


CTSHandshaking (Serial) Top

Gets or sets whether to use the RTS/CTS handshaking.
Syntax: CTSHandshaking
Example:
serial1.CTSHandshaking = true


Databits (Serial) Top

Gets or sets the data bits used.
Can be 4,5,6,7 or 8 (default).
Syntax: Databits


DSR (Serial) Top

Returns the value of the Data Set Ready line.
Syntax: DSR


DTREnable (Serial) Top

Gets or sets whether to enable the Data Terminal Ready line.
Syntax: DTR


EnableOnComm (Serial) Top

Gets or sets whether the OnCom event will be raised when data is received.
Syntax: EnableOnComm

Example:
Sub App_Start
...
serial1.EnableOnComm = true
End Sub


Sub serial1_OnCom
...use data
End Sub


EventType (Serial) Top

Returns a string describing the cause for the last OnCom event.
This property is available only on the desktop.
Syntax: EventType


InBufferCount (Serial) Top

Returns the number of characters / bytes waiting in the receive buffer.
Syntax: InBufferCount


InputArray (Serial) Top

Returns an array of bytes from the receive buffer.
Syntax: InputArray

Example:
buffer() = serial1.InputArray


InputString (Serial) Top

Returns a string from the receive buffer.
Syntax: InputString

Example:
TextBox1.Text = serial1.InputString


MaxInputLen (Serial) Top

Gets or sets the size of the receive buffer.
Syntax: MaxInputLen


MaxOutputLen (Serial) Top

Gets or sets the size of the output buffer.
Syntax: MaxOutputLen


New1 (Serial) Top

Initializes the Serial object.
Syntax: New1


New2 (Serial) Top

Initializes the Serial object and sets its settings.
Syntax: New2 (Port As Int32, BitRate As Int32, Parity As String, DataBits As Int32, StopBits As Single)

Example:
serial1.New2 (4,9600,"N",8,1)


OnCom Event (Serial) Top

The OnCom event is raised when there is data in the receive buffer.
It will not be raised if the EnableOnComm property is not set to true.
Example:
Sub serial1_OnCom
...
End Sub


Output (Serial) Top

Sends a string.
Syntax: Output (string As String)


Output2 (Serial) Top

Sends an array of bytes.
Syntax: Output2 (buffer As Byte())

Example:
serial1.Output2 ( buffer() )


Parity (Serial) Top

Gets or sets the parity value.
Syntax: Parity


Paritiy can be:
"E" - Even
"M" - Mark
"N" - None
"O" - Odd
"S" - Space

Example:
serial1.Parity = "E"


PortOpen (Serial) Top

Gets or sets the state of the serial port.
Syntax: PortOpen


It is recommended to close the ports before the end of the program.
Example:
serial1.PortOpen = true


RI (Serial) Top

Returns the value of the Ring Indicator line.
Available only on the device.
Syntax: RI


RTSEnable (Serial) Top

Gets or sets whether to enable the Ready To Send line.
Syntax: RTSEnable


StopBits (Serial) Top

Gets or sets the stop bits value.
Syntax: StopBits
Stop bits can be: 1, 1.5 or 2.


TimeOut (Serial) Top

Gets or sets the TimeOut value (milliseconds) of the Serial object.
Syntax: TimeOut


XonXoffHandshaking (Serial) Top

Gets or sets whether to use the XonXoff handshaking protocol.
Syntax: XonXoffHandshaking