rpi: don't set the physical address to 1.0.0.0 when receiving VC_HDMI_UNPLUGGED....
[deb_libcec.git] / support / cec-test-device.sh
1 #!/bin/bash
2
3 ## Tests whether the USB-CEC adapter can be accessed correctly
4 ## Copyright (C) 2011-2013 Pulse-Eight Ltd.
5
6 check_lsusb()
7 {
8 echo -n " * searching USB device: "
9 adapters_found=`lsusb | grep 2548:1001 | wc -l`
10 if [ "x${adapters_found}" = "x0" ]; then
11 echo "NOT FOUND"
12 return 1
13 else
14 echo "ok"
15 return 0
16 fi
17 }
18
19 check_acm_module()
20 {
21 echo -n " * checking for CDC-ACM support: "
22 acm_found=`grep cdc_acm /proc/modules | wc -l`
23 if [ "x${acm_found}" = "x0" ]; then
24 echo "NOT LOADED"
25 return 1
26 else
27 echo "ok"
28 return 0
29 fi
30 }
31
32 check_acm_file()
33 {
34 echo -n " * checking for CDC-ACM node: "
35 acm_found=`ls /dev/ttyACM* | wc -l`
36 if [ "x${acm_found}" = "x0" ]; then
37 echo "NOT FOUND"
38 return 1
39 else
40 echo "ok"
41 return 0
42 fi
43 }
44
45 check_cec_client_dev()
46 {
47 echo -n " * checking cec-client: "
48 cec_client=`cec-client -l | grep 'Found devices' | awk '{print \$3}'`
49 if [ -z "${cec_client}" ]; then
50 echo "ERROR"
51 elif [ "x${cec_client}" = "xNONE" ]; then
52 echo "NO DEVICES FOUND"
53 else
54 echo "ok"
55 fi
56 }
57
58 check_poll_tv()
59 {
60 echo -n " * trying to poll the TV: "
61 cec_client=`echo 'poll 0' | cec-client -t p -p 1 -d 1 -s | tail -n1 | grep 'POLL'`
62 if [ -z "${cec_client}" ]; then
63 echo "ERROR"
64 elif [ "x${cec_client}" = "xPOLL message sent" ]; then
65 echo "ok"
66 else
67 echo "COULD NOT POLL THE TV"
68 fi
69 }
70
71 check_tv_vendor()
72 {
73 echo -n " * vendor id of the TV: "
74 cec_client=`echo 'ven 0' | cec-client -t p -p 1 -d 1 -s | tail -n1 | grep 'vendor' | awk '{print \$3}'`
75 if [ -z "${cec_client}" ]; then
76 echo "ERROR"
77 else
78 echo "${cec_client}"
79 fi
80 }
81
82 check_tv_power()
83 {
84 echo -n " * power status of the TV: "
85 cec_client=`echo 'pow 0' | cec-client -t p -p 1 -d 1 -s | tail -n1 | grep 'power' | awk '{print \$3}'`
86 if [ -z "${cec_client}" ]; then
87 echo "ERROR"
88 else
89 echo "${cec_client}"
90 fi
91 }
92
93 check_tv_lang()
94 {
95 echo -n " * language of the TV: "
96 cec_client=`echo 'lang 0' | cec-client -t p -p 1 -d 1 -s | tail -n1 | grep 'language' | awk '{print \$3}'`
97 if [ -z "${cec_client}" ]; then
98 echo "ERROR"
99 else
100 echo "${cec_client}"
101 fi
102 }
103
104 send_power_off()
105 {
106 echo -n " * powering off the TV: "
107 cec_client=`echo 'standby 0' | cec-client -t p -p 1 -d 1 -s | tail -n1`
108 echo "ok"
109 }
110
111 echo "Pulse-Eight USB-CEC Adapter tester v0.1"
112 echo ""
113
114 check_lsusb
115 check_acm_module
116 check_acm_file
117 check_cec_client_dev
118 check_poll_tv
119 check_tv_vendor
120 check_tv_power
121 check_tv_lang
122 send_power_off
123