Can I get the input data by directly reading the IOport of an USB keyboard - io

I am working on the Xen platform, Now I want to intercept the interrupt on HVM domain to read the raw data (scan code) of a keyboard .
One idea is that the hypervisor follows the path UHCI frame list-> TD related to keyboard device -> data buffer to get the raw data. However, when the interrupted is generated, the TD has been remove from the TD list. In this way, the hypervisor can not find the data buffer, and can not read the raw data.
Another idea is that directly read the IOport of keyboard.
I know it is possible to get the input of the PS2 keyboard by reading the IOport 0x60 and 0x64
But my current work device is USB keyboard.
Now my question is that whether it is possible to get the input raw data of USB keyboard
by directly reading the IOports.
If can, how to achieve that, please give me an simple example.
or is there other method to read the input raw data?

it seems that there is no exported port (e.g., USB-keyboard) for guest to read such information.
but I found that, the UHCI controller does not automatically remove the TD from the list even if the controller successfully complete the data transfer. The deletion operation is done in the uhci-irq function
In this way, we can read the data buffer before the function uhci-irq is invovled.

Related

data transfer from PL(fpga) to the PC via ethernet

I work with Zedboard and vivado v2017.3.
I have a custom IP in the PL part of zynq generating 32 bit values and stores them in one of the registers, say slv_reg0 (address : 0x43c00000).
In the PS part I read this register and I can print it in the gtkterm (simple one).
I now want to transmit these values over ethernet to to the PC.
Any suggestion on how to carry out this?
Thanks,
Upasana.
Xilinx supplies sample programs, one of these is an echo server. It should be quite simple to change it so that it serves the data you generate instead of just echo-ing the received message, and you can learn out of it how to use the lwip library in case you want a more suitable solution.

Datalogic Scanner-Write Data to File

I have a Datalogic PM8300-DK Scanner that is working fine so far. I choose the USB-KBD-Mode (USB INTERFACE SELECTION) and now everytime I scan a barcode, the data-representation of the barcode is writen on my computer (where the cradle is connected to).
But the problem is, the data is writen to where the cursor stands (where the focus is). For example, when the focus is in a text-editor, the scanner writes the data to the text-editor. When the focus is in the google-search-box of my browser, it writes the barcodes to the search-box.
I would prefer if the data would be writen directly to a file, and there would be no output to the screen directly. Is that possible, does anyone know a modus for that ?
Thanks, Andre
You need to use the serial or USB serial emulation (COM port) connection for that. You will also need to have some software to handle the data.

control Chip Select manually prior to data read in linux?

Hi I have a SPI touch device with 24 keys, each read will return 3 bytes, containing exact all 24 keys status. My hardware is a custom made beaglebone like device, spi0 is able to read its own write by connecting MISO to MOSI.
Everything (wiring, software) is working perfectly matching this guide: http://communistcode.co.uk/blog/blogPost.php?blogPostID=1
Now my touch device is CS active high device, but it requires to drive the chip select to low and back to high before actual read. I don't seems to have control with SPI cs value, I can only either control it within an actual read phase by specifying CS high or low. From my knowledge I have to use another GPIO to emulate the CS.
Question: any way to control cs freely? (i.e. set 0 or 1 by my code directly?)
I have solved this by pinmux the CS pin to a GPIO, and control it manually prior to actual communication.

HID input on linux for games

What is the best way to capture HID input on linux for games? I don't need anything special. Just mouse and keyboard. Right now I'm using Xlib. I have a separate input thread, which has its own connection to the X Server (Display instance) and it handles events for main render window. It is working just fine, but it is a bit limited. For example, I'm missing mouse raw input.
Have you tried opening and reading device files in /dev/input?

How do I read events from a HID device under Ubuntu Jaunty?

I have a Linux USB HID device (a Hama MCE), and I can read its events manually by reading cat /dev/input/event7 and cat /dev/input/event8. Whenever I press a key on the device, a few bytes become available for reading with one of the cat commands above. I have a default installation of Ubuntu Jaunty 64-bit desktop on the machine.
I think I can write a parser to interpret the bytes emitted by the device, or I'll use libhid if it's more convenient.
My questions are:
How do I prevent the text-mode virtual consoles from receiving some of the key presses on the device as normal keypresses? As of now, some device keys result an Enter, a BackSpace, a PageUp or numeric keypad numbers.
Similarly, how do I prevent the X server from receiving keyboard and mouse events from this device? I have several USB keyboards and mice connected to the computer. I want the X server receive events from all of them, except for this device.
How do I set up that whenever the device gets connected to the computer, the command /usr/local/bin/keydumper /dev/input/event7 /dev/input/event8 (or one command for each /dev/ path) would get run, with the proper /dev/ paths substituted in the command line?
Answering my own question based on answers from the Linux USB HID driver developers:
Question 1. and 2.: Do
ioctl(open("/dev/input/event7", O_RDONLY), EVIOCGRAB, 1);
As long as this filehandle is open, the events generated would go only
to this filehandle (not to other open()s of the same device or to the
system keyboard or mouse event pool). At most one process can hold a
successful EVIOCGRAB at a HID device at a time. Lirc can be configured
to do an EVIOCGRAB.
Question 3.: Configure udev to start the program once the device is connected.
I do not have enough points to comment sadly.
If you are looking for the definition of EVIOCGRAB try
#include <linux/input.h>
I think solution for all questions can be writing own filter device driver, or custom driver for your device. I know such a thing (filter device driver) is available on windows so something similar can be on Linux. In that filter device driver you could block all unwanted events from the target device that you wish to block, I don't really get 3 question so I don't know how to answer for that.

Resources