使用beaglebone黑色作为键盘设备。 [英] Using beaglebone black as a keyboard device.

查看:89
本文介绍了使用beaglebone黑色作为键盘设备。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我正在开发一个触摸屏键盘项目,其中BBB在屏幕上显示图像,从触摸屏接收触摸事件并具有将它们作为关键事件发送到主PC。所以BBB必须将它自己作为HID(键盘)设备呈现给PC。



我要做的是,编写一个在BeagleBone上运行的程序必须做以下事情:

- 从闪存中取出图像并将它们排列在屏幕上;

- 捕获触摸面板的输出并将其转换为正确的按键事件。

- 最后,它必须连接到USB设备控制器并发送这些关键事件到电脑。



硬件存在。 BBB具有USB On-The-Go,可用作USB设备控制器。它默认配置为USB以太网设备和大容量存储设备,这些功能确实有效。



到目前为止,我编写了一个脚本,将USB OTG设备配置为HID ,但现在呢?!

我真的不知道如何继续。我甚至不确定我的脚本是否配置了应有的一切。我看过的示例(这些脚本)有点过时。



脚本将数据(如VID和PID)填入configfs创建的文件中并创建一些根据我见过的例子,新的文件和目录。只有最后一个命令失败: ls:写入错误:设备或资源繁忙这是必须提到所需内核模块的位置,以便configfs加载它。但是模块(usb_f_hid)确实被加载了!所以我认为这个错误不是什么大问题?!



我原本希望在脚本运行后设备文件出现在/ dev中,所以我可以打开它并开始与USB设备控制器通信。但我无法找到这样的设备文件。它必须命名为usb0,但在脚本运行之前或之后不存在带有usb前缀的设备。



BeagleBone运行Debian Linux beaglebone 4.4.14-bone11#1 Thu Jul 14 08:51:47 EEST 2016 armv7l GNU / Linux



可以你指的是一些资源,解释了使用BBB作为HID或类似的东西的过程。



另外如何正确删除USB网络功能?



非常感谢。



我的尝试:



这是整个脚本。它被执行为 root

configfs已经安装,libcomposite模块在启动时加载,所以我不必在脚本。

Hi All

I'm currently working on a touchscreen keyboard project where the BBB displays images on a screen, receives the touch events form the touch panel and has to send them to the main PC as key events. So the BBB has to present it self as a HID (keyboard) device to the PC.

What I have to do is, write a program that runs on the BeagleBone that has to do the following things:
- Takes the images from its FLASH memory and arranges them on the screen;
- Captures the output of the touch panel and translates them into proper key events.
- And lastly, it has to connect to the USB Device controller and send those key events to the PC.

The hardware is present. The BBB has USB On-The-Go, which can be used as USB device controller. It's configured as USB Ethernet device and mass storage device by default and those functions do work.

So far I've written a script that configures the USB OTG device as HID, but now what?!
I really don't know how to continue. I'm not even sure that my script configures everything as it should. The examples (of such scripts) I looked from, were somewhat outdated.

The script fills in data like VID and PID into the files created by the configfs and creates some new files and directories as per the examples I've seen. Only the last command fails: ls: write error: Device or resource busy This is where the desired kernel module has to be mentioned so that configfs loads it. But the module (usb_f_hid) does get loaded! So I thought that error is not a big deal?!

I was expecting that a device file would appear in /dev after the script is ran, so I can open it and start communicating with the USB device controller. But I was not able to find such a device file. it has to be named "usb0" but no device filed with "usb" prefix are present before or after the script is ran.

The BeagleBone runs Debian Linux beaglebone 4.4.14-bone11 #1 Thu Jul 14 08:51:47 EEST 2016 armv7l GNU/Linux

Can you point me to some resources that explain the process of using BBB as HID or something of the sort.

Also how can I remove the USB network functionality properly?

Thanks a lot in advance.

What I have tried:

This is the entire script. It's executed as root.
The configfs is already mounted and the libcomposite module is loaded at startup so I don't have to do that in the script.

mkdir /sys/kernel/config/usb_gadget/usb_keyboard

mkdir /sys/kernel/config/usb_gadget/usb_keyboard/configs/c.1
mkdir /sys/kernel/config/usb_gadget/usb_keyboard/functions/hid.usb0

