What is a cat port on the computer. What are the ports of a personal computer? And what are they? How to disable USB ports when you turn off the computer

Description of the RS-232 interface, the format of the connectors used and the assignment of the outputs, signals, data exchange protocol.

general description

The RS-232 interface, quite officially called "EIA / TIA-232-E", but better known as the "COM port" interface, previously was one of the most common interfaces in computer technician. He still meets in desk computersDespite the appearance of more speed and "intelligent" interfaces such as USB and Fireware. Its advantages from the point of view of radio amateurs can be attributed to the low minimum speed and simplicity of the implementation of the protocol in the homemade device.

The physical interface is implemented by one of two types of connectors: DB-9M or DB-25M, the latter in the currently available computers is practically not found.

Appointment of 9-pin connector conclusions


9-pin DB-9M type plug
Pin contact numbers
The direction of signals is indicated relative to the host (computer)
Contact Signal Direction Description
1 CD entrance Loading detected
2 RXD. entrance Accepted data
3 TXD. Output Transmitted data
4 Dtr. Output Host ready
5 GND. - Common wire
6 DSR. entrance Device is ready
7 RTS. Output Host ready for transmission
8 CTS. entrance Device is ready to receive
9 RI. entrance A challenge was found

Appointment of the 15-pin connector conclusions

Contact Signal Direction Description
1 Shield. - Screen
2 TXD. Output Transmitted data
3 RXD. entrance Accepted data
4 RTS. Output Host ready for transmission
5 CTS. entrance Device is ready to receive
6 DSR. entrance Device is ready
7 GND. - Common wire
8 CD entrance Loading detected
9 - - Reserve
10 - - Reserve
11 - - Not used
12 SCD. entrance The carrier is detected. # 2
13 SCTS. entrance Device ready for reception # 2
Contact Signal Direction Description
14 STXD. Output Transmitted data # 2
15 TRC. entrance Taking transmitter
16 SRXD. entrance Accepted data # 2
17 RCC entrance Tact on receiver
18 Lloop. Output Local loop
19 SRTS. Output Host ready to transmit # 2
20 Dtr. Output Host ready
21 Rloop. Output Outer loop
22 RI. entrance A challenge was found
23 DRD. entrance The speed of the data is determined
24 TRCO Output Take the external transmitter
25 Test entrance Test mode

The table shows that the 25-pin interface is distinguished by the presence of a full-fledged second receive channel (signals indicated "# 2"), as well as numerous additional control and control signals. However, often, despite the presence in the computer "wide" connector, additional signals are simply not connected on it.

Electrical characteristics

Logical transmitter levels: "0" - from +5 to +15 volts, "1" - from -5 to -15 volts.

Logical levels of the receiver: "0" - above +3 volts, "1" - below -3 volts.

input resistance receiver at least 3 com.

These characteristics are defined by the standard as minimum, guaranteeing device compatibility, however, the actual characteristics are usually significantly better, which allows, on the one hand, to feed low-power devices from the port (for example, numerous homemade Data cables are designed for cell phones), and on the other - to submit to the port of the port inverted TTL level instead of a bipolar signal.

Description of the main interface signals

CD - The device sets this signal when it detects the carrier in the received signal. Typically, this signal is used by modems, which thus report the host on the discovery of the working modem on the other end of the line.

RXD. - Receive the host data from the device. Described in detail in the section "Data Exchange Protocol".

TXD. - Data host transfer line to device. Described in detail in the section "Data Exchange Protocol".

Dtr. - The host sets this signal when ready to exchange data. In fact, the signal is set when you open the port of the communication program and remains in this state all the time until the port is open.

DSR. - The device sets this signal when enabled and ready to exchange data with host. This and previous (DTR) signals must be installed to exchange data.

RTS. - The host sets this signal before starting data transfer to the device, and also signals readiness for receiving data from the device. Used when hardware control of the exchange of data.

CTS. - The device sets this signal in response to the previous host installation (RTS) when it is ready to take data (for example, when the previous host data sent data is transmitted to the line in line or there is a free space in the intermediate buffer).

