Communications
MAIN FUNCTIONS:
Open(PortName,
Setup) Added TCP
support
(Rev 2.01 and Greater)
Close()
WriteString(Data)
ReadString(Length)
WriteByte(Data)
ReadByte()
SetTimeOut(Time)
SetTimeOuts(BaseTime,
Multiplier)
SetHandshaking(HSMethod)
WriteData(Data,
Length)
ReadData(Length)
ReadTil(EndStr,
EndStrLen, TimeOut, Length) New
(Rev 2.01 and Greater)
ADDITIONAL FUNCTIONS:
BytesRead()
ListPorts(Index,
Type)
NumberRetries(Retries)
DataBuffer
Mode
GetLastJobSubmitted
GetLastJobCompleted
PortName
NumBytesRead
NumBytesWritten
GetPortHandle()
SetBufferSize(InSize,
OutSize)
Sleep()
Wait()
OpenEx()
CancelIO()
GetInfoInt(InfoID)New
(Rev 2.01 and Greater)
GetInfoString(InfoID)New
(Rev 2.01 and Greater)
WriteBytes(ByteArray)New
(Rev 2.03 and Greater)
ReadBytes(ByteArray,
Length) New (Rev 2.03
and
Greater)
Status
ParallelStatus
SerialStatus
TCPStatus
NumCharsInQue
NumCharsOutQue
IOStatusEvent(StatusType,
IOStatus)
IOCompleteEvent(JobType,
JobId, JobResult)
IOQueueEvent(NumCharsInputQue,
NumCharsOutputQue)
IOPeriodicEvent()
StatusEventInterval
PeriodicEventEnabled
Parallel Specific
InitPrinter()
Out()
Modified to work on NT4.0, Win2000, WinXP (Rev 2.01 and Greater)
In()
Modified to work on NT4.0, Win2000, WinXP (Rev 2.01 and Greater)
DeviceControl()
Serial Specific
SerialPortSetupDialog()
SerialSetPortDefaults()
SerialGetPortDefaults()
SerialBreak()
SerialSetBaud(BaudRate)New
(Rev 2.01 and Greater)
Serial Specific (Advanced)
SerialCTSFlow(Value)
SerialDSRFlow(Value)
SerialDTRControl(long
Value)
SerialDSRSensitivity(Value)
SerialTxContinueOnXoff(Value)
SerialOutX(Value)
SerialInX(Value)
SerialErrorReplacment(Value)
SerialNullStripping(Value)
SerialRTSControl(Value)
SerialXonLimit(Value)
SerialXoffLimit(Value)
SerialXonCharacter(Value)
SerialXoffCharacter(Value)
SerialErrorCharacter(Value)
SerialEndCharacter(Value)
Remarks
Opens a port for doing input and output.
If you are doing TCP communications, the
server connection must be opened first then the client TCP connection.
Returns
1 if successful and 0 if the function
fails.
2 if successful but the port setup fails.
This can happen when another app/driver is using the port.
Example
Result = IO1.Open("LPT1:", "") 'Open a
parallel Port.
Result = IO1.Open("COM2:", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
Result = IO1.Open("\\.\digi1", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
Result = IO1.Open("\\.\COM22", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
Result = IO1.Open("localhost:9092",
"server")
'Open a TCP Port 9092.
Result = IO1.Open("localhost:9092",
"client")
'Open a TCP Port 9092.
Result = IO1.Open("192.168.1.5:9092",
"client") 'Open a TCP Port 9092.
NOTE: On Win NT Open() can fail if another device/driver is setup to use the port you are trying to open. Remove all devices/drivers setup to use this port, including printer drivers.
NOTE (TCP):
From the server end-
IO1.Open localhost : Port, "server"
From the client end:
IO1.Open remotehost : Port, "client"
where:
1: the server end is opened first
2: "localhost" at the server end is the
same "remotehost" at the client end
3: Monitor IOstatusevent. If any of the
2 ends is closed, the other end must be subsequently closed before
attempting
to open a line using the same IP address and Port numbers.
If "reconnect" (i.e. "server
reconnect")
is specified in the setup string, the IO control will attempt to
automatically
reconnect a lost connection.
Remarks
Closes an open port.
Returns
1 if successful and 0 if the function
fails.
Example
Result = IO1.Close()
Remarks
Writes a string to the previously opened
port. For binary data (i.e. Nulls) use the WriteData
function. If the function fails, you may need to increase the timeout
value
via SetTimeOuts. On a NT PC you should check to see if the
parallel
device is on-line via the ParallelStatus()
routine before you do a write.
Returns
1 if successful and a 0 if the function
fails.
Example
Result =
IO1.WriteString("Hello
World" + Chr(13) + Chr(10)) 'Sends "Hello World" to a printer or other
device.
Note: On PC's
setup
for countries such as Chinese, Japanese, or other symbol type
languages,
you may have to use the ReadBytes() and WriteBytes() functions to avoid
unwanted Unicode character translation.
Remarks
Reads characters from an opened port and
returns them as a string. For binary data (i.e. Nulls) use the function
ReadData.
When reading data from a parallel port, this function uses the RS1284
protocol
for reading data from the parallel port. If the function fails, you may
need to increase the timeout value via SetTimeOuts. On a NT PC
you
should check to see if the parallel device is on-line via the ParallelStatus()
routine before you do a read.
Example
String =
IO1.ReadString(30)
'Reads data from a port. Typically a request for data precedes this
command.
Note: On PC's
setup
for countries such as Chinese, Japanese, or other symbol type
languages,
you may have to use the ReadBytes() and WriteBytes() functions to avoid
unwanted Unicode character translation.
WriteByte(Data)
Remarks
Writes a byte/character to the previously
opened port. If the function fails, you may need to increase the
timeout
value via SetTimeOuts. On a NT PC you should check to see if the
parallel device is on-line via the ParallelStatus()
routine before you do a write.
Returns
1 if successful and a 0 if the function
fails.
Example
Result = IO1.WriteByte(10) 'Sends Line
feed to a printer or other device.
Remarks
Reads a byte/character from an opened
port. When reading data from a parallel port, this function uses the
RS1284
protocol for reading data from the parallel port. This function returns
the byte data in an integer. Some environments my sign extend this
value.
You may wish to do a bitwise AND with the value read from this function
and a hex FF to restore it to an unsigned value. On a NT PC you
should
check to see if the parallel device is on-line via the ParallelStatus()routine
before you do a read.
Returns
The byte/character.
Example
Result = IO1.ReadByte() 'Reads 1 data
byte from a port. Typically a request for data precedes this command.
OR
Result = IO1.ReadByte() And &Hff
'restores
to unsigned byte
Remarks
Sets the time out factor for a port. The
write/read operation will be tried until the time is expired. If the
timeout
expires, the function will return an error (0) result.
Returns
1 if successful and a 0 if the function
fails. If you call this function before the port is opened, it will
return
0. In this case the information will be retained untill the port is
opened
and applied at that time.
Example
Result = IO1.SetTimeOut(20) 'Sets timeout
factor, how long a request is tried before an error is returned.
SetTimeOuts(BaseTime, Multiplier)
Remarks
Sets the time out factor for a port. The
write/read operation will be tried until the time is expired. If the
timeout
expires, the function will return an error (0) result. For
Reading
a port the timeout will be: BaseTime + (number of characters to read) x
Multiplier .For writing to a port the time out will be: BaseTime +
(number
of characters to write) x Multiplier.
BaseTime + (number of characters to
read)
x Multiplier. Where "BaseTime" is the minimum time out regardless
of how many characters are communicated and the "Multiplier" time is
multiplied
with the string length and these two times are added together to get
the
total time out.
Returns
1 if successful and a 0 if the function
fails. If you call this function before the port is opened, it will
return
0. In this case the information will be retained untill the port is
opened
and applied at that time.
Example
Result = IO1.SetTimeOut(200, 20) 'Sets
timeout factor, how long a request is tried before an error is returned.
Remarks
Sets the type of handshaking to be used
with this port, the device must be configured to use the same type of
handshaking
protocol. Calling this function will reset the baud rate, parity,
and stop bits to the values passed into the Open() function. This
function should be called before the "Advanced
Serial Communications" functions. SetHandshaking() will
cancel
the "Advanced Serial Communications" functions settings.
Returns
1 if successful and a 0 if the function
fails. If you call this function before the port is opened, it will
return
0. In this case the information will be retained untill the port is
opened
and applied at that time.
Example
Result = IO1.SetHandshaking(2) 'Serial
ports Only. 0 = None, 1 = Xon/Xoff, 2 = Hardware
Remarks
Writes data to the previously opened port.
If the function fails, you may need to increase the timeout value via
SetTimeOuts.
On a NT PC you should check to see if the parallel device is on-line
via
the ParallelStatus() routine before you
do
a write.
Returns
The length of data written if successful
and a 0 if the function fails.
Example
Result = IO1.WriteData("String1" + Chr(00)
+ "String2" + Chr(00) + "String3" + Chr(00) + Chr(00)) 'Sends 3 null
terminated
strings to the port, with the total data being double null terminated.
Note: On PC's
setup
for countries such as Chinese, Japanese, or other symbol type
languages,
you may have to use the ReadBytes() and WriteBytes() functions to avoid
unwanted Unicode character translation.
Remarks
Reads bytes from an opened port and
returns
them in a string. The data can have null bytes. Even thought this
function
will return a string with embedded nulls other functions that operate
on
strings may not be null friendly. When reading data from a parallel
port,
this function uses the RS1284 protocol for reading data from the
parallel
port. On a NT PC you should check to see if the parallel device is
on-line
via the ParallelStatus() routine before
you
do a read.
Returns
Binary data in a string.
Example
String = IO1.ReadData(30) 'Reads data
from a port. Typically a request for data precedes this command.
Note: On PC's
setup
for countries such as Chinese, Japanese, or other symbol type
languages,
you may have to use the ReadBytes() and WriteBytes() functions to avoid
unwanted Unicode character translation.
ReadTil(EndStr, EndStrLen,
Timeout, AbortLength)
Remarks
Reads bytes from an opened port and
returns
them in a string. The data can have null bytes. Even thought this
function
will return a string with embedded nulls other functions that operate
on
strings may not be null friendly. When reading data from a parallel
port,
this function uses the RS1284 protocol for reading data from the
parallel
port. On a NT PC you should check to see if the parallel device is
on-line
via the ParallelStatus() routine before
you
do a read.
Returns
Binary data in a string.
Example
String = IO1.ReadTil(Chr(13)+Chr(10),
2, 3000, 50) 'Reads data from a port. Typically a request for data
precedes
this command.
Remarks
Return the number of bytes previously
read from the port. This value corresponds to the last read function
done
on this port. For use with the ReadData() function.
Returns
The number of bytes previously read
function
called.
Example
String = IO1.ReadData(30) 'Reads data
from a port.
NumBytes = IO1.BytesRead() 'returns number
of bytes read.
Remarks
Type is 1 for COM ports, 2 for LPT ports
and, 4 for all ports. Note you can OR these values together to get a
combination.
Returns
Returns the ports availble on the machine
for the given index.
Example
For i = 0 To 10
Label2.Caption = Label2.Caption +
IO1.ListPorts(i,
1) + " "
Next i
Remarks
Default is 1 retry.
Returns
Returns 1.
Example
Result = IO1.NumberRetries(1)
If using 2 (MODE_ASYNC), set the Mode
after
you Open() the communications port. The background
I/O operations work for ReadString() and WriteString()
and ReadData() and WriteData()
also. But, not for ReadByte() and WriteByte().
You can have more than one write data function outstanding (queued in
order),
but typically only one read data function is pending at a time.
Remarks
Returns the "Job ID" for the last submitted background job (read or write). (i.e. Mode = 2 (MODE_ASYNC))
Remarks
Returns the "Job ID" for the last job completed by a background job (read or write). (i.e. Mode = 2 (MODE_ASYNC))
Remarks
This function returns the handle of the
currently opened port. This function is provided to allow calls to the
Windows API directly.
Returns
The handle of the currently opened port.
Example
Result = IO1.GetPortHandle()
SetBufferSize(InSize, OutSize)
Remarks
This function sets the size of the input
and output buffer associated with the opened port. Caution should be
taken
when using this function, some hardware running Windows 95 can function
incorrectly when overriding the default buffer size with a serial port.
Returns
0 if the function fails.
Example
Result = IO1.SetbufferSize(InSize, OutSize)
Remarks
This function delays for the number of
milliseconds specified. This function is provided to allow for custom
timing
of signals on the ports.
Returns
None.
Example
IO1.Sleep(500) ‘delay for 500ms (½
second).
Remarks
This function delays for the number of
milliseconds specified. This function differs from Sleep()
in that it will yield the current thread to allow the application to
process
user input. This yielding lets the application respond to user
input
instead of appearing to "hang" during a long delay. Because this
functions yields to other tasks, it may delay for longer than the time
specified.
Returns
None.
Example
IO1.Wait(500) ‘delay for at least 500ms
(½ second).
OpenEx(PortName,
Setup, Mode, Extra)
Remarks
Opens a port for doing input and output.
Example
Result = IO1.Open("LPT1:", "",
OPEN_MODE_SHARE,
0) 'Open a parallel Port. In shared mode.
NOTE: On Win NT Open() can fail if
another
device/driver is setup to use the port you are trying to open. Remove
all
devices/drivers setup to use this port, including printer drivers. Note:
IODef.bas has VB constants for the IO control (in the samples directory)
Parameters
CancelFlags Determines how and what cancel action is taken. These values can be added or ORed to combine the flags.
RemarksCANCEL_TXABORT (1) Abort the pending/current writes to the comm port.
CANCEL_RXABORT (2) Abort the pending/current reads from the comm port.
CANCEL_TXCLEAR (4) Purge the transmit queue.
CANCEL_RXCLEAR (8) Purge the receive buffer.
Cancels pending reads or writes to the open port, also can purge/remove any information in the read or write buffers. Canceling pending I/O works best if using the background I/O Mode.Returns
Example
Result = IO1.CancelIO(1+2+4+8) 'Cancels pending I/O.
Note: IODef.bas has VB constants for the IO control (in the samples directory)
Parameters
InfoID A number that determines what information is returned by the function.RemarksINFO_BAUD (01) retuns the baud rate
Returns information about the opened communications channel.The requested data.Returns
Example
Result = IO1.GetInfoInt(1) '.
Note: IODef.bas has VB constants for the IO control (in the samples directory)
Parameters
InfoID A number that determines what information is returned by the function.RemarksINFO_BAUD (01) retuns the baud rate
INFO_PORT (02) returns the port name
INFO_SETUP (03) return the setup string
Returns information about the opened communications channel.The requested data.Returns
Example
Result = IO1.GetInfoString(1) '.
Note: IODef.bas has VB constants for the IO control (in the samples directory)WriteBytes(Data)
Parameters
Data is a byte array.Remarks
The array must be a byte array with a single dimension.Returns
Returns number of bytes actually written.Example
Dim darray(2) As Bytedarray(0) = 111
darray(1) = 112
darray(2) = 113
IO1.WriteBytes (darray)
Parameters
Data is a byte array.
Length is the number of character to read into the byte array.Remarks
The actual length of bytes read will not exceed the length of the array. The array must be a byte array with a single dimension.Returns
Returns number of bytes actually written.Example
Dim darray(3) As Byteres = IO1.ReadBytes(darray, 4)
res = darray(0)
res = darray(1)
res = darray(2)
res = darray(3)
Status
Example:
IOStatus = IO1.ParallelStatus
If (IOStatus And PARALLEL_SELECTED) Then
NewText = NewText + "Selected. "
Else
NewText = NewText + "Not Selected. "
End If
OR
IOStatus = IO1.ParallelStatus
If (IOStatus And &h80) Then
NewText = NewText + "Selected. "
Else
NewText = NewText + "Not Selected. "
End If
Note: IODef.bas has VB constants for the IO control (in the samples directory)
PARALLEL_PAPER_EMPTY
PARALLEL_OFF_LINE PARALLEL_POWER_OFF PARALLEL_NOT_CONNECTED PARALLEL_BUSY PARALLEL_SELECTED |
0x4
0x8 0x10 0x20 0x40 0x80 |
Example:
IOStatus = IO1.SerialStatus
If (IOStatus And SERIAL_RXEMPTY) Then
NewText = NewText + "RX Buffer Empty,
"
else
NewText = NewText + "RX Buffer Not Empty,
"
End If
OR
IOStatus = IO1.SerialStatus
If (IOStatus And &h40) Then
NewText = NewText + "RX Buffer Empty,
"
else
NewText = NewText + "RX Buffer Not Empty,
"
End If
Note: IODef.bas has VB constants for the IO control (in the samples directory)
SERIAL_RXOVER
SERIAL_OVERRUN SERIAL_RXPARITY SERIAL_FRAME SERIAL_BREAK SERIAL_TXFULL SERIAL_TXEMPTY SERIAL_RXEMPTY SERIAL_CTS_TXHOLD SERIAL_DSR_TXHOLD SERIAL_RLSD_TXHOLD SERIAL_XOFF_TXHOLD
SERIAL_CTS_ON SERIAL_DSR_ON SERIAL_RING_ON SERIAL_RLSD_ON |
0x0001
0x0002 0x0004 0x0008 0x0010 0x0100 0x0020 0x0040 0x0200 0x0400 0x0800 0x1000
0x010000 0x020000 0x040000 0x080000 |
An
input buffer overflow has occurred. There is either no room in the
input
buffer, or a character was received after the end-of-file (EOF)
character.
A character-buffer overrun has occurred. The next character is lost. The hardware detected a parity error. The hardware detected a framing error. The hardware detected a break condition. The application tried to transmit a character, but the output buffer was full. The transmit buffer is empty. The receive buffer is empty. Transmission is waiting for the CTS (clear-to-send) signal to be sent. Transmission is waiting for the DSR (data-set-ready) signal to be sent. Transmission is waiting for the RLSD (receive-line-signal-detect) signal to be sent. Transmission is
waiting because
the XOFF character was received.
The CTS (clear-to-send) signal is on. The DSR (data-set-ready) signal is on. The ring indicator signal is on. The RLSD (receive-line-signal-detect) signal is on. |
Example:
IOStatus = IO1.TCPStatus
If (IOStatus And &h2) Then
NewText = NewText + "Connection Ready
to Transmit"
else
NewText = NewText + "Connection Not Ready
to Transmit"
End If
OR
IOStatus = IO1.TCPStatus
If (IOStatus And &h1) Then
NewText = NewText + "Data Present and
Ready to Read"
else
NewText = NewText + "No Data Present "
End If
Note: IODef.bas has VB constants for the IO control (in the samples directory)
TCP_READ_READY
TCP_WRITE_READY TCP_LOST_CONNECTION
|
0x1
0x2 0x4
|
This value will likely be inaccurate when using a background read operation (i.e. Mode = MODE_ASYNC(2)). The background read may have already read the data and stored it in an intermediate buffer until the IOCompleteEvent is fired..
NOTE: This value may not function on an
NT based OS using a parallel port.
This value will likely be inaccurate
when
using a background write operation(s) (i.e. Mode =
MODE_ASYNC(2)).
The background write may not have written the data yet, the data is
stored
in an intermediate buffer until the pending write is processed.
Events
IOStatusEvent(StatusType, IOStatus)
STATUS_TYPE_PARALLEL 1
STATUS_TYPE_SERIAL 2
IOStatus. Specifies the status
pertaining to the open port. See the definition of SerialStatusand
ParallelStatusfor
the value of this parameter.
Remarks
This event is fired whenever a status change is detected on the port. How often status is checked and events are generated is set by StatusEventInterval (default of 250 milliseconds).
IOCompleteEvent(JobType, JobId, JobResult)
BKJOB_WRITE 3
BKJOB_READ 4
JobId. Specifies the Id of the
job
submitted for background processing.
JobResult. Specifies the result
of the job submitted for background processing.
Remarks
This event is fired whenever a background
job is finished. If a read operation is completed, DataBuffer
will contain the result of the read operation.
IOQueueEvent(NumCharsInputQue, NumCharsOutputQue)
Remarks
This event is fired whenever the number
of character in either the input or output queue has changed.
This
event is provided to allow the application designer to monitor the
communications
activity.
Example:
If (NumCharsInputQue > 0) Then
NOTE: The value "NumCharsInputQue" may not function on an NT based OS using a parallel port.
Remarks
This event is fired whenever the StatusEventInterval
has expired. This event is provided to allow the applications
designer
to add custom communications monitoring on a periodic basis. This
event is enable by setting the property PeriodicEventEnabled to TRUE
(1).
StatusEventInterval
(Property) R/W
PeriodicEventEnabled (Property) R/W
Parallel Specific
Parameters
Code Specifies what action to take.
1 assert init signal to device on printer port.
Remarks
Executes a printer reset via the Init pin on the parallel printer port. When asserting a signal, the signal transitions from false to true and back to false.
Returns
1 for success and 0 if the function fails.Example
ret = IO1.InitPrinter(1)
Remarks
Because this is used to write a data byte
directly to the parallel port hardware, do not call the Open() or
Close()
functions when using the Out() function.. See below for the
address
of standard parallel ports.
Port addresses:
LPT1: 378 Hex(Data), 379 Hex(Status), 37A Hex(Control)
LPT2: 278 Hex(Data), 279 Hex(Status), 27A Hex(Control)
LPT3: 3BC Hex(Data), 3BD Hex(Status), 3BE Hex(Control)
Remarks
Because this is used to read a data byte
directly from the parallel port hardware, do not call the Open() or
Close()
functions when using the In() function. See below for the address
of standard parallel ports.
Returns
The data byte of the addressed port
register.
Port addresses:
LPT1: 378 Hex(Data), 379 Hex(Status), 37A Hex(Control)
LPT2: 278 Hex(Data), 279 Hex(Status), 27A Hex(Control)
LPT3: 3BC Hex(Data), 3BD Hex(Status), 3BE Hex(Control)
Example
Result = IO1.In(&H378)
Or
Result = IO1.In(&H378) And &Hff
'restores to unsigned byte
Parameters
Command. Specifies the command.ASSERT_PAR_CONTROL (1441800) Assert parallel port control signal(s).Data. Specifies data that the command uses.PARALLEL_INIT (1)Buffer. Specifies additional data as needed.
PARALLEL_AUTOFEED (2)Remarks
Sends a command to port hardware through the port driver.Returns
The return data is a string. If the function fails the string is empty. If the function succeeds the string is non-empty and its contents depend on the command sent. When asserting a signal, the signal transitions from false to true and back to false (pulse).Example
ret = IO1.DeviceControl(1441800, 1, "")
Serial Specific
SerialPortSetupDialog(PortName)
Remarks
This method displays the serial port setup
dialog and allows a user to adjust the port settings. After the
dialog
is dismissed by clicking on the "OK" button, the new settings are
applied
to the currently open port. If no port is open, the settings are saved
in the I/O object and can be stored by calling the SerialSetPortDefaults()
function. If the PortName is blank (i.e. ""), the dialog will use
the port name of the most recently opened port.
Returns
1 for success
0 for fail or cancel button was clicked.
Example
IO1.SerialGetPortDefaults
(PortName)
'Get port settings
Result =
IO1.SerialPortSetupDialog(PortName)
'Allow user to setup port
If Result = 1 Then
Result =
IO1.SerialSetPortDefaults(PortName,
"", -1) 'Save the settings
End If
SerialSetPortDefaults(PortName, Setup, HSMode)
Remarks
This method allows setting of the default
settings of a serial port. The default settings for a port are
maintained/save
by the operating system. If Setup is blank (i.e. ""), this
function
will use the settings of the last opened port or the settings entered
via
the SerialPortSetupDialog()
function.
If the HSMode is -1, this function will use the settings of the last
opened
port or the settings entered via the SerialPortSetupDialog()
function.. If the PortName is blank (i.e. ""), this function will
use the port name of the most recently opened port. This function
will also change/set the settings for the currently opened port (if one
is opened).
Returns
1 for success or 0 for fail.
IO1.SerialPortSetupDialog (PortName) 'Allow user to setup port
Result = IO1.SerialSetPortDefaults(PortName, "", -1) 'Save the settings
SerialGetPortDefaults(PortName)
Remarks
This method allows retrieval of the
default
settings of a serial port. The default setting for a port are
maintained/save
by the operating system. If the PortName is blank (i.e. ""), this
function will use the port name of the most recently opened port.
This function should be called after the port is opened, as opening of
the port will overwrite the setting retrieved by calling this function.
Returns
1 for success or 0 for fail.
Remarks
This method allows the open serial port
to be put into a break condition.
Returns
1 for success or 0 for fail.
Remarks
This method allows the open serial port
to be put into a break condition.
Returns
1 for success or 0 for fail.
Advanced Serial Communications functions
These functions are not
typically
needed to successfully do serial communication, but are provided to
allow
advanced control of the serial port. These functions should be called
after
the SetHandshaking() function is called, as SetHandshaking()
will cancel these settings.
Remarks
Specifies whether the CTS (clear-to-send)
signal is monitored for output flow control. If it is 1 and CTS is low,
output is suspended until CTS is high again. The CTS signal is under
control
of the device (usually a modem/printer), the host simply monitors the
status
of this signal, the host does not change it. This function should be
called
before the port is opened.
Returns
1 if successful or 0 if failed.
Example
Result = IO1.SerialCTSFlow(1)
...
Result = IO1.Open("COM2:", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
Remarks
Specifies whether the DSR (data-set-ready)
signal is monitored for output flow control. If this member is 1 and
DSR
is low, output is suspended until DSR is high again. This signal is
under
the control of the attached device; the host(PC) only monitors this
signal.
This function should be called before the port is opened.
Returns
1 if successful or 0 if failed.
Example
Result = IO1.SerialDSRFlow(1)
...
Result = IO1.Open("COM2:", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
Remarks
If 0 then the DTR line is lowered when
the device is opened.
If 1 then the DTR line is raised when
the device is opened.
If set to 2 enables DTR flow-control
handshaking.
After the port is opened:
If called with a value of 5 sets DTR high.
Only
allowed if SerialDTRControl was set to 1 0r 0 before the port was
opened.
If called with a value of 6 sets DTR low.
Only
allowed if SerialDTRControl was set to 1 0r 0 before the port was
opened.
Returns
1 if successful or 0 if failed.
Example
Result = IO1.SerialDTRControl(0)
...
Result = IO1.Open("COM2:", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
...
Result = IO1.SerialDTRControl(5)
Remarks
Specifies whether the communications
driver
is sensitive to the state of the DSR signal. If this is set to a 1, the
driver ignores any bytes received, unless the DSR modem input line is
high.
Returns
1 if successful or 0 if failed.
Example
Result = IO1.SerialDSRSensitivity(1)
...
Result = IO1.Open("COM2:", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
SerialTxContinueOnXoff(Value)
Parameters
Value 1 or 0. Controls Xon/Xoff
behavior. Undetermined results if set to other than 1 or 0.
Remarks
Specifies whether transmission stops when
the input buffer is full and the driver has transmitted the XOFF
character.
If this is set to a 1, transmission continues after the XOFF character
has been sent. If this is set to a 0, transmission does not continue
until
the input buffer is within SerialXonLim bytes of being empty and the
driver
has transmitted the XON character.
Returns
1 if successful or 0 if failed.
Example
Result = IO1.SerialTxContinueOnXoff(1)
...
Result = IO1.Open("COM2:", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
Remarks
Specifies whether XON/XOFF flow control
is used during transmission. If this member is a 1, transmission stops
when the XOFF character is received and starts again when the XON
character
is received.
Returns
1 if successful or 0 if failed.
Example
Result = IO1.SerialOutX(1)
...
Result = IO1.Open("COM2:", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
Remarks
Specifies whether XON/XOFF flow control
is used during reception. If this is set to a 1, the XOFF character is
sent when the input buffer comes within a preset limit of bytes of
being
full (see SerialXonLimit and SerialXoffLimit), and the
XON
character is sent when the input buffer comes within a preset limit of
bytes of being empty.
Returns
1 if successful or 0 if failed.
Example
Result = IO1.SerialInX(1)
...
Result = IO1.Open("COM2:", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
Remarks
Specifies whether bytes received with
parity errors are replaced with the character specified by the SerialErrorCharacter
member function. If this is set to a 1 and the Parity is set to a 1,
replacement
occurs.
Returns
1 if successful or 0 if failed.
Example
Result = IO1.SerialErrorReplacment(1)
...
Result = IO1.Open("COM2:", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
Remarks
Specifies whether null bytes are
discarded.
If this is set to 1, null bytes are discarded when received.
Returns
1 if successful or 0 if failed.
Example
Result = IO1.SerialNullStripping(1)
...
Result = IO1.Open("COM2:", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
Remarks
If 0 then the RTS line is lowered when
the device is opened.
If 1 then the RTS line is raised when
the device is opened.
If set to 2 enables RTS flow-control
handshaking.
The driver raises the RTS line, enabling the attached device to send
(when
the input buffer has enough room to receive data). The driver lowers
the
RTS line, preventing the attached device from sending (when the input
buffer
does not have enough room to receive data).
If set to 3 specifies that the RTS line
will be high if bytes are available for transmission. After all
buffered
bytes have been sent, the RTS line will be low. (Not supported on Win95)
After the port is opened:
If called with a value of 5 sets RTS high.
Only
allowed if SerialRTSControl was set to 1 0r 0 before the port was
opened.
If called with a value of 6 sets RTS low.
Only
allowed if SerialRTSControl was set to 1 0r 0 before the port was
opened.
Returns
1 if successful or 0 if failed.
Example
Result = IO1.SerialRTSControl(0)
...
Result = IO1.Open("COM2:", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
...
Result = IO1.SerialRTSControl(5)
Remarks
Specifies the minimum number of bytes
allowed in the input buffer before the XON character is sent.
Returns
1 if successful or 0 if failed.
Example
Result = IO1.SerialXonLimit(256)
...
Result = IO1.Open("COM2:", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
Remarks
Specifies the maximum number of bytes
allowed in the input buffer before the XOFF character is sent.
Returns
1 if successful or 0 if failed.
Example
Result = IO1.SerialXoffLimit(100)
...
Result = IO1.Open("COM2:", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
SerialXonCharacter(Value)
Remarks
Specifies the Xon character.
Returns
1 if successful or 0 if failed.
Example
Result = IO1.SerialXonCharacter(17)
...
Result = IO1.Open("COM2:", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
Remarks
Specifies the Xoff character.
Returns
1 if successful or 0 if failed.
Example
Result = IO1.SerialXoffCharacter(19)
...
Result = IO1.Open("COM2:", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
Remarks
Specifies the Error character, the
character
used to replace bytes received with a parity error.
Returns
1 if successful or 0 if failed.
Example
Result = IO1.SerialErrorCharacter('?')
...
Result = IO1.Open("COM2:", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
Remarks
Specifies the End character, the character
used to signal the end of data.
Returns
1 if successful or 0 if failed.
Example
Result = IO1.SerialEndCharacter(&hFF)
...
Result = IO1.Open("COM2:", "baud=9600
parity=N data=8 stop=1") 'Open a serial Port.
Home
Page | Site
Map | Copyright (c) 1998 by JSPayne
of Cortland NY