3

I am trying to turn off my samsung tv through android app using HDMI CEC for android i used Amlogic MBOX

  1. Samsung Tv HDMI CEC already turned on.
  2. Amlogic MBOX HDMI CEC also turned on.

Code snippet how i execute command in android

fun sudoForResult(vararg strings: String): String? {
    Log.e("TAG", "sudoForResult: executing ")
    var res: String? = ""
    var outputStream: DataOutputStream? = null
    var response: InputStream? = null
    try {
        val su = Runtime.getRuntime().exec("su")
        outputStream = DataOutputStream(su.outputStream)
        response = su.inputStream
        for (s in strings) {
            outputStream.writeBytes("$s\n")
            outputStream.flush()
        }
        outputStream.writeBytes("exit\n")
        outputStream.flush()
        try {
            su.waitFor()
        } catch (e: InterruptedException) {
            e.printStackTrace()
        }
        res = readFully(response)
    } catch (e: IOException) {
        e.printStackTrace()
    } finally {
        outputStream?.close()
        response?.close()
    }
    Log.e("TAG", "sudoForResult: op = \n$res")
    return res
}

this command used for enable HDMI CEC in Amlogic MBOX and it's working.

sudoForResult(
    "settings put global hdmi_control_enabled 1",
    "settings put global hdmi_control_auto_wakeup_enabled 1",
    "settings put global hdmi_control_auto_device_off_enabled 1"
)

this both command tried but tv is not turn off.

sudoForResult("echo 0x40 0x36 > /sys/class/cec/cmd")
sudoForResult("echo 0xF0 0x36 > /sys/class/cec/cmd")

My Amlogic MBOX is already root device.

I am also tried most of answers and comment of the question related Hdmi-cec.

Any one can help regarding this issue. Any developer face same issue please ping me so we can help each other.

Some other command with log output if any one can found issue or solution from that

1.   sudoForResult(
            "ls -l /dev/cec",
            "ls -l /sys/class/cec/",
            "cat /sys/class/cec/physical_addr",
            "cat /sys/class/cec/device_type",
            "cat /sys/class/cec/vendor_id"
        )
    
Log output :
crw-rw-rw- 1 root root 217,   0 2023-07-07 09:05 /dev/cec 
total 0
-r--r--r-- 1 root root 4096 2023-07-07 09:14 arc_port
lrwxrwxrwx 1 root root    0 2023-07-07 09:14 cec -> ../../devices/aocec/cec
-r--r--r-- 1 root root 4096 2023-07-07 09:14 cec_version
--w------- 1 root root 4096 2023-07-07 09:19 cmd
-rw-rw-r-- 1 root root 4096 2023-07-07 09:14 dbg_en
-rw-rw-r-- 1 root root 4096 2023-07-07 09:14 device_type
-r--r--r-- 1 root root 4096 2023-07-07 09:14 dump_reg
-rw-rw-r-- 1 root root 4096 2023-07-07 09:14 fun_cfg
-rw-rw-r-- 1 root root 4096 2023-07-07 09:14 menu_language
-r--r--r-- 1 root root 4096 2023-07-07 09:14 osd_name
-rw-rw-r-- 1 root root 4096 2023-07-07 09:14 physical_addr
-r--r--r-- 1 root root 4096 2023-07-07 09:14 pin_status
-r--r--r-- 1 root root 4096 2023-07-07 09:14 port_num
-rw-rw-r-- 1 root root 4096 2023-07-07 09:14 port_seq
-r--r--r-- 1 root root 4096 2023-07-07 09:14 port_status
-rw-rw-r-- 1 root root 4096 2023-07-07 09:14 vendor_id
-r--r--r-- 1 root root 4096 2023-07-07 09:14 wake_up
1000
4
0


2.  sudoForResult("echo 0xF0 0x36 > /sys/class/cec/cmd && sleep 0.1 && cat /sys/class/cec/dump_reg")

Log output :

TX buffer:
0: 0
1: 0
2: 0
3: 0
4: 0
5: 0
6: 0
7: 0
8: 0
9: 0
10: 0
11: 0
12: 0
13: 0
14: 0
15: 0
CEC_TX_MSG_LENGTH: 0
CEC_TX_MSG_CMD: 0
CEC_TX_WRITE_BUF: 0
CEC_TX_CLEAR_BUF: 0
CEC_RX_MSG_CMD: 0
CEC_RX_CLEAR_BUF: 0
CEC_LOGICAL_ADDR0:14
CEC_LOGICAL_ADDR1: 0
CEC_LOGICAL_ADDR2: 0
CEC_LOGICAL_ADDR3: 0
CEC_LOGICAL_ADDR4: 0
CEC_CLOCK_DIV_H: 0
CEC_CLOCK_DIV_L: 0
RX buffer:
0: 0
1: 0
2: 0
3: 0
4: 0
5: 0
6: 0
7: 0
8: 0
9: 0
10: 0
11: 0
12: 0
13: 0
14: 0
15: 0
CEC_RX_MSG_LENGTH: 0
CEC_RX_MSG_STATUS: 0
CEC_RX_NUM_MSG: 0
CEC_TX_MSG_STATUS: 0
CEC_TX_NUM_MSG: 0


william xyz
  • 710
  • 5
  • 19

0 Answers0