RI. - The device (usually modem) sets this signal when receiving a call from the remote system, for example, when receiving phone callIf the modem is configured to receive calls.

Data exchange protocol

The RS-232 protocol exists two data management methods: hardware and software, as well as two transmission modes: synchronous and asynchronous. The protocol allows you to use any of the management methods together with any transmission mode. Working without flow control is also allowed, which implies the constant readiness of the host and the device to receive data when the connection is set (DTR and DSR signals are installed).

Hardware control method It is implemented using RTS and CTS signals. To transfer the data host (computer), sets the RTS signal and waits for the CTS signal to be installed, after which the data is started until the CTS signal is set. The CTS signal is checked by the host immediately before starting the transmission of the next byte, so byte, which has already begun to be transmitted, will be transmitted completely regardless of the CTS value. In the half-duplex data exchange mode (the device and host transmit data in turn, in full-duplex mode, they can do it at the same time) RTS signal removal by the host means its transition to the reception mode.

Software management method It is to transfer the host of special stop symbols (symbol with 0x13 code, called xoff) and renewal (symbol with code 0x11, called Xon). When receiving these characters, the transmitting party must stop the transmission accordingly or resume it (if there is data waiting for transmission). This method is easier in terms of the implementation of the equipment, however, provides a slower reaction and, accordingly, requires the transmitter notification of the transmitter when the free space is reduced in the receiving buffer to a certain limit.

Synchronous transmission mode It implies a continuous data exchange when the bits follow one after another without additional pauses at a given speed. This COM port mode not supported.

Asynchronous transmission mode It is that each data byte (and the parity control bit, in the event of its presence), "turns out" a synchronizing sequence of one zero start-bit and one or more single stop bits. Data flow diagram in asynchronous mode is presented in the figure.

One of the possible algorithms of the receiver following:

  1. Expect the "0" level of the reception signal (RXD in the case of a host, TXD in the case of a device).
  2. Count half the battery duration and check that the signal level is still "0"
  3. Count full bit duration and current signal level write to the younger data batch (bit 0)
  4. Repeat the previous item for all other data bits
  5. Count the full bit duration and current signal level to use to verify the correctness of the reception using parity control (see below)
  6. Squeeze the full bit duration and make sure that the current level of the signal "1".

When calculating, the serial port is a serial communication interface through which the information is transmitted or issued at a time. For most of the history of personal computers, the data was transmitted through serial ports on devices, such as modems, terminals and various peripheral devices.

Although interfaces such as Ethernet, FireWire and USB, all send data as a sequential stream, the term "serial port" typically identifies hardware, more or less compatible with the RS-232 standard, intended to interact with a modem or with a similar communication link.

Modern computers without serial ports may require converters with a serial interface to ensure compatibility with RS-232 serial devices. Serial ports are still used in applications such as industrial automation systems, scientific devices, sales systems and some industrial and consumer goods. Server computers can use a serial port as a management console or diagnostics. Network equipment (for example, routers and switches) often use the serial console for the configuration. Serial ports are still used in these areas, since they are simple, cheap, and their console functions are highly standardized and widespread.

COM port pinout (RS232)

There are 2nd varieties of the COM port, 25-pin old connector and replaced its newer 9-pin connector.

Below is a diagram of a standard standard 9-pin RS232 connector with connectors, this type of connector is also called the DB9 connector.

  1. Carrier detection (DCD).
  2. Data obtaining (RXD).
  3. Data Transfer (TXD).
  4. Readiness for the exchange from the receiver (DTR).
  5. Earth (GND).
  6. Readiness for the exchange from the source (DSR).
  7. Request for transfer (RTS).
  8. Transmission readiness (CTS).
  9. Call signal (RI).

RJ-45 to DB-9 Information about the output of the sequential port adapter for switch

The console port is the RS-232 serial interface, which uses the RJ-45 connector to connect to the control device, such as a PC or laptop. If there is no DB-9 pin pin on your laptop or PC, and you want to connect a laptop or PC to the switch, use the RJ-45 and DB-9 adapter combination.

DB-9.RJ-45.
Data obtaining2 3
Data transfer3 6
Exchange readiness4 7
Land5 5
Land5 4
Exchange readiness6 2
Request for transfer7 8
Readiness for transmission8 1

