I have to create virtual com port,by which I can communicate with other com port on machine,It is a part of device driver development?or simply we can write in c++.
Anyone can help me on this Thanks in advance.
You'll have to write a driver, so you'll need to install the WDK (previously called DDK). But you're lucky, because the Windows Driver Kit Samples Pack contains a Virtual Serial port samples.
It seems that you want a 'translater' to talk with a device, why not simply write a filter driver and implement some additional IOControls?
If you really want to access an other port from within your driver (which I already did once), you should look up following functions:
IoGetDeviceObjectPointer
/ ObDereferenceObject
(for opening/closing the port)IoBuildDeviceIoControlRequest
/ IoCallDriver
(for sending IOCTL's to change port settings)IoBuildSynchronousFsdRequest
/ IoCallDriver
(for writing/reading data)Structures/IOCTL's you'll need:
SERIAL_BAUD_RATE
(for IOCTL_SERIAL_SET_BAUD_RATE
/IOCTL_SERIAL_GET_BAUD_RATE
)IOCTL_SERIAL_SET_TIMEOUTS
SERIAL_HANDFLOW
(for IOCTL_SERIAL_SET_HANDFLOW
/IOCTL_SERIAL_GET_HANDFLOW
)SERIAL_LINE_CONTROL
(for IOCTL_SERIAL_SET_LINE_CONTROL
)IOCTL_SERIAL_PURGE
IOCTL_SERIAL_SET_WAIT_MASK
/IOCTL_SERIAL_GET_WAIT_MASK
IOCTL_SERIAL_SET_CHARS
/IOCTL_SERIAL_GET_CHARS
IOCTL_SERIAL_WAIT_ON_MASK
A complete overview of control requests can be found here
Have a nice trip :)
I am assuming you are asking this for a Windows environment because you tagged with winapi.
Yes, you will need to write a virtual driver for this. The good news is, the DDK (now called the WDK) is freely available from MS. If you don't have VS2013 (required for the 8.1 version of the WDK), you can get the Express Edition from the MS web site for free.
on edit: you might want to check this out - http://com0com.sourceforge.net/. From the description:
The Null-modem emulator is an open source kernel-mode virtual serial port driver for Windows, available freely under GPL license.
The Null-modem emulator allows you to create an unlimited number of virtual COM port pairs and use any pair to connect one COM port based application to another. Each COM port pair provides two COM ports. The output to one port is the input from other port and vice versa.
It sounds like it might be pretty much what you're looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With