|
Serial
Port
|
 |
 |
|
| Port |
| On
computer and telecommunication devices, a port
is generally a specific place for being physically connected to some
other device, usually with a socket and plug of some kind. Typically, a
personal computer is provided with one or more
Serial
ports and usually one
Parallel
port.
|
| Serial & Parallel Port |
| The serial port supports sequential, one bit-at a time transmission to
peripheral devices such as scanners and the parallel port supports multiple bit
at a time transmission to devices such as printers.
|
| Parallel Port
|
Serial port |
 |
 |
|
| Serial Port – The 9 Pin Connector |
 |
|
| Serial Port – The 9 Pin Connector
|
| Carrier Detect
|
Determines if the modem is connected to a working phone line.
|
| Receive
Data
|
Computer receives information sent from the modem.
|
| Transmit
Data
|
Computer sends information to the modem. |
| Data
Terminal Ready
|
Computer tells the modem that it is ready to talk.
|
| Signal
Ground
|
Pin is grounded.
|
| Data
Set Ready
|
Modem tells the computer that it is ready to talk.
|
| Request
To Send
|
Computer asks the modem if it can send information.
|
| Clear
To Send
|
Modem tells the computer that it can send information.
|
| Ring
Indicator
|
Once a call has been placed, computer acknowledges signal (sent
from modem) that a ring is detected.
|
|
| Serial Port In programming |
A
port is a "logical connection place" and specifically, using the Internet's
protocol
(TCP/IP)
the way a client program specifies a particular server program on a computer in
a network. Higher-level applications that use TCP/IP such as the Web protocol
Hypertext Transfer Protocol
have ports with pre-assigned numbers. These are known as "well-known ports"
that have been assigned by the
Internet Assigned Numbers Authority (IANA)
Other application processes are given
port numbers dynamically for each connection. When a service (server program)
initially is started, it is said to bind to its designated port number. As any
client program wants to use that server, it also must request to bind to the
designated port number.
|
|
| Serial Port In programming
|
An
interface on a computer to which you can connect a device.
A PC have various types of
ports. Internally, there are several ports for connecting disk drives, display
screens, and keyboards.
Externally, personal computers have
ports for connecting modems, printers, mouse, and other peripheral devices.
Almost all personal computers come
with a
RS-232C
port or
RS-422
port for connecting a modem or mouse and a parallel port for connecting a
printer.
|
|
|
|
| Establishing Communication |
Can
we talk/Listen through serial port?
The answer is simple
-
YES
|
|
| Communicating with Serial Port |
The
following steps are used for sending and receiving data through the serial port
of a PC.
Open the Communication Port that you decide to use.
Configure the selected Communication Port by setting the Baud rate, parity, no.
of data bits, etc.
Set time-out value for Communication.
Read/Write Data to the Port.
Close the Port |
 |
|
| Buffer |
A
Buffer
is a region of memory used to temporarily hold data while it is being moved
from one place to another.
Typically, the data is stored in a buffer as it is retrieved from an input
device (such as a keyboard) or just before it is sent to an output device (such
as a printer).
However, a buffer may be used when moving data between processes within a
computer.
Buffers can be implemented in either hardware or software, but the vast
majority of buffers are implemented in software. Buffers are typically used
when there is a difference between the rate at which data is received and the
rate at which it can be processed, or in the case that these rates are
variable, for example in a printer spooler.
|
|
| Baud Rate |
In
telecommunications and electronics, it is a measure of the
symbol rate;
that is the number of distinct symbol changes(signaling events)made to the
transmission medium per second in a digitally modulated signal
Object . BaudRate [ = value ]
Value - An Int32 representing the baud rate of the communications port. |
 |
|
| Baud Rate
|
110
300
600
1200
2400
4800
9600 (Default)
14400
19200
28800
38400
56000
57600
115200
128000
256000
Errors - Attempting to set BaudRate to an invalid value will
cause PortController to throw an "Invalid argument" exception. |
 |
|
| BreakSTATE Property |
X
Sets and returns the state of the break signal.
X
object. BreakState [ = value ]
X
Errors -
Setting this value while the port is closed causes Port Controller to throw a
"Port is closed" exception. You may read this value while the port is closed
but the returned value is meaningless as it does not represent the current or
initial break state of the port. |
Object
-
An object expression that evaluates to a Port Controller object.
Value
-
A Boolean value representing the state of the break signal.
Return Value
–
When All data in the transmit queue is cleared then we will get true bool value
Default
-
false