Wire colors:

1 black
2 brown
3 red
4 orange
5 yellow
6 green
7 blue
8 Gray (or White)

Sometimes you have to solve the communication task electronic device With a computer, whether it is simply exchanged data or remote control. This article describes how this can be implemented using a serial port. Its main advantage is that standard software windows interface (API) Allows you to directly control output lines, giving direct control over them, and has a function of waiting for a certain event associated with the COM port. Also, the RS-232 standard for which the COM ports are made, allows you to connect and turn off the cables during the operation of the devices (Hot Plug).

Description

COM port (serial port) - bidirectional interface transmitting data in a sequential form (bit beyond) via RS-232 protocol. This is a rather common protocol used to communicate one device (for example, a computer) with other wires up to 30m. Logical signals are different here from standard: the level of the logical unit is from +5 to + 15V, the level of logical zero is from -5 to -15V, which requires additional transformations of the circuit, but provides good noise immunity.

Consider a 9-pin connector (DB-9M). Below is its pinout:

Output № Name Signal character Signal
1 DCD. Input Data Carrier Detect.
2 RXD. Output TRANSMIT DATA.
3 TXD. Input Receive Data.
4 Dtr. Output Data Terminal Ready
5 GND. - Ground.
6 DSR. Input Data Set Ready
7 RTS. Output Request to Send.
8 CTS. Input Clear To Send.
9 RI. Input Ring Indicator

Most of all, we will be interested in Pins 2 (data transfer), 3 (data reception) and 5 (land). This is a minimum set for the possibility of double-sided appliances.

Starting in detail on the description of the protocol will not. For this there are GOST and the like. Therefore, we will go further and let's talk about how to manage this beast.

Application

As already mentioned, the levels of RS-232 differ from the standard TTL levels. Therefore, we need to somehow convert voltage values. Those. Make 5V from + 15V and 0V from -15V (and vice versa). One of the ways (and, probably, the easiest) - the use of a special MAX232 microcircuit. It is easy to understand and at the same time can convert two logical signals.

Below is the scheme of its inclusion:


I think there should be no difficulty. This is one of the use of this chip: data transmission from a microcontroller on a computer and vice versa. The transmitted signal comes on legs T x.In on one side and on R x.In on the other. Input signals are removed from T x.Out and R. x.OUT, respectively.

Programming

To begin with, let's talk about programming ports at a low level. So it will be more correct. I spent a lot of nerves, dealing with this interface, until I started to delve into the principle of its work at a lower level than, rather simple transfer Symbols. If it is clear, it means that there will be no problems with high-level languages.

Below are the addresses of the COM ports with which we will have to work:

Port name Address IRQ.
COM 1. 3F8h 4
COM 2. 2F8h 3
COM 3. 3E8h 4
COM 4. 2E8h. 3

They may vary. Set values \u200b\u200bin the BIOS settings. This is basic addresses. They will also depend on the address of the registers responsible for the work of the ports:

Address DLAB Reading / writing Abbreviation Register name
+ 0 =0 Write. TRANSMITTER HOLDING BUFFER.
=0 Read. Receiver Buffer.
=1 Read / Write. Divisor Latch Low Byte
+ 1 =0 Read / Write. IER Interrupt Enable Register
=1 Read / Write. Divisor Latch High Byte
+ 2 - Read. Iir. Interrupt Identification Register
- Write. FCR. FIFO CONTROL REGISTER
+ 3 - Read / Write. LCr. Line Control Register
+ 4 - Read / Write. MCR. Modem Control Register
+ 5 - Read. Lsr. Line Status Register.
+ 6 - Read. MSR. Modem Status Register
+ 7 - Read / Write. Scratch Register.

The first column is the register address relative to the basic. For example, for COM1: The LCR register address will be 3F8H + 3 \u003d 3FB. The second column - DLAB (Divisor Latch Access Bit) bit, defining a different purpose for the same register .. i.e. It allows you to operate with 12 registers using only 8 addresses. For example, if DLAB \u003d 1, then referring to 3F8H, we will set the value of the younger byte of the clock generator frequency. If DLAB \u003d 0, then referring to the same address, the transmitted or accepted byte will be recorded in this register.

