Download example source code

Windows 10 Communications Port I upgraded to Windows 10. Now when I try and communicate with a device at work, via a USB com port, the system does not recognize any serial, or communications port. I bought a Serial to USB connector for a device that i want to connect with my laptop since my laptop does not have those Serial port that usually came with Desktops. So when i insert the cable and installed the driver, the program that i want the device to connect it with says:' Failed to open COM 1 '. Acer’s product range includes laptop and desktop PCs, tablets, smartphones, monitors, projectors and cloud solutions for home users, business, government and education.


Introduction to RS-232:

RS232 is the most known serial port used in transmitting the data in communication and interface. Even though serial port is harder to program than the parallel port, this is the most effective method in which the data transmission requires less wires that yields to the less cost. The RS232 is the communication line which enables the data transmission by only using three wire links. The three links provides ‘transmit’, ‘receive’ and common ground...

Android runs Linux under the hood, and Linux treats serial ports differently than Windows does. Javax.comm also contains win32com.dll, a driver file, which you won't be able to install on an Android device. If you do find a way to achieve what you're trying to do, you can't actually look for a 'COM' port in a Linux environment. The original IBM standard LPT port did not provide bidirectional communications (talkback) and was designed solely for one-way data streams to a printer. The standard addresses are IRQ 7 for LPT1 and IRQ 5 assigned to LPT2, if it is present.

The ‘transmit’ and ‘receive’ line on this connecter send and receive data between the computers. As the name indicates, the data is transmitted serially. The two pins are TXD & RXD. There are other lines on this port as RTS, CTS, DSR, DTR, and RTS, RI. The ‘1’ and ‘0’ are the data which defines a voltage level of 3V to 25V and -3V to -25V respectively.

The electrical characteristics of the serial port as per the EIA (Electronics Industry Association) RS232C Standard specifies a maximum baud rate of 20,000bps, which is slow compared to today’s standard speed. For this reason, we have chosen the new RS-232D Standard, which was recently released.

The RS-232D has existed in two types. i.e., D-TYPE 25 pin connector and D-TYPE 9 pin connector, which are male connectors on the back of the PC. You need a female connector on your communication from Host to Guest computer. The pin outs of both D-9 & D-25 are show below.

D-Type-9 pin no.

D-Type-25pin no.

Pin outs

Function

3

2

RD

Receive Data(Serial data input)

2

3

TD

Transmit Data (Serial data output)

7

4

RTS

