Hello,
I've received iMX233 MAxi from few days. I've connected an USB barcode reader and it appears like an USB keyboard but I can't understand what device to read.
I'm writing my application in C.
And this my dmesg output
mmcblk0: p1 p2
usb 1-1: new high speed USB device using fsl-ehci and address 2
usb 1-1: New USB device found, idVendor=0424, idProduct=9512
usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 3 ports detected
usb 1-1.1: new high speed USB device using fsl-ehci and address 3
usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
smsc95xx v1.0.4
smsc95xx 1-1.1:1.0: usb0: register 'smsc95xx' at usb-fsl-ehci-1.1, smsc95xx USB 2.0 Ethernet, 2a:c5:f2:8e:04:9f
EXT4-fs (mmcblk0p2): recovery complete
EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
VFS: Mounted root (ext2 filesystem) on device 179:2.
devtmpfs: mounted
Freeing init memory: 128K
EXT4-fs (mmcblk0p2): re-mounted. Opts: barrier=1,data=ordered
<30>systemd-udevd[63]: starting version 186
EXT4-fs (mmcblk0p2): re-mounted. Opts: barrier=1,data=ordered
usb0: link up, 100Mbps, full-duplex, lpa 0xCDE1
usb0: no IPv6 routers present
usb 1-1.2: new low speed USB device using fsl-ehci and address 4
usb 1-1.2: New USB device found, idVendor=04b4, idProduct=0100
usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1.2: Product: Cypress USB Keyboard
usb 1-1.2: Manufacturer: Cypress
input: Cypress Cypress USB Keyboard as /class/input/input0
generic-usb 0003:04B4:0100.0001: input: USB HID v1.00 Keyboard [Cypress Cypress USB Keyboard] on usb-fsl-ehci-1.2/input0
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
usb 1-1.2: USB disconnect, address 4
usb 1-1.2: new low speed USB device using fsl-ehci and address 5
usb 1-1.2: New USB device found, idVendor=04b4, idProduct=0100
usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1.2: Product: Cypress USB Keyboard
usb 1-1.2: Manufacturer: Cypress
input: Cypress Cypress USB Keyboard as /class/input/input1
generic-usb 0003:04B4:0100.0002: input: USB HID v1.00 Keyboard [Cypress Cypress USB Keyboard] on usb-fsl-ehci-1.2/input0
usb 1-1.2: USB disconnect, address 5
usb 1-1.3: new low speed USB device using fsl-ehci and address 6
usb 1-1.3: New USB device found, idVendor=04b4, idProduct=0100
usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1.3: Product: Cypress USB Keyboard
usb 1-1.3: Manufacturer: Cypress
input: Cypress Cypress USB Keyboard as /class/input/input2
generic-usb 0003:04B4:0100.0003: input: USB HID v1.00 Keyboard [Cypress Cypress USB Keyboard] on usb-fsl-ehci-1.3/input0
In this list the reader is the device 006
Bus 001 Device 006: ID 04b4:0100 Cypress Semiconductor Corp. Cino FuzzyScan F760-B
It's my first time using Arch linux too.
Thank you for your help.
Raff
Try
ls /dev/input
on your maxi board to see all device nodes there.
Keyboard devices should be called event0, event1 etc.
In your app you can then open the device and read raw input from it:
struct input_event ev[64];
int fd, rd, value, size = sizeof (struct input_event);
fd = open ("/dev/input/event0", O_RDONLY);
rd = read (fd, ev, size * 64);
See description of input_event structure from linux/input.h to figure out how to process only keyboard press events.
Other option might be much easier, if your application requirements allow it:
When you scan RFID card, USB reader outputs card code as simple stream of characters.
Login to your maxi board and then scan id card. Card code will appear on terminal output just as if you typed it yourself.
There you have your solution: once your C application is started all it has to do is process anything that comes from stdin and that will be your card code. This will only work, however, if you will start your app from terminal and there will be no other input to it from stdin except what reader sends.
There might be other ways to capture stdin from keyboard in linux in general (i.e. in bash scripts etc.) and I suggest you try that first and if it works use it to develop your app, and then later just add C code that reads directly from /dev/input/eventxxx if you really need it.
you can also try one of the utilities from input-utils package, i.e. input-event or input-send etc...