tags:

views:

443

answers:

2

I'm currently working on a project that utilizes a proprietary PCMCIA radio card to communicate with some wireless devices. I currently have a background process that handles reading data to and from the card and storing it for processing, but I'd like to be able to shut down power to the card when my application is not running. I've done some investigating, and while WMI evidently does support the CIM_PCMCIAController profile in its WIN32_PCMCIAController implementation, the SetPowerState() and Reset() functions are not implemented. Does anyone know of a way (with or without WMI) to control the power state of the slot? I need to be able to programatically both power off and power on either the slot or the card.

Edit

Several people I've spoken to have suggested adding a function to the card that would facilitate this. Unfortunately modifying the card to provide this sort of functionality really isn't an option right now.

Edit 2

I've confirmed that the device does show up in the Device Manager under the "Multifunction adapters" category, though neither disabling the device nor the PCMCIA controller itself from here has any effect on the power of the card.

+1  A: 

I'm curious, but does using the "Safely remove hardware..." button turn off the power to the device, enough to satisfy your requirement?

If that works, you could programatically register and unregister the device through Microsoft's API. Here is a page that shows a couple functions that might be helpful for this scenario: http://msdn.microsoft.com/en-us/library/aa363234(VS.85).aspx

Matt Andreko
Thanks, I'll give this suggestion a shot as soon as I get back to work on Monday (I don't have the card at home with me).
Adam Robinson
Not sure why, but it won't let me delete my previous comment...the device itself doesn't actually show in the "Safely remove hardware" dialog. The device ITSELF doesn't actually show in the Device Manager (though I will double check that on Monday), only the two virtual COM ports that it creates.
Adam Robinson
Original post updated...the device shows in the device manager, but disabling it has no effect on the power state.
Adam Robinson
+1  A: 

Presumably, the device has it's own drivers of some sort and shows-up in Device Manager.

In which case, you could disable the device by calling devcon (Command-line equivalent of Device Manager), from inside your program. This would make windows handle shutting down the device.

devcon disable. See Example #31 for an example of how to shutdown device by a specific device id.

Am I going on the right-lines, or have I misinterpreted your question?

Ali Lown
The device drivers create two virtual COM ports. I know that those ports show up in device manager, but I'm not confident that the card itself does. I will have to check on Monday.
Adam Robinson
Ok. Let us know on Monday. If not, is the card port controlled by a specialized chipset, or is it connect straight to the south-bridge? Because you could try getting on of those controllers to cut power to the port.
Ali Lown
@Ali: If that's something that would change from machine to machine (ie, it's machine-specific, rather than card-specific), then that won't work as this needs to be a generic solution for any laptop with the card in it.
Adam Robinson
Sorry, I hadn't considered that possibility. Requesting this functionality to be built into future generations of the card, (or at least some form of driver) is starting to look the best way to do this. Or just accept that it will sit there drawing a small amount of current all the time?
Ali Lown
Original post updated...the device shows in the device manager, but disabling it has no effect on the power state.
Adam Robinson
Actually, the current draw really isn't what I'm concerned with. The card I'm working with creates a network when there's power applied to it, and that network will be visible to the wireless nodes that we have in place. Since there's no GUI running to respond to commands, though, this will cause the nodes to try to connect to me and will eventually time out before attempting to connect to another network, whereas if I could turn off the card then they (obviously) wouldn't try to connect to me and would connect to the next available network.
Adam Robinson
Aah. Unfortunately, I am out of ideas for the program. If disabling the device and/or the slot, has no effect on its power state, yet the power is being taken from the laptop, not external, I cannot think of any other way to cut power without the device being able to do it itself. Since it is now down to the bios to control it's power state. (Any power saving bios settings to turn off the port after certain inactive time perhaps?)
Ali Lown
I've accepted your answer because you were more responsive in working with me on it. While the issue hasn't actually be resolved, I figured someone should get it and since you communicated more I picked you.
Adam Robinson
Thank you. If I have any further ideas on this, I will notify you. I can't think of anything else that will control power at this high level. Firmware upgrade for the device (assuming it has such capabilities, if not you might be able to re-program the main chip), to stop it sending data to the port perhaps? (This might trick it into thinking that the device is 'sleeping' or similar, and make it cut the power.) (Only 2 problems, re-doing the firmware is going to be costly, 2ndly - how to get it to turn back on?)
Ali Lown