Zero Register

It complies with the registers / data transmission registers and the generator frequency divider coefficient. As mentioned above, if DLAB \u003d 0, then the register is used to record the received / transmitted data, if it is 1, then the value of the lower byte of the clock generator frequency divider is set. Data transfer rate depends on the value of this frequency. The eldest divider byte is written to the next memory cell (i.e., for the COM1 port, it will be 3F9H). Below is the dependence of the data rate from the divider coefficient:

INTERRUPT ENABLE REGISTER (IER)

If DLAB \u003d 0, it is used as a register register of interrupts from an asynchronous adapter, if DLAB \u003d 1, then it sets a senior byte of the clock generator frequency.

INTERRUPT Identification Register (IIR)

Interrupt is an event at which the execution of the main program stops and the interrupt procedure begins. This register determines the type of interruption.

LINE CONTROL REGISTER (LCR)

This is the control register.

Bit 7. 1 Divisor Latch Access Bit - Data Exchange Speed
0 Common mode (interrupt control, reception / data transmission)
Bit 6. Mimic line break (sends a sequence of several zeros)
Bits 3 - 5 Bit 5. Bit 4. Bit 3. Choice of belief
X. X. 0 No parity.
0 0 1 ODD PARITY.
0 1 1 Even Parity.
1 0 1 HIGH PARITY (Sticky)
1 1 1 LOW PARITY (Sticky)
Bit 2. Number of stop bits
0 1 Stop Bit
1 2 stop bits at 6.7 or 8 data bits or 1.5 stop bits with 5 data bits.
Bits 0 and 1 Bit 1. Bit 0. Number of data bits
0 0 5 bits
0 1 6 bits
1 0 7 bits
1 1 8 bits

Checking the readiness implies the transmission of another bit - the point of readiness. Its value is set in such a way that in the bit packet, the total number of units (or zeros) was even or odd, depending on the installation of the port registers. This bit is used to detect errors that may occur during data transmission due to interference on the line. The receiving device re-calculates the parity of data and compares the result with a parity bit. If parity has not coincided, it is believed that the data is transmitted with an error.

Stop bit means ending data transfer.

MODEM CONTROL REGISTER (MCR)

Modem control register.

Bit Value
0 Line dtr.
1 RTS line.
2 Line OUT1 (spare)
3 Line Out2 (spare)
4 Starting diagnostics when entering an asynchronous adapter, closed on its output.
5-7 Equal 0.

Line Status Register (LSR)

Register defining the status of the line.

Bit Value
0 Data is obtained and ready for reading, automatically reset when reading data.
1 Overflow error. A new data byte was adopted, and the previous one was not yet read by the program. The previous byte is lost.
2 Error Readyness is reset after reading the status of the line.
3 Synchronization error.
4 A request to interrupt the transmission "Break" is detected - a long row of zeros.
5 The transmitter storage register is empty, you can record a new byte for transmission.
6 The transmitter shift register is empty. This register receives data from the storage register and converts them to a serial type for transmission.
7 Time-out (the device is not connected to the computer).

Modem Status Register (MSR)

Modem status register.

That's it. Operating these registers, you can directly communicate with the COM port, control the transmission and reception of data. If you do not want to mess with memory, you can use already ready-made components for various programming environments: C ++, VB, Delphi, Pascal, etc. They are intuitive, so, I think it's not worth the attention here.

StopBits. - Sets the number of stop bits. The field maybe
Take the following values:


  • ONESTOPBIT. - one stop bit;
  • One5STOPBIT. - one and a half stop bits (practically not
    used);
  • Twostopbit. - Two stop bits.

After all the DCB structure fields are filled, you need
Configuring the port by calling the SetCommState function:

