Serial Port Complete - Latest Microcontroller projects

(lily) #1
COM Ports on PCs

 
3 
  
  


For .NET’s programmers, the SerialPort class provides a convenient way to
access COM-port devices. Other programming options include API functions
such as CreateFile, ReadFile, and WriteFile and software components from
Greenleaf Software, MarshallSoft Computing, Sax.net, and others. Chapter 9
and Chapter 10 have more about .NET programming.


 


Terminal-emulator utilities can provide a user interface for COM-port commu-
nications. With a typical terminal emulator, you can type data to send, view
received data, and transfer files. Hilgraeve, Inc. (www.hilgraeve.com) provides a
free edition of the Hyperterminal utility for personal use as well as a business
edition of Hyperterminal and a more full-featured emulator called Hyper-
ACCESS. Windows editions through Windows XP include Hyperterminal,
accessed via Start > Programs > Accessories > Communications. Other terminal
emulators are available from a variety of sources. A popular free emulator is Tera
Te r m P r o.


 

 #
PC programmers sometimes want to know how to access a UART’s registers
directly. While direct port access is possible for some ports, it’s rarely useful.
Under DOS and early Windows editions, most serial ports used standard port
addresses, and applications could read and write to these addresses using assem-
bly code or functions, often called Inp and Out.
Under recent operating systems, accessing port addresses requires a low-level
driver such as inpout32 (available from http://www.Lvr.com). USB virtual COM port
devices don’t have dedicated port addresses and might not have a UART at all.
Beyond these limitations, using .NET’s SerialPort class or an equivalent driver
has many benefits. Applications can still access the UART’s registers, but do so
indirectly and without having to know the port address or other hardware
details. Plus, serial-port classes and drivers offer built-in efficiencies such as
buffering of serial data.
Free download pdf