Now one process has already open the serial port COMx to read data, then if I use ::CreateFile to open it, it would fail.
So I would like to know whether I can read data simultaneously(open serial port) with two process from same serial port or not.
Printable View
Now one process has already open the serial port COMx to read data, then if I use ::CreateFile to open it, it would fail.
So I would like to know whether I can read data simultaneously(open serial port) with two process from same serial port or not.
No. Comports can only be used by 1 filehandle at a time, and you can't share filehandles between programs.
I heard about may use *virtual port*
I google "virtual port", then it's all serial port simulator,
Does anybody knows *virtual port* stuff?
I just need to read data via two processes!
Processes or applications ? If you mean 2 processes within 1 application then you CAN share the filehandle, but you will need to add semaphores/mutexes for process synchronization.
One process(I have not owned the code) existing in my application open the serial port COMx to read data(I can ensure that the process don't write data to COMx), Now I need to open COMx also to read data.Quote:
Could you explain why you need it? Perhaps, we could suggest you some workaround?
So can you suggest some wordaround?
Well, your description is very unclear: what kind of data to be read from COMx, what do you mean by this process YOU "have not owned the code", what do you need the data from COMx for, ...?
So, without knowing all these thing I can suggest you very simple and straightforward "woraround": don't use this process you "have not owned the code" and rather write your own code to read from COMx. See the code example in Serial Port essay.
One com port can only serve one connection at a time. Unless you have ways for the 3rd party process to connect/release the port as you wish, there is no way for your own process to gain the port connection.
The only way I can think of is to install a new com port (new hardware), then tab pin 2,3,5 of existing com port (with extra wires) over to pin 2,3,5 of new port, and have your own process connect to new com port. That way, your own process will receive the same data simultaneously.
Regards
Kevin Choong