04-30-2009 03:15 PM
I need to read status of CTS line of an RS232 port while port is opened by another application. Port is already open and I do not have direct access to the port lines via CVI functions.
Is there anyway to do this? I am not sure If I can read port registers using inp function.
05-01-2009 12:24 AM
I think best way to find out is to try it.
Write a small application that uses the inp function and reads the memory range of the COM port (can be found from the Device Manager).
Before running that executable, open the COM port using the interactive execution.
Manually apply voltages on the pins, or just apply some jumpers and observe the results.
Btw, I realized I didn't know the signal level for control signals, are they TTL or like the TX/RX signals?
I'd be glad if you could post the resuts here 
05-01-2009 07:37 AM
Hi Thanks for your suggestion. I am using USB to serial cable and in my device manager I don't have Resources tab which list address range for that port.
My comport number is 3.
Any other idea?
05-01-2009 11:18 AM
Hey test_man,
The function viGetAttribute can be called for the VI_ATTR_ASRL_CTS_STATE attribute using the NI-VISA driver. This returns the status of the CTS line. If the port is opened by a non-VISA call, then you won't be able to do this. Like you said, using the inp function would work if you were able to find the address space of the USB device. I'll have to research into this a bit more to see if I can find where the USB device's I/O range is.
05-01-2009 04:30 PM
test_man,
I wasn't able to find where the I/O range for this device is set, but you might be able to do something with the Windows API. You'd have to research into that more to figure out if that's a possibility though
05-02-2009 03:37 PM
05-04-2009 03:13 AM
Justin_E wrote:
"you might be able to do something with the Windows API"
Let's have a look at the Windows SDK, in "About Communications resources/Communications resource handle":
"When the process uses CreateFile to open a communications resource, it must specify certain values for the following parameters: [...] The fdwShareMode parameter must be zero, opening the resource for exclusive access. "
this line taken from the SDK tells us that anybody willing to open a COM port must have exclusive access over it. the only calls allowing to read the status of the CTS line needs a file handle to do so. so i can conclude that to read the status of the CTS line, you should have opened the port yourself.
in any case, reading the status of a flow control line when you are not part of the conversation is not clean. ho, and i forgot: when will people stop using the serial and parallel ports as a general purpose i/o board? these ports were never intended for this, but there are boards made specifically for this kind of stuff.
05-04-2009 07:40 AM
Serial port monitors do monitor status of RTS and CTS lines when port is opened by another application. So solution is out there...I just don't know how to do it.
For example, I tried HHD Free serial port monitor. It successully monitored all of the lines of serial port while serial port was opened my another application at the same time.
05-04-2009 09:02 AM
i can bet that a serial port monitor is a special driver loaded on top of microsoft driver.
on Windows, most driver type allows for filters or mini-drivers which sit between the real driver and the kernel to perform special processing. personally, i would implement it this way. unfortunately, this means really low level development, with extra care because this kind of drivers run in kernel-mode, and a special communication pipe between the kernel-mode driver and the user-mode application. you may find more informations about driver development in the Windows Driver Development Kit, which is available from Microsoft's website.