Request to send(acknowledge to modem that UART is ready to exchange data

8

5

CTS

Clear to send(i.e.; modem is ready to exchange data)

6

6

DSR

Data ready state(UART establishes a link)

5

7

SG

Signal ground

1

8

DCD

Data Carrier detect(This line is active when modem detects a carrier

4

20

DTR

Data Terminal Ready.

9

22

RI

Ring Indicator(Becomes active when modem detects ringing signal from PSTN

About DTE & DCE:

Devices, which use serial cables for their communication, are split into two categories. These are DCE (Data Communications Equipment) and DTE (Data Terminal Equipment.) Data Communications Equipments are devices such as your modem, TA adapter, plotter etc while Data Terminal Equipment is your Computer or Terminal. A typical Data Terminal Device is a computer and a typical Data Communications Device is a Modem. Often people will talk about DTE to DCE or DCE to DCE speeds. DTE to DCE is the speed between your modem and computer, sometimes referred to as your terminal speed. This should run at faster speeds than the DCE to DCE speed. DCE to DCE is the link between modems, sometimes called the line speed.

Most people today will have 28.8K or 33.6K modems. Therefore, we should expect the DCE to DCE speed to be either 28.8K or 33.6K. Considering the high speed of the modem we should expect the DTE to DCE speed to be about 115,200 BPS.(Maximum Speed of the 16550a UART) . The communications program, which we use, has settings for DCE to DTE speeds. However, the speed is 9.6 KBPS, 144 KBPS etc and the modem speed.

Usb To Com1

If we were transferring that text file at 28.8K (DCE-DCE), then when the modem compresses it you are actually transferring 115.2 KBPS between computers and thus have a DCE-DTE speed of 115.2 KBPS. Thus, this is why the DCE-DTE should be much higher than the modem's connection speed. Therefore, if our DTE to DCE speed is several times faster than our DCE to DCE speed the PC can send data to your modem at 115,200 BPS.

What is NULL MODEM?

Null modem is used to connect two DTE's together. This is used to transfer files between the computers using protocols like Zmodem protocol, xmodem protocol, etc

Figure: Above shows the connections of the Null modem using RS-232D connecter

Above-mentioned figure shows the wiring of the null modem. The main feature indicated here is that the to make the computer to chat with the modem rather than another computer. The guest & host computer connected through the TD, RD, and SG pins. Any data that is transmitted through TD line from the Host to Guest is received on RD line. The Guest computer must have the same setup as the Host. The signal ground (SG) line of the both must be shorted so that grounds are common to each computer.

The Data Terminal Ready(DTR) is looped back to Data Set Ready and Carrier Detect on both computers. When the Data Terminal Ready is asserted active, then the Data Set Ready and Carrier Detect immediately become active. At this point, the computer thinks the Virtual Modem to which it is connected is ready and has detected the carrier of the other modem.

All left to worry about now is the Request to Send and Clear To Send. As both computers communicate together at the same speed, flow control is not needed thus these two lines are also linked together on each computer. When the computer wishes to send data, it asserts the Request to Send high and as it is hooked together with the Clear to Send, It immediately gets a reply that it is ok to send and does so.

The Ring indicator line is only used to tell the computer that there is a ringing signal on the phone line. As we do not have, a modem connected to the phone line this is left disconnected

To know about the RS232 ports available in your computer, Right click on 'My Computer', Goto 'Properties', Select tab 'Device Manager', go to Ports( COM & LPT ), In that you will find 'Communication Port(Com1)' etc. If you right click on that and go to properties, you will get device status. Make sure that you have enabled the port( Use this port is selected).

How to program the Serial Port using C/C++?

There are two popular methods of sending data to or from the serial port in Turbo C. One is using outportb(PORT_ID, DATA) or outport(PORT_ID,DATA) defined in “dos.h”. Another method is using bioscom() function defined in “bios.h”.

Using outportb() :

The function outportb () sends a data byte to the port ‘PORT_ID’. The function outport() sends a data word. These functions can be used for any port including serial port, parallel ports. Similarly to receive data these are used.

  • inport reads a word from a hardware port

  • inportb reads a byte from a hardware port

  • outport outputs a word to a hardware port

  • outportb outputs a byte to a hardware port

Declaration:

  • int inport(int portid);

  • unsigned char inportb(int portid);

  • void outport(int portid, int value);

  • void outportb(int portid, unsigned char value);

Remarks:

  • inport works just like the 80x86 instruction IN. It reads the lowbyte of a word from portid, the high byte from portid + 2.

  • inportb is a macro that reads a byte

  • outport works just like the 80x86 instruction OUT. It writes thelow byte of value to portid, the high byte to portid + 1.

  • outportb is a macro that writes value Argument

portid:

  • Inport- port that inport and inportb read from;

  • Outport- port that outport and outportb write to

value:

  • Word that outport writes to portid;

  • Byte- that outportb writes to portid.

If you call inportb or outportb when dos.h has been included, they are treated as macros that expand to inline code.

If you don't include dos.h, or if you do include dos.h and #undef themacro(s), you get the function(s) of the same name.

Return Value:

#inport and inportb return the value read

#outport and outportb do not return

For more details of these functions read article from beondlogic.com

Using bioscom:

The macro bioscom () and function _bios_serialcom() are used in this method in the serial communication using RS-232 connecter. First we have to set the port with the settings depending on our need and availability. In this method, same function is used to make the settings using control word, to send data to the port and check the status of the port. These actions are distinguished using the first parameter of the function. Along with that we are sending data and the port to be used to communicate.

Here are the deatails of the Turbo C Functions for communication ports.

Declaration:

bioscom(int cmd, char abyte, int port)
_bios_serialcom(int cmd ,int port, char abyte)

bioscom() and _bios_serialcom() uses the bios interrupt 0x14 to perform various communicate the serial communication over the I/O ports given in port.

cmd: The I/O operation to be performed.

cmd (boiscom)

cmd(_bios_serialcom)

Action

0

_COM_INIT

Initialise the parameters to the port

1

_COM_SEND

Send the character to the port

2

_COM_RECEIVE

Receive character from the port

3

_COM_STATUS

Returns rhe current status of the communication port

portid: port to which data is to be sent or from which data is to be read.

0: COM1
1: COM2
2: COM3

abyte:

When cmd =2 or 3 (_COM_SEND or _COM_RECEIVE) parameter abyte is ignored.

When cmd = 0 (_COM_INIT), abyte is an OR combination of the following bits(One from each group):

value of abyte

Meaning

Bioscom

_bios_serialcom

0x02

0x03

_COM_CHR7

_COM_CHR8

7 data bits

8 data bits

0x00

0x04

_COM_STOP1

_COM_STOP2

1 stop bit

2 stop bits

0x00

0x08

0X10

_COM_NOPARITY

_COM_ODDPARITY

_COM_EVENPARITY

No parity

Odd parity

Even parity

0x00

0x20

0x40

0x60

0x80

0xA0

0xC0

0xE0

_COM_110

_COM_150

_COM_300

_COM_600

_COM_1200

_COM_2400

_COM_4800

_COM_9600

110 baud

150 baud

300 baud

600 baud

1200 baud

2400 baud

4800 baud

9600 baud

For example, if

abyte = 0x8B = (0x80 0x08 0x00 0x03)= (_COM_1200 _COM_ODDPARITY _COM_STOP1 _COM_CHR8)

the communications port is set to
1200 baud (0x80 = _COM_1200)
Odd parity (0x08 = _COM_ODDPARITY)
1 stop bit (0x00 = _COM_STOP1)
8 data bits (0x03 = _COM_CHR8)

To initialise the port with above settings we have to write,

bioscom(0, 0x8B, 0);

To send a data to COM1, the format of the function will be bioscom(1, data, 0). Similarly bioscom(1, 0, 0 ) will read a data byte from the port.

The following example illustrate how to serial port programs. When a data is available in the port, it inputs the data and displays onto the screen and if a key is pressed the ASCII value will be sent to the port.

#include <bios.h>
#include <conio.h>
#define COM1 0
#define DATA_READY 0x100
#define SETTINGS ( 0x800x020x000x00)
int main(void)
{
int in, out, status;
bioscom(0, SETTINGS, COM1); /*initialize the port*/
cprintf('Data sent to you: ');
while (1)
{
status = bioscom(3, 0, COM1); /*wait until get a data*/
if (status & DATA_READY)
if ((out = bioscom(2, 0, COM1) & 0x7F) != 0) /*input a data*/
putch(out);
if (kbhit())
{
if ((in = getch()) 27) /* ASCII of Esc*/
break;
bioscom(1, in, COM1); /*output a data*/
}
}
return0;
}

Com1 Port

When you compile and run the above program in both the computers, The characters typed in one computer should appear on the other computer screen and vice versa. Initially, we set the port to desired settings as defined in macro settings. Then we waited in an idle loop until a key is pressed or a data is available on the port. If any key is pressed, then kbhit() function returns non zero value. So will go to getch function where we are finding out which key is pressed. Then we are sending it to the com port. Similarly, if any data is available on the port, we are receiving it from the port and displaying it on the screen.

To check the port, If you have a single computer, you can use loop-back connection as follows. This is most commonly used method for developing communication programs. Here, data is transmitted to that port itself. Loop-back plug connection is as follows.


Fig 2. Loop-back plug connection

If you run the above program with the connection as in this diagram, the character entered in the keyboard should be displayed on the screen. This method is helpful in writing serial port program with single computer. Also you can make changes in the port id if your computer has 2 rs232ports. You can connect the com1 port to com2 of the same computer and change the port id in the program. The data sent to the port com1 should come to port com2. then also whatever you type in the keyboard should appear on the screen.

The program given below is an example source code for serial communication programmers. It is a PC to PC communication using RS232. Download the code, unzip and run to chat in dos mode between two computers. Use the program to get more idea about serial port programming.

Click here to download example source code: pc2pc.zip

Com1

Please contact us if any problem exits in the above programs.

>Interfacing Links:Links related to serial port, bioscom function, rs232, rs485, usb, parallel port etc.
>Click here to list other C Programming sites

Click here to send feedback or use email: [email protected] or [email protected]

Note: Examples given above are tested with Turbo C++ Compiler Version 3.0. How ever, we do not give any guaranty for working of the programs in the examples.

Summary :

COM ports are common components of Device Manager. Windows users can see them easily by opening the Device Manager. However, problems may occur, causing the COM ports lost from Device Manager. If you are encountering this, please read the methods mentioned below to try to fix the problem yourself.

COM stands for Communication port and it is actually the original name of the serial port interface. The COM can be used to refer both physical ports and emulated ports, which are created via the Bluetooth or USB-to-serial adapters. Well, the COM ports missing in Device Manager problem happens now and then.

How to access Windows 10 Device Manager ports?

  1. Right click on This PC icon on the desktop.
  2. Choose Manage from the context menu.
  3. Select Device Manager under System Tools. (You can also press Start + X directly to select Device Manager.)
  4. Choose View from the menu bar.
  5. Choose Show hidden devices from the submenu.
  6. Locate Ports (COM & LPT) from the list in the right pane.
  7. Expand it to find Communications Port (COM).

MiniTool Software could help you recover data from hard disk, USB flash drive, and other external storage. If you find the USB ports not showing in Device Manager Windows 10, please read this to know how to fix USB not recognized issue.

Various solutions are provided for you to fix USB flash drive not recognized error and recover data from the inaccessible flash drive.

Usb To Com1 Driver

COM Ports Missing in Device Manager

However, there are many peoples said they can’t find ports in Device Manager and they desperately need a solution to it.

COM Ports Not Showing in Device Manager: Ture Cases

One: Com Port is Missing / Ports Option Not Available In Device Manager.

My com port is missing. And the ports option is not available in Device Manager. I'm able to perfectly connect and use my phone/modem with the computer. I had gone through several discussions about same topic here in answers.microsoft.com to no avail. How do I enable it, or can you provide a link where I can download this com driver for windows 10? Thanks.- posted by etwdensegen sprechen in Microsoft Forum

Two: No Ports shown in Device Manager (even hidden) Win 7 Pro 64 bit.

I can't get an external modem to work (even though it shows in devices and printers window. I can't get a USB-serial port converter to work either. It would be helpful if I had info from the device manager window but nothing show up, even though I have turned on the show hidden devices. Any ideas? Thanks.- asked Paul Saacke in Microsoft Forum

Three: COM PORT is disappeared in Device Manager.

When I opened device manager at that time I found that, portable devices COM port option disappeared from device manager. What should I have to do to resolve this issue?- said SAY014 in HP Forum

So how to fix the problem and find back your Windows 10 COM ports? Please keep reading!

How Do I Add a COM Port to Device Manager

Some users complained that their Widows 10 COM ports disappeared from Device Manager after they have upgraded their Windows platforms. Whatever the cause, the users’ primary concern is how to restore missing COM ports. That’s what I’m going to talk in this section.

Method 1: Show hidden devices.

As I have mentioned at the beginning of this article, users can’t see the COM ports directly. Instead, they need to open Device Manager -> select View tab -> choose Show hidden devices. After that, they’ll see the Ports (COM & LPT) option and they only need to expand it to fins COM ports.

Method 2: add COM ports manually.

  1. Open Device Manager on your Windows 10 computer.
  2. Click on the Action option from menu bar.
  3. Choose Add legacy hardware from the submenu to open the Add Hardware window.
  4. Click on the Next button to move on.
  5. Check Install the hardware that I manually select from a list (Advanced) and press Next.
  6. Select Ports (COM & LPT) from the given list and press the Next button.
  7. Choose Standard port types option or the manufacturer for the ports; then, click Next.
  8. Click on the Finish button to complete.

Method 3: update the motherboard drivers.

Com1 Port Pc

If the motherboard drivers are too outdated, they will also lead to COM ports missing in Device Manager. Therefore, you are advised to update your motherboard drivers manually and see whether it works.

Coments are closed
Scroll to top