Programatically getting USB power draw of a device? - windows

In Windows, it is possible to view a Power tab for a USB hub in Device Manager that lists information such as whether the hub is self-powered and the total power available.
Is this information available programatically, either in Windows (perhaps WMI?) or Linux? I've looked in MSDN with little success so far.

Linux:
lsusb -v | grep MaxPower

I think WMI is going to be your best bet here. I'm not familar with exactly what you want, but I'd start with the Win32_VoltageProbe class.

Related

Logging USB devices on Windows

I am looking for a way to log when USB devices are plugged in and unplugged from a Windows 7 machine. I would like it to function similarly to the USBLogView program made by NirSoft, however we are not allowed to use any third party software on this machine, only first party Microsoft. Basically, if it could log the name of the usb device and the time it was plugged/unplugged that would be perfect.
Edit: sorry batch is not a requisite, to be honest I'm not too familiar with scripting on windows, I'm much more familiar with bash scripting.
Take a look in this solution:
https://superuser.com/questions/1096887/where-can-i-find-logs-on-recent-usb-insertion-in-the-event-viewer (scottschlaefli answer)
Link found on the above answer:
https://learn.microsoft.com/en-us/windows-hardware/drivers/usbcon/how-to-capture-a-usb-event-trace
This way you'll get a extensive log of all USB devices, than later you can get this log with a software, ex: c# software with 'EventLogQuery' object to get informations and use it.

Getting the battery level of a Bluetooth headset on Mac OSX

I would like to know if it is possible to get the battery level of a connected Bluetooth device (for example, a headset) on Mac OSX.
I'm looking for a command line or a library that would offer this possibility.
Thanks.
There is no easy way to get this information without special application.
There is an app especially designed for this only purpose - called AKKU.
It worked with Bose and Sony's headphones (checked)
https://github.com/jariz/Akku/
Remember to download version 0.1.0-beta.10.
The app works after restart.
Just follow this guide: http://osxdaily.com/2014/05/18/how-to-check-bluetooth-keyboard-battery-levels-from-the-command-line-on-mac-os-x/
Basically:
You just need to know the name of the device and then use ioreg, like this:
ioreg -c <devicename> |grep '"BatteryPercent" ='
Additionally, you could retrieve broader battery information with:
ioreg -c BeatsBluetoothHeadset |grep Battery
Next time, just google ... Since a similar question was already answered https://apple.stackexchange.com/questions/215256/check-the-battery-level-of-connected-bluetooth-headphones-from-the-command-line

Find out if USB device is connected. Ruby in Linux

I'm using Ruby 1.8 and linux (Ubuntu and SLAX), and i need to write a script in ruby which finds out if some specific usb device is connected to the system and on which USB port (0,1,2, etc). It was done before with the help of HAL (hal-find-by-capability --capability serial), but now i can't use this approach. I was trying to read /var/log/messages file trying to find the number of the usb port, but it appears that this number may not be written in some systems. Other thing i tried is to check /dev folder and search for ttyUSB# file, but it doesn't appear on some system when new device connects to USB.
I would appreciate any ideas how to do this.
lsusb is a linux command for displaying your usb hubs and listing the devices that are connected to them. In ruby I believe you'd be able to do something like this:
ls_results = `lsusb`
You should be able to parse that for whatever device you're looking for.
I'm sorry that I couldn't provide you an ruby sample. I had the same problem in C / C++ (QT). You can find my snippet here:
http://www.known-issues.net/cpp/how-to-detect-if-dev-is-a-usb-device.html
You have libusb ruby bindings which allow to control usb devices.

Windows: Is it *possible* to create a (virtual) video card driver?

i want to create a virtual monitor. The way this would work is that the virtual monitor would appear in a window on my desktop. As far as Windows knows it is just another monitor.
It occurs to me that it would, as a practical matter, have to be done as video card driver (i.e. rather than the video going out a wire to an LCD panel, it would go into another window on the desktop).
Does what i'm describing sound, technically, possible? (from a DDK point of view)
Note: i can't use a virtual pc, because no virtual PC has resolutions high enough for my needs. Also because it's not what i asked for.
Note: My reasons are unimportant, but i can make some up:
i want to test my application under high-dpi settings (288dpi)
i want to create a monitor that my iPad can VNC to
the family TV runs on the main monitor
the hijacker is monitoring the bus, and he'll blow it up if he suspects we're getting the passengers off
i'm trying to expand the limits of human knowledge and understanding, for the good of all man-kind
I'd say it's definitely possible, since that's what virtualization tools do for their guest utilities, but I wouldn't be able to tell you how in details. I'd suggest looking at the VirtualBox guest driver code as a starting point:
http://www.virtualbox.org/browser/trunk/src/VBox/Additions/WINNT/Graphics
(This is released under GPL as far as I'm aware.)
It's definitely possible, see for example the UltraVNC mirror driver. But I don't know of any virtual video driver that makes source code available.
I have been searching for something similar and I found a nice solution: spacedesk. You can download it here: http://spacedesk.ph/
In windows, it installs an extra monitor, which you can open in a browser or a viewer. Enjoy!
Don't know about Windows, but for X (Linux) there is Xvfb (X Virtual Frame Buffer), which is quite a useful thing.

Obtaining a Mac's System Profiler data from shell

How can I retrieve the information shown in the Mac's System Profiler app programatically? I'm actually interested in the USB section if that matters.
The OSX command line tool "ioreg" might give you want you want.
man ioreg
ioreg displays the I/O Kit registry. It shows the heirarchical registry as an inverted tree.
Also if you can/want to use Cocoa look at IOKit. IOKit is the OSX framework that talks to USB hardware.
Take a look at the system_profiler(8) command.

Resources