IOKit get current power source - objective-c

How do I get the current power source on a Mac, using IOKit?
I want to see if the Mac is running via the built-in battery or via a power adapter.

The functions in IOPowerSources.h (specifically, IOPSGetProvidingPowerSourceType()) will give you the info you're looking for.

Related

Obtaining GPS coordinates using internal GPS receiver and VBA

We currently have HP XP2 tablets with a built in internal GPS receiver. What we'd like to achieve is obtain GPS Lat/Long coordinates using an MS Access database and VBA code.
Would it be possible for anyone to please provide the VBA code required to access the coordinates to make them available to add to our Access database?
Please see details below regarding GPS receiver model and drivers:
Driver = u-blox GNSS Location Sensor Driver.
Description = The u-blox GNSS Location Sensor driver is required to enable the u-blox USB GPS standalone device.
Standalone GPS name = HP Graff GNSS Module
If i understand correctly you want to extract with VBA the GPS coordinates from your internal GPS receiver and add them to a an Access database.
If that is the case, then unfortunately VBA is a language only used by MS office application, therefore if your built in GSP receiver is not an office application i'm quite sure you wont be able to extract the data using VBA (it is possible in a few cases but it requires a very advance knowledge of VBA)
The easiest way for you would be to extract manually the data and save them in a specific location of your files and then ask the VBA macro to open the file and save the data in your database.
If you really want to extract the data without any human interaction, I suggest you use python or another programming language or check on the IFTTT website if you can create an applet.
I hope this answer will help you!
If you need a more detailed question, you'll need to send more specification about your data, the built in GPS app...

How can I get system uptime programmatically on the chrome-os platform?

System uptime is available in chrome without enabling the developer mode via the crosh window and the command top. I'd like to be able to access this programmatically within my chrome app. I'm not seeing it jump out at me in the chrome apis here.
Uptime usually includes both the load average and the time since the last boot-up. I'm mostly interested in the time since the last boot-up.
How can I get system uptime programmatically on the chrome-os platform - without enabling developer mode?
I do not have a chrome development environment set up at the moment, or I'd try. But chrome.system.cpu.getInfo() looks like it will give you what you want. Note that the processors array gives cumulative time (total) that may be equivalent to time since last boot.
See https://developer.chrome.com/apps/system_cpu.

Creating a computer ID using Mono

I develop a few tools in C# using the .Net framework and I am considering the move to Mono. Based on the compatibility analyzer tool (MOMA), the only compatibility issue is the licensing code:
I use Window's serial number and a few other things to generate a computer ID which I then use to generate and manage my licenses.
Obviously, Windows will not be available on Linux or Mac, so I need another way to generate a computer ID.
What can I use in mono to create a reasonably reliable computer ID?
Use a MAC Address:
Get MAC Address in linux using mono
That should be unique to a given network interface, which would uniquely identify the machine.
Also, see this thread discussing the pitfalls and issues related to DRM in mono.
You can use a combination of either CPUID and a hard drive serial number.
As for your code, there is not going to be an elegant way to do this with a one-liner. You will have to check which platform you are running on via Environment.OSVersion. And then based on that, branch your code to do system-specific access. For example, to get CPUID/hdd serial number, use a WMI query; or parse the output of hdparm -I /dev/hda and go from there.
You could use a portion of how Microsoft checked hardware for Windows XP activation. They checked 10 items
Display Adapter
SCSI Adapter
IDE Adapter (effectively the motherboard)
Network Adapter (NIC) and its MAC Address
RAM Amount Range (i.e., 0-64mb, 64-128mb, etc.)
Processor Type
Processor Serial Number
Hard Drive Device
Hard Drive Volume Serial Number (VSN)
CD-ROM / CD-RW / DVD-ROM
When XP was (re)installed/activated it'd contact their servers and if 7 or more of the above items were unchanged it would activate without the need to speak with anyone.
I, personally, would recommend against using the MAC address. As you mentioned, it can be easily changed. Additionally, most machines have two or more network cards now (wired and wireless). It gets worse with virtualization as the MAC can be changed even more easily than the physical one can (do you license differently for virtual environments?)
Another option, instead of checking all 10 hardware components, is to use the UUID of the root file system. The downside of this, is that if the drive ever has issues, the license needs to be reacquired.
sudo blkid
/dev/sda1: TYPE="ntfs" UUID="72C0DE8EC0DE57C5" LABEL="windows"
/dev/sda2: UUID="30fcb748-ad1e-4228-af2f-951e8e7b56df" SEC_TYPE="ext2" TYPE="ext3"
/dev/sda5: TYPE="swap" UUID="8c4e69f8-5074-42c0-8134-0b2429c4c02c"
/dev/sdb1: SEC_TYPE="msdos" UUID="4848-E35A" TYPE="vfat"

tester for HID devices

I have built my own USB HID device. I want to check, if it is working correctly.
I want to check the descriptors sent by the device, display input reports and send output reports. What tools are capable of this task and runs on Windows 7 64 bit?
On a day-to-day basis I use USBlyzer. It works well on Windows 7 64-bit.
As far as free tools go, the Windows DDK includes (in C:\winddk\7600.16385.1\tools\avstream\amd64) a tool called UVCview.exe ("USB device viewer") that shows at least some descriptor information.
You might also try Wireshark, but I admit, I only use it for network and can't speak to the quality of its USB capture.
(even though it's an old post) - here is a convenient and free solution:
Our Docklight Scripting software can test custom USB HID devices in the free (evaluation) download already, no time limit. Tested both on Windows 7 and Windows 10. You can access your device via the chosen VID and PID, display input report data and send output reports, even with variable output report ids.

How do you create a multiboot SCCM task sequence USB Stick?

I need to dual boot 2 different task sequences (Win7 images) for different Pc types which require different drivers, we have 2 images one for staff and student which can be added to a particular task sequence.
I need to create a portable solution for cloning without the network using 2 different SCCM (System Center Configuration Manager) task sequences. At the moment I go through the usual steps of creating a boot media via the Configuration manager, but there seems to be know way to create a script that changes the task media on the fly so you can select which OS image.
I was looking at a possible solution using YUMI (a Usb boot tool) but each bootable image requires an ISO. The task sequence image is around 8GIG.
We use SCCM 2007. (Still awaiting for a budget to upgrade to 2012 :) )
It sounds like you want to boot two different .WIM images.
Out of the box, I haven't found any tool from MS that will allow this. I have gotten around this discrepancy by renaming the .WIM I want to use to BOOT.WIM in the \SOURCES directory.
That is the name of the .WIM that gets used by all the default settings. You have to rename the file before you attempt to boot from the USB device, but it doesn't take long and could be scripted without much effort.
Theoretically, it should be possible to configure the BCD on the USB device (\EFI\MICROSOFT\BOOT\BCD or BOOT\BCD, depending on how the computer is configured to boot) so that you could choose which .WIM to use at boot time without the need to do any messy renaming. I haven't gotten this to work yet (mostly due to lack of time/urgency), but I did write down what I had done so far. I found some useful information about booting to .WIM's from windowsitpro.com.