BOOL SETCOMMSTATE (

Handle hfile

LPDCB LPDCB.

In case of successful completion, the function will return different from zero
value, and in case of error - zero.

The second mandatory structure for configuring the port is
COMMTimeouts structure. It defines temporary delay parameters
When receiving. Here is a description of this structure:

typeDef struct _commtimeouts (

DWORD ReadInterValTimeout;

DWORD READTOTALTIMEOUTMULTIPLIER;

DWORD READTOTALTIMEOUTCONSTANT;

DWORD WRITETOLTIMEOUTMULTIPLIER;

DWORD WRITETOLTIMEOUTCONSTANT;

) CommTimeouts, * lpcommtimeouts;

CommTimeouts structure fields have the following values:


  • ReadIntervalTimeout. - Maximum time interval
    (in milliseconds) allowable between two readable
    Communication line by successive characters. During
    The time of reading the time period begins to count down from
    reception of the first symbol. If the interval between two
    Sequential characters will exceed the specified value, operation
    Reading and all data accumulated in buffer are transmitted
    in the program. Zero value this field means that given
    Time-out is not used.
  • ReadTotalTimeOutmultiplier. - Specifies the multiplier (in


    multiplied by the number of characters requested to read.
  • ReadtotalTimeoutconstant - Specifies the constant (in

    Reading operations. For each read operation, this value
    plus to the result of multiplication ReadTotalTimeoutMultiplier on
    The number of characters requested to read. Zero fields
    ReadTotalTimeoutMultiplier and ReadTotalTimeoutConstant Means
    That the overall timeout for read operation is not used.
  • WritetotalTimeoutmultiplier - Specifies the multiplier (in
    milliseconds) used to calculate the total timeout

    multiplied by the number of written characters.
  • WritetotalTimeoutConstant - Specifies the constant (in
    milliseconds) used to calculate the total timeout
    Recording operations. For each record operation, this value
    Added to the result of multiplication of WritetotalTimeoutmultiplier on
    The number of writable characters. Zero fields
    WritetotalTimeoutMultiplier and WritetotalTimeOUTCONSTANT means
    That the overall timeout for the record operation is not used.

A little more in detail about the timeouts. Let we read from the port 50
Symbols with a speed of 9,600 bits / s. If 8 bits are used
on the symbol, addition to parity and one stop bit, then one
The symbol in the physical line accounts for 11 bits (including starting bits).
It means 50 characters at a speed of 9,600 bits will be accepted

50 × 11/9600 \u003d 0.0572916 with

or about 57.3 milliseconds, provided the zero interval
between receiving consecutive characters. If the interval between
The characters are approximately half the transmission time of one
symbol, i.e. 0.5 milliseconds, the reception time will be

50 × 11/9600 + 49 × 0.0005 \u003d 0,0817916

or about 82 milliseconds. If more in the process of reading
82 milliseconds, then we have the right to assume that an error occurred in
work of the external device and can stop reading, thereby
avoiding the freezing of the program. This is the overall timeout operation
reading. Similarly, there is a total timeout of the record operation.

Formula for calculating the total timeout operation, for example,
Reading, looks like this:

Numofchar x ReadTotalTimeOutmultiplier +
ReadtotalTimeoutconstant

where Numofchar is the number of characters requested for the read operation.

In our case, the timeout recording can not be used and
Set them equal to zero.

After filling in the COMMTimeouts structure, you need to call
Timeout installation feature:

BOOL SETCOMMTIMEOUTS (

Handle hfile

Lpcommtimeouts lpcommtimeouts.

Since transmission-reception operations are carried out at low speed,
Used data buffering. To set the size of the reception buffer and
Transfers must be used by the function:

BOOL SETUPCOMM (

Handle hfile

DWORD DWINQUEUE,

DWORD DWOUTQUEUE.

Suppose you exchange with the external device packages
information of the size of 1024 bytes, then a reasonable size of buffers
There will be a value of 1200. The setupcomm function is interesting because it can
Just take your dimensions to note by making your own adjustments or
In general, reject the buffer sizes offered by you - in this case
This feature is completed with an error.

I will give an example of opening and configuring sequential
port COM1. For brevity - without error definition. In this example
The port opens to work at a speed of 9,600 bits / C, used 1
Stop bit, parity bit is not used:

#Include.

. . . . . . . . . .

Handle handle;

Commtimeouts commtimeouts;

DCB DCB;

handle \u003d createfile ("COM1", Generic_read | generic_write,
NULL, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);

Setupcomm (Handle, Sizebuffer, SizeBuffer);

GetcommState (handle, & dcb);

dCB.BAUDRATE \u003d CBR_9600;

dCB.Fbinary \u003d True;

dCB.FoutXCTSFLOW \u003d FALSE;

dCB.FOUTXDSRFLOW \u003d FALSE;

dCB.FDTRCONTROL \u003d DTR_CONTROL_HANDSHAKE;

dCB.FDSRSENSITIITY \u003d FALSE;

dCB.FNULL \u003d FALSE;

dCB.FRTSCONTROL \u003d RTS_CONTROL_DISABLE;

dCB.FabortoneRror \u003d False;

dCB.BYTESIZE \u003d 8;

dCB.PARITY \u003d NOPARITY;

dCB.STOPBITS \u003d 1;

SetCommState (Handle, & DCB);

Commtimeouts.readintervaltimeout \u003d 10;

Commtimeouts.readtotalTimeoutmultiplier \u003d 1;

// the values \u200b\u200bof these time - the outs are quite enough for sure
reception

// even at speed 110 baud

Commtimeouts.readtotalTimeoutConstant \u003d 100;

// Used B this case like waiting time
parcel

Commtimeouts.writetaltimeoutmultiplier \u003d 0;

Commtimeouts.writetalTimeoutConstant \u003d 0;

SetCommtimeouts (handle, & commtimeouts);

Purgecomm (handle, Purge_RxClear);

Purgecomm (Handle, Purge_txClear);

After opening the port, the first thing you need to lose it, so
As in the buffers of reception and transmission can be "garbage". Therefore B.
end of the example we applied the function previously not known to us
PurgeComm:

BOOL PURGECOMM (

Handle hfile

DWORD DWFLAGS

This feature can perform two tasks: clean the queue
reception and transmission in the driver or completing all operations
I / O What exactly actions to perform, set to another
Parameter:


  • Purge_txabort
    records even if they are not completed;
  • Purge_RxAbort. - immediately stops all operations
    reading, even if they are not completed;
  • Purge_txclear - Clears the transmission queue in the driver;
  • Purge_Rxclear - clears the reception queue in
    Driver.
    These values \u200b\u200bcan be combined using a beaten
    Operations or. Clean buffers are recommended after errors
    acceptance and after completion with the port.

It is time to consider directly operations
Read-write for the port. As for working with files, used
Readfile and WriteFile features. Here are their prototypes:

BOOL READFILE (

Handle hfile

LPVoid LpBuffer,

DWORD NNUMOFBYTESTOREAD,

LPDWORD LPNUMOFBYTESREAD,

LpoverLapped LpoverLapped

BOOL WRITEFILE (

Handle hfile

LPVoid LpBuffer,

DWORD NNUMOFBYTEWRITE,

LPDWORD LPNUMOFBYTESWRITENTEN,

LpoverLapped LpoverLapped

Consider the assignment of the parameters of these functions:


  • hfile - Descriptor open File Communication
    port;
  • lpBuffer. - The address of the buffer. For write operation data from
    This buffer will be transmitted to the port. For reading operation in this
    The buffer will be placed by the data taken from the line;
  • nNUMOFBYTESTOREAD, NNUMOFBYTEWRITE. - Number of expected
    to receiving or intended for transmission byte;
  • nNUMOFBYTESREAD, NNUMOFBYTESWRITTEN. - The number of actual
    accepted or transmitted bytes. If accepted or transferred less
    data than requested, it testifies to the disk file
    About the error, and for the communication port is not necessarily.
    Cause in timeouts.
  • LpoverLapped. - address of the Overlapped structure used
    For asynchronous operations.

In case of normal completion, the function is returned to
different from zero, in case of error - zero.

I will give an example of reading and writing operation:

#Include.

…………..

DWORD NUMBYTS, NUMBYTES_OK, TEMP;

Comstat Comstate;

Overlapped overlap;

char buf_in \u003d "Hello!";

numBytes \u003d 6;

// If TEMP is not zero, it means that the port is able
Errors

if (! temp) WriteFile (handle, buf_in, numbytes,
& NUMBYTES_OK, & OVERLAP);

ClearCommerror (Handle, & Temp, & Comstate);

if (! Temp) Readfile (handle, buf_in, numbytes, & numbytes_ok,
& OVERLAP);

// in the NUMBYTES_OK variable contains a real number
transmitted

// accepted byte

In this example, we used two unknown me earlier
COMSTAT and OVERLAPPED structures, as well as the ClearCommerror function. For
our communication case "in three wires" structure overlapped
Consider (just use as in the example). Prototype function
Clearcommerror has the form:

BOOL CLEARCOMMERROR (

Handle hfile

LPDWORD LPERRORS,

Lpcomstat lpstat.

This feature resets the port error sign (if any
place) and returns information about the state of the port in the structure
Comstat:

typeDef struct _comstat.

DWORD FCTSHOLD: 1;

DWORD FDSRHOLD: 1;

DWORD FRLSDHOLD: 1;

DWORD FXOFFHOLD: 1;

DWORD FXOFFSENT: 1;

DWORD FEOF: 1;

DWORD FTXIM: 1;

DWORD FRERVED: 25;

DWORD CBINQUE;

DWORD CBOUTQUE;

) Comstat, * lpcomstat;

We can use two fields of this structure:


  • CBinque - The number of characters in the receiving buffer. These symbols
    taken from the line, but not yet read by the readfile function;
  • CBoutque - The number of characters in the transmitting buffer. These
    Symbols are not yet transmitted to the line.

The remaining fields of this structure contain information about
Errors.

Finally, after completing work with the port, it should be closed.
Closing the object in Win32 executes the Closehandle function:

BOOL CLOSEHANDLE (

Handle hobject.

On our site you can find the full text of the class for working with
sequential port in asynchronous mode "in three wires", and
Also an example of a program using this class. All this
written under Builder C ++, but because only functions are used.
API Win32, the program text is easy to change for any C ++ compiler.
It is also possible that the class is not written quite "according to the rules" - I ask
excuse, the author is not a "right" programmer and writes so
How it is comfortable j.

I welcome everyone again on the pages of your blog and today I want to tell how connect com uSB port In Windows. Let's talk that it is and for what is used. I think for novice network administrators, and just for advanced users it will be interesting, for me, at one time it was just some kind of magic that allows you to configure server equipment.

What is connected via COM port

Through the COM port previously connected modems, mice. Now it is used to connect to sources uninterrupted power, for communication with hardware development of embedded computing systems, satellite receivers, cash registers, with devices for object security systems, as well as with many other devices.

Using the COM port, you can connect two computers using the so-called "zero-modem cable" (see below). Used from MS-DOS times to pump files from one computer to another, in UNIX for terminal access to another machine, and in Windows (even modern) - for the kernel level debugger.

But in the network world through COM portconnect to the cantilever port of network devices (switches, routers, brands such as Cisco or Juniper)

What is the circuit of connecting to switches through the serial port. There are adapters, for example, from St-Lab at one end of the USB which you connect to a computer, and the second is a COM port.

Installing COM Drivers USB Port in Windows

Unfortunately in Windows connected devices, USB to COM is not always automatically installed in the system, and you have to search for them drivers. If you bought it yourself, then the drive was included with the drivers, and you can use it if it is not, then look at how to find drivers.

Open the device manager in Windows. If you don't know how, then press CTR + Pause Breake, or press Win + R and enter Devmgmt.msc in the window. As you can see in the ports section (COM and LPT), I was found on the third COM port Unknown wire, and the drivers did not find for him from the system, which the yellow icon tells us.

Go to Properties this device And choose the equipment ID, you will have, something by type USB \\ vid_067b & pid_2303 & rev_0300, here you are copying it and look for in Google or Yandex.

Then click on the right click on the device in the device manager and select install the drivers, indicate the path to them and put if everything is OK, then you have the icon will disappear Warnings.

Next, you can already use the possibilities of the COM port, using such utilities on the semblance of Putty, where you select Serial and specify the desired COM port port, you can see it in the same device manager.

I hope you learned and figured out how to connect the COM USB port in Windows.