|
|
| BytesUsedRQ Property
|
X
Returns a long integer indicating how many bytes are in the
receive queue.
X
object.BytesUsedRQ
X
Errors -
None |
Object
-
An object expression that evaluates to a PortController object.
Return Value
-
A long integer representing the number of bytes in the receive queue.
Remarks
-
This property is read-only. |
|
| DataBits Property |
X
Sets and returns the data bits communications parameter.
X
object.DataBits [ = value ] |
Object
-
An object expression that evaluates to a PortController object.
Value
-
An Int16 representing the data bits in each frame.
Return Value
-
An Int16 representing the data bits in each frame.
Remarks
-
Valid data bits values are as follows:8
(Default)
7
6
5
Default
-
8
|
 |
 |
|
| DataBits Property |
Errors
- Attempting to set Data Bits to an invalid value will cause Port Controller to
throw an "Invalid argument" exception.
Attempting to set Data Bits to 6, 7, or 8 when Stop Bits is
1.5 is illegal and will cause Port Controller to throw a "Invalid stop bits /
data bits combination" exception if the port is open. If the port is closed, no
exception will be thrown.
Attempting to set Data Bits to 5 when Stop Bits is 2 is illegal and will cause
Port Controller to throw an "Invalid stop bits / data bits combination"
exception if the port is open. If the port is closed, no exception will be
thrown.
|
|
| Close Method
|
X
Closes the communications port .
X
object.Close()
X
Errors -
If the port is open and unable to be closed for any reason, the PortController
will throw an "Unexpected Error" exception |
Object
-
An object expression that evaluates to a PortController object.
Return Value
–
None
Remarks
-
If Close() is called on an unopened port, no exception is thrown and execution
will continue normally. This means that it is always safe to call Close(), even
when there is no guarantee that the port is open. This method is called
automatically when the object is destroyed.
|
 |
|
| IsOpen Property |
X
Returns the open state of the port.
X
object.IsOpen
X
Errors –
None |
Object
-
An object expression that evaluates to a PortController object.
Return Value
-
The Boolean value true if the port is open, false otherwise.
Remarks
-
This property is read-only.
Default
-
False |
 |
|
| Parity Property |
X
Sets and returns the parity communications
parameter.
X
object.Parity [ = value ]
X
Errors -
Attempting to set Parity to an invalid value will cause PortController to throw
an "Invalid argument" exception.
X
Valid parity values are as follows:
X
Parity_None (Default)
X
Parity_Odd
X
Parity_Even
X
Parity_Mark
X
Parity_Space
X
Default - Parity_None |
Object
-
An object expression that evaluates to a PortController object.
Value
-
A value of type ParityValue indicating the parity setting.
Return Value
- A value of type ParityValue representing the parity setting.
Remarks
-
Parity values are contained in the SciCom.PortController.ParityValue namespace
|
 |
|
| PortName Property |
X
Returns the name of the port ("COM1", "COM2", etc.).
X
object.PortName
X
Errors -
Reading the PortName property while the port is closed is not permitted and
will cause PortController to throw a "Port is closed" exception. |
Object
-
An object expression that evaluates to a PortController object.
Return Value
-
A String containing the name of the open port. |
 |
|
| ReadBufferSize Property |
X
Sets and returns the recommended size of the port's internal
input buffer, in bytes.
X
object.ReadBufferSize=
[ value ]
X
Errors -
If PortController is unable to set the receive buffer size, a "Failed trying to
set buffer size. This could be because the specified buffer size was too
large." exception is thrown.
X
Remarks -
The port receives the recommended buffer sizes, but is free to use any input
and output (I/O) buffering scheme, as long as it provides reasonable
performance and data is not lost due to overrun (except under extreme
circumstances).
|
Object
-
An object expression that evaluates to a PortController object.
Value
-
An integer indicating the recommended size of the port's internal input buffer,
in bytes.
Return Value
-
An integer representing the recommended size of the port's internal input
buffer, in bytes. |
|