I have a UPS which outputs data, like battery status, via serial port. This UPS is connected to a computer via USB, using a serial port to USB adapter. Communication with the UPS is possible with hyper terminal via a custom protocol.
Is it possible to write a HID power device driver for Windows using the USB output from the UPS? This driver should translate the custom protocol to the HID power device protocol.
Yes that can be done by writing a WDM or KMDF USB HID mini driver for your UPS. In the HID Mini driver, you must have to define the HID report descriptor with USB power device usages in the hid collections. In that driver you need to configure and enumerate your USB pipes which are used for virtual serial port communication right now. You have to send and receive data directly from and to USB pipes.
In this HID mini driver, once you define report descriptor with usage pages such as Battery system with necessary uses as hid reports and handle IOCTL calls from the top HID class driver, you can see your UPS attached as a HID UPS Battery in the Windows device manager. You can see the UPS as a battery with charging status, AC power status, battery remaining capacity % on the power options panel as well as in the system tray, like what we see in the laptop's battery status on the system tray.
Also you can send the existing UPS commands what you are sending now via hyper terminal would be then sent via HID API calls such as HidD_GetFeature, HidD_SetFeature, HidD_GetInputReport, HidD_SetOutputReport functions from a custom developed application as per your requirements.
Related
What I want to achieve is that I plug in a device, for example a mouse, but in general any device that outputs serial data via USB, and then either screen it in terminal, or store it in a file and, if possible, use python to do things with it.
As a concrete example, let's say I want access to the data from a trackpad plugged into a USB port on a macbook. When I run /dev/{tty,cu}.* in terminal, I get a bunch of devices, but none of them is the one I want. When I run ioreg -p IOUSB -l -b | grep -E "#|PortNum|USB Serial Number", I see that the device is plugged in, at a specific address (i.e. #14200000), as well as <class AppleUSBDevice, id 0x100002c38, registered, matched, active, busy 0 (10 ms), retain 14> and "PortNum" = 2.
Yes, the device is plugged in, no it does not show up in /dev/{tty,cu}.*. I don't want to have to write a device driver, I have heard that it is not the easiest thing to do. Are there any solutions for accessing low-level data from devices that don't show up in the /dev/ directory?
Devices showing up as /dev/tty... and /dev/cu... are devices implementing the asynchronous serial data communication protocol derived from RS-232. There used to be dedicated serial ports on computers. Today on a Mac, they are usually connected via USB.
Few USB devices implement the serial protocol. Instead they implement the HID protocol (keyboard, mouse etc.), USB mass storage protocol (external drives of all kind), USB ECM (for network adapters) or a custom protocol. Except for the ones with a custom protocol, macOS provides device drivers for all of them.
USB isn't a simple serial communication. Instead, devices configure several endpoints. Each endpoint uses a separate communication channel. Even USB CDC ACM for RS-232 like communication uses three endpoints. In addition, USB devices can pretend to be several devices at once. This is call composite device.
My understanding is that you want to observe and record USB communication. The main approaches are:
Use Wireshark. It is well known for observing and recording network traffic but it can do the same for USB. Unfortunately, with the ever tighter security on macOS, it isn't so easy to set up and probably doesn't work on Apple Silicon Macs anymore.
Use a dedicated USB protocol analyzer. They are very powerful and start at about USD 300.
I am trying to connect a Bluetooth Low Energy enabled MIDI hardware to wirelessly send data to a Windows PC and get it to detect as a MIDI device in Windows. Currently, the device is able to pair with my Windows 10 laptop and I am able to read the incoming data off of it.
The same hardware is configured and working fine as a wireless MIDI device on Mac and iOS devices(which natively supports MIDI over Bluetooth). I am trying to get this feature implemented on Windows(which doesn't support MIDI over Bluetooth, although it was promised in Windows 10).
The device, when is paired, is showing up in the 'Bluetooth devices' section in device manager, I am trying to make this device showing up as a MIDI device in 'Sound, video and game controllers' section.
Any help/resources somebody can provide to help me crack this problem is highly appreciated.
Following is my current thought process to implement this.
Pair the device and read the data off of it. (Already implemented)
Create a virtual MIDI port. (Don't know how to implement this, I am currently checking out rtpMIDI)
Send the MIDI data which was read from the BLE device to the virtual MIDI port. (Still don't know how to implement this)
Any suggestions/comments on the above thought process as I am absolutely new to Windows Driver Development.
When I connect several USB audio devices using the default drivers I usually end up with some kind of friendly device description like "nn- USB Audio codec" or something else, so I have currently no unique property which refers to a specific hardware the e.g. manufacturer ID. I would like to ensure that in case of re-enumerating or replugging the hardware to a different port that my software will automatically identify the changed windows audio device which maps to this hardware. I there a possibility to gather further windows audio device information which can be used to determine the physical hardware ?
Maybe a little clarification is needed:
I have two or more USB audio devices, not necessarily same product or manufacturer. The audio connections have different purposes, so I want to ensure that I my software uses constantly the same physical audio devices for different tasks. This sometimes fails when a re-enumeration occurs ( sometimes without changing the physical USB port connections, it's a windows thing...)
Ideally I would distinguish them by an individual serial number, which usually is only available with storage devices. But what I can retrieve is the "physical" USB topology when I'm looking at the device with a tool such as USBDeview from Nir Sofer. There I have a property like "Hub 3, Port1". If I could map this to a sound device I get from audio audio api like "nn- USB Audio codec" as seen in the sound control panel I would be perfectly happy.
Edit2:
May be this[1] post helps here, but I still have to figure out how to get a USB Port <-> Windwos Sounddevice mapping.
[1]: Can the physical USB port be identified programatically for a device in Windows? "
Do you know any way to make a software (virtual) HID device for Windows and/or Linux?
I want to use some sensors as HID but they don't have any HID so I thought I could have my own HID installed on the PC (the emulated onde) that converts some messages to HID and vice-versa.
Windows doesn't have a way; you will have to simulate mouse and keyboard events instead. Linux has uinput, which will allow you to inject input events directly into the kernel.
I need to create a application that will allow a Windows PC (XP/Vista) to emulate a thumbdrive. That is, when the PC is plugged into either another Windows system, or in this case, a piece of hardware that allows for USB thumbdrives to be plugged in, a folder on the computer looks like a giant thumbdrive. Any thoughts on where a guy would start to investigate this?
Update (more specific description):
I need to connect my PC to one of the newer multifuction devices that support scanning to a USB thumbdrive that is inserted into the front of the device. These units do not support WIA or TWAIN via the rear USB connector that you'd typically use for connectivity to a PC.
Most USB controllers in regular pc's dont have the possibility to function as an USB slave. So I'd start with investigating what kind of hardware you're going to use.
Another way to go: there are USB Link cables to link up 2 pc's over USB, maybe that's usable for you?
You cannot do this in an application. At the lowest level, the USB ports on your computer are controlled by an Host Controller Interface. This chip will manage up to 127 slave USB devices. You would need to seriously reprogram this chip before it implements the slave side of the USB protocol. Of course, at that point any USB hub in your PC will break down - those 8 USB ports you probably have are usually implemented by 2 smart USB hubs connecting to both USB1 and USB2 host controllers. Next, your USB keyboard and mouse will stop working.
Take an MCU with two Slave USBs. Write a simple frimware which makes one USB act as a Special Device Class and wait until PC on this USB provides mandatory data (including Device Class, of course) for the other USB. Write a PC program which connects to the Special Device (your MCU), uploads Mass Storage Device Class and redirects I/O to a dedicated partition. The other USB on the MCU will become an emulated Mass Storage Device.
Some of those code can be taken from Linux.