how to get the count of inbuilt serial ports availability in vxworks - vxworks

Is there a way to know how many inbuilt serial ports are available?. We can enable or disable these ports, when the vxworks image is built. For example, if I give command /devs it lists /tyCo/0 and /tyCo/1. I want to know is there a way to know that there are 2 inbuilt serial ports available.

Related

Is there a POSIX way of determining if a file (serial port actually) is open-able without opening it?

We make a device that can appear as a USB serial port on a variety of POSIX-compliant systems. I'm supporting an API that allows callers to retrieve a list of all the currently available (i.e. not in use, have correct privileges, etc.) instances of our device available to them. The caller can also get a list where the in-use devices are also indicated.
The simple way to do this of course is just attempt to open/close each candidate serial port and take note of which ones are open-able. I would prefer not to do this as it is possible that multiple applications using this API (which would be a library / dylib in their app) could create race conditions where they both try to query the same serial port simultaneously which would cause one app to erroneously think the device was in use.
So what I need is a way of knowing the port is open-able without actually opening it. I have seen others use lock-file schemes where there is a special file created to indicate the port is in use - the assumption being that if the file is not present the port is available. My problem is that there may be other users of the port other than my library that do not abide by such as scheme, so I cannot rely on it.
Is there perhaps some low-level POSIX functionality that lets me query a file's status in this regard without actually attempting to open it?

Mac Application - Disable specific USB port

There is any way to I disable/enable a specific USB Port with my application ?
I'm not aware of any way to do this from user space, and even within the kernel it could be tricky: I think you would need to install a dummy I/O Kit driver which matches all USB devices and/or interfaces. This could be tricky as existing drivers would take precedence, so you'd need to work around that. Once matched, you would check the port in the driver's probe() method and return true if it was one of the disallowed ports. This would stop other drivers from grabbing the device, which would essentially disable it.

SerialPort.GetPortNames() not returning correct result

I'm developing small demo application for Windows Mobile 6.1 to get the list of all serial ports and the Bluetooth devices configured on them. I'm facing some weird problem.
I can see total 10 COM ports when I go to Settings->Connections->Bluetooth->COM POrts. But when I use SerialPort.GetPortNames() to get all the ports, it shows 9 ports i.e. one port less. The last port i.e. COM09 is not returned in the result set.
Then I removed one of the paired devices configured on one of the COM ports (COM08) and SerialPort.GetPortNames() returned the result set WITHOUT the COM08 port.
I further tried to know which COM ports are still unused. When i tried to create "New Outgoing Port" manually on one of the 'unused' (as per my program) port, it gives a message saying "COM port cannot be created"!
Could someone tell me the reason and guide me further to resolve the issue?
The Bluetootch driver is probably modifying the registry key where the Drivers are and GetPortNames is probably looking through that key.
Take a look at both HKLM\Drivers\BuiltIn and HKLM\Drivers\Active with the remove registry editor and see what's happening. You can likely write your own parser that looks at these values for what you are after.

How to access a PCMCIA modem's serial number?

A Sprint cellular modem plugs into a laptop - often the PCMCIA slot. To connect, the user opens a program called the Connection Manager. This program has a menu option to display the serial number and phone number of the modem that's currently inserted.
Does that imply that the serial/phone number of the modem could be available to other programs running on the system? (Note: let's assume this is Windows XP.)
Specifically, could a company's VPN software be configured to pass along information about which modem is being used to connect?
Finally, is there existing VPN software that already does this, or would it have to be custom-programmed?
Sometimes you can get the modem's serial number using the AT command set. To see this in action, go to your control panel and open up Phone and Modem Options. Select the Modems tab, select the modem you're interested in, and choose Properties.
In the modem window, select the Diagnostics tab, and press the Query Modem button.
This opens the serial port and sends a series of AT commands to gather various settings and information. You can open the serial port in your program (or a terminal program), send the AT command, and get the same information back.
You may need to check your specific modem's AT command set to find where the serial number is stored, or use a serial port spy program to see how Sprint's program does it.
I'm not aware of any VPNs that use this information, and I can think of several ways to spoof it, since communications between the modem and the computer are not cryptographically secure.
-Adam
Open hyperterminal or make a serial port connection programatically and use Hayes AT language to talk to it. Most software also has it listed in the device properties and/or diagnostics.
AT+GSN
press enter

How do I determine which process is using a serial port?

The company I work for makes hardware that communicates to the computer though a serial port. Third party companies write software that communicates with our hardware.
There are times when I need to diagnose our hardware. However, a third party software app connects to the serial port when Windows starts up, blocking any other connection. I don't know the name of this application/service and it's not always the same one.
Is there any way to either:
Find the name/pid of the app/service that is currently using a given serial port or
Steal the serial port connection from another app.
vb.net preferably, but I'll take a language agnostic answer as well.
You can use the process explorer tool also from SysInternals to search for open handles. In this case you would want to search for 'Serial' since it uses device names that may not map to com port numbers. (e.g. COM1 is \Device\Serial0 on my system).
If you want to take control of the serial port from another app I think you would need co-operation of the driver.
As Rob Walker said, you can find who's using a serial port using Process Explorer. Most of the time, typing Ctrl+F and searching for "serial" will show you who has a serial port open, but I just ran into a situation where my "COM3" serial port's handle appeared as "\Device\VCP0". It may be strange because it was running under VirtualBox with a USB-to-serial connector.
If searching for "serial" and "device\vcp" don't get you any results, you may be able to figure out how serial port handles are named by opening one with a known program. In Process Explorer, display the lower pane with each process's open handles by typing Ctrl+L. Click on the process that you used to open the serial port and look through the lower pane to see which handles look like they might be a serial port. You can open and close the port while you're looking, and the file handle should appear and disappear, as well as being highlighted in green or red. Of course, this is only possible if you have more than one serial port or the serial port you're trying to diagnose isn't always locked by some mystery process.
Sysinternals has a slew of utilities I find very useful and educational for tracking down what processes are doing to the system.
They have a utility that does exactly what you need called Portmon, and give some information on how it works near the bottom of the page. That info and a few well-asked questions will probably give you everything you need to implement it yourself if the utility isn't enough.
-Adam