echo "1" > /sys/kernel/config/usb_gadget/usb_keyboard/functions/hid.usb0/protocol                 # set the HID protocol
echo "1" > /sys/kernel/config/usb_gadget/usb_keyboard/functions/hid.usb0/subclass                 # set the device subclass
echo "8" > /sys/kernel/config/usb_gadget/usb_keyboard/functions/hid.usb0/report_length            # REPORT_LENGTH = 8  set the byte length of HID reports
cat /home/debian/report_desc.bin > /sys/kernel/config/usb_gadget/usb_keyboard/functions/hid.usb0/report_desc

mkdir /sys/kernel/config/usb_gadget/usb_keyboard/strings/0x409
mkdir /sys/kernel/config/usb_gadget/usb_keyboard/configs/c.1/strings/0x409

echo "0x37f2" > /sys/kernel/config/usb_gadget/usb_keyboard/idVendor
echo "0x0001" > /sys/kernel/config/usb_gadget/usb_keyboard/idProduct
echo "0x03"   > /sys/kernel/config/usb_gadget/usb_keyboard/bDeviceClass

echo "71cb32dc0e49d782e9d1"       > /sys/kernel/config/usb_gadget/usb_keyboard/strings/0x409/serialnumber
echo "**** ***** Technology Ltd." > /sys/kernel/config/usb_gadget/usb_keyboard/strings/0x409/manufacturer
echo "*** Keyboard"               > /sys/kernel/config/usb_gadget/usb_keyboard/strings/0x409/product
echo "Custom USB Keyboard"        > /sys/kernel/config/usb_gadget/usb_keyboard/configs/c.1/strings/0x409/configuration
echo "120"                        > /sys/kernel/config/usb_gadget/usb_keyboard/configs/c.1/MaxPower

ln -s /sys/kernel/config/usb_gadget/usb_keyboard/functions/hid.usb0 /sys/kernel/config/usb_gadget/usb_keyboard/configs/c.1

ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/usb_keyboard/UDC #This fails with "ls: write error: Device or resource busy"





根据configfs HID设置的说明, / sys / class / udc / 的上下文不是它们应该的内容。可能会有一个要加载的模块列表。相反,有这个 musb-hdrc.0.auto simlink。



我也用谷歌搜索了一些关于此事的更多信息,但没有任何结果。



The contetnts of /sys/class/udc/ are not what they're supposed to be as per the instructions for configfs HID setup. There sould be a list of modules to be loaded. Instead, there is this "musb-hdrc.0.auto" simlink.

Also I googled my a** off trying to find some more info on the matter but nothing comes out.

推荐答案

我不知道你是否仍然需要这个,但我找到了你的问题的解决方案。



我刚开始项目我需要做同样的事情。



BBB设置USB客户端在 /opt/scripts/boot/am335x_evm.sh

在此之后,您似乎无法再禁用UDC以便安装你的小工具。



所以我在 / etc / default / bb-boot 并在 /opt/scripts/boot/am335x_evm.sh 中注释了2行以禁用ACM(USB Serial)。

Make确保你通过以太网连接并知道之前重启 :-)

之后,你应该可以用

来禁用UDC
I don't know if you still need this, but I found the solution to your problem.

I'm just starting a project where I need to do the same.

The BBB sets up the USB clients in /opt/scripts/boot/am335x_evm.sh
And it seems that after this, you can no longer disable the UDC in order to install your gadget.

So I disabled the Mass Storage Device and the USB Network in /etc/default/bb-boot and also commented 2 lines in /opt/scripts/boot/am335x_evm.sh to disable the ACM (USB Serial).
Make sure you connect via ethernet and know the IP before you reboot :-)
After that, you should be able to disable the UDC with
cd /sys/kernel/config/usb_gadget/g_multi
echo "" > UDC

并运行你的脚本。



希望这会有所帮助。

and run your script.

Hope this helps.


我还没有这样做过远。所以这可能没有帮助。



据我所知, / sys / class / udc / 由前面的脚本创建/填充命令(之前不存在或为空)。所以我会在访问该目录之前等待一段时间( sleep )(不再忙)。



你可以也可以手动完成最后一步。那就是执行

I have not done such so far. So this might not help.

As far as I understand, /sys/class/udc/ is created / filled by the preceding script commands (does not exist before or is empty). So I would wait some time (sleep) before accessing that directory (not busy anymore).

You can also do the last step manually. That is execute
ls /sys/class/udc/

选择一个设备名称,并使用<$ c将其写入UDC文件$ c> echo



如果目录中包含多个应该全部使用的文件,我也会期望'ls -1 dir'命令获取换行符分隔列表。

pick a device name, and write that to the UDC file using echo.

If the directory contains multiple files that should be all used I would also expect a 'ls -1 dir' command to get a newline separated list.


这篇关于使用beaglebone黑色作为键盘设备。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