在Android应用中使用libCEC + USB软件狗 [英] Use libCEC + USB dongle in Android app

查看:169
本文介绍了在Android应用中使用libCEC + USB软件狗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是从运行在配备Pulse-Eight的USB加密狗的Android盒子上的标准(即非系统)应用程序发送HDMI CEC命令.

My goal is to send HDMI CEC commands from a standard (i.e non-system) app running on an Android box equipped with Pulse-Eight's USB dongle.

遵循这些说明成功地为Android编译了 libcec ,并使用以下命令在根目录下以root身份执行:/p>

Following these instructions I successfully managed to compile libcec for Android and execute it as root on the box, with this command:

echo <my-cec-command> | cec-client -s /dev/ttyACM0

其中/dev/ttyACM0是系统在插入加密狗时创建的设备文件.

where /dev/ttyACM0 is the device file created by the system when plugging the dongle.

但是,此文件的权限阻止该命令由非root用户执行(因此无法从我的Android应用程序执行).

However the permissions of this file prevent the command to be executed by a non-root user (therefore it cannot be executed from my Android app).

另一方面,该应用程序实际上可以通过 Android SDK的USB Host API (只要用户授予许可),甚至可以使用 UsbSerial 库.

On the other hand the app can actually access the USB dongle via the USB Host API of the Android SDK (provided the user grants the permission) and can even be wrapped into a USB serial controller with UsbSerial library.

但是我看不出有什么方法可以在Android的USB Host API提供的连接与libcec/cec-client之间建立桥梁.您有什么想法或建议吗?

But I don't see any way to make the bridge between the connection provided by Android's USB Host API and libcec/cec-client. Do you have any idea or suggestion?

推荐答案

到目前为止,我发现的最佳解决方案是使用 UsbSerial库使用纯Java代码(无嵌入式libCEC)在适配器的串行端口上读取/写入CEC数据包.

The best solution that I have found so far is to use USB Host API + UsbSerial library to read/write CEC packets on the adapter's serial port with pure Java code (no embedded libCEC).

我在 libCEC 上进行了一些逆向工程,以找到用于基本操作的适当命令就像打开电视关闭并设置活动源.

I did some retro-engineering on libCEC to find out the appropriate commands for basic operations like switching TV on & off and setting active source.

最后我想到了以下UsbCecConnection java类: https://gist.github .com/sdabet/ac4d7711d1a529806cb7b695530b1fac

And I finally came up with the following UsbCecConnection java class: https://gist.github.com/sdabet/ac4d7711d1a529806cb7b695530b1fac

这篇关于在Android应用中使用libCEC + USB软件狗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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