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.
我的目標是從配備Pulse-Eight USB加密狗的Android機箱上運行的標准(即非系統)應用程序發送HDMI CEC命令。
Following these instructions I successfully managed to compile libcec for Android and execute it as root on the box, with this command:
按照這些說明,我成功地設法為Android編譯libcec並在框中以root身份執行它,使用以下命令:
echo | cec-client -s /dev/ttyACM0
where /dev/ttyACM0 is the device file created by the system when plugging the dongle.
其中/ dev / ttyACM0是系統在插入加密狗時創建的設備文件。
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).
但是,此文件的權限會阻止該命令由非root用戶執行(因此無法從我的Android應用程序執行)。
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 SDK的USB Host API訪問USB加密狗(前提是用戶授予權限),甚至可以用UsbSerial庫封裝到USB串行控制器中。
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?
但我沒有看到任何方法在Android的USB Host API和libcec / cec-client提供的連接之間架起橋梁。你有什么想法或建議嗎?
1 个解决方案
#1
0
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).
到目前為止,我發現的最佳解決方案是使用USB Host API + UsbSerial庫在適配器的串行端口上使用純Java代碼(無嵌入式libCEC)讀/寫CEC數據包。
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.
我在libCEC上做了一些逆向工程,找出適合基本操作的命令,如開關電視和設置活動源。
And I finally came up with the following UsbCecConnection java class: https://gist.github.com/sdabet/ac4d7711d1a529806cb7b695530b1fac
我終於提出了以下UsbCecConnection java類:https://gist.github.com/sdabet/ac4d7711d1a529806cb7b695530b1fac