1# External CEC adapter
2
3## USB - CEC Adapter from Pulse-Eight
4
5![Picture of USB - CEC Adapter](https://www.pulse-eight.com/generated-assets/products/0000237_555.jpeg)
6
7## Get the hardware
8
9*   [Order from Pulse-Eight](https://www.pulse-eight.com/p/104/usb-hdmi-cec-adapter#)
10*   [Pulse-Eight USB CEC adapter on Amazon](https://www.amazon.com/s/ref=nb_sb_ss_i_1_22?url=search-alias%3Daps&field-keywords=pulse+eight+usb+cec+adapter&sprefix=usb+cec+adapter+pulse+%2Caps%2C218&crid=UK4LY390M5H2)
11
12## Get the software {#software}
13
141.  Connect "TV" port on the adapter to your TV
152.  Connect USB mini port to you computer
163.  Install the cec-client
17
18    *   Linux
19
20    ```shell
21    sudo apt-get install cec-utils
22    ```
23
24    *   mac (using [MacPorts](https://guide.macports.org/#installing))
25
26    ```shell
27     sudo /opt/local/bin/port install libcec
28    ```
29
304.  run the client
31
32    ```shell
33    $ cec-client
34    No device type given. Using 'recording device'
35    CEC Parser created - libCEC version 4.0.2
36    no serial port given. trying autodetect:
37     path:     /dev/cu.usbmodemv1
38     com port: /dev/cu.usbmodemv1
39
40    opening a connection to the CEC adapter...
41    DEBUG:   [               1] Broadcast (F): osd name set to 'Broadcast'
42    DEBUG:   [               3] connection opened, clearing any previous input     and waiting for active transmissions to end before starting
43    DEBUG:   [              10] communication thread started
44    DEBUG:   [              70] turning controlled mode on
45    NOTICE:  [             255] connection opened
46    DEBUG:   [             255] processor thread started
47    DEBUG:   [             255] << Broadcast (F) -> TV (0): POLL
48    TRAFFIC: [             255] << f0
49    DEBUG:   [             255] setting the line timeout to 3
50    DEBUG:   [             403] >> POLL sent
51    DEBUG:   [             403] TV (0): device status changed into 'present'
52    ```
53
54## Add timestamps
55
56Use the `ts` command to add timestamps.
57
58```shell
59$ cec-client  | ts
60Nov 18 16:15:46 No device type given. Using 'recording device'
61Nov 18 16:15:46 CEC Parser created - libCEC version 4.0.4
62Nov 18 16:15:46 no serial port given. trying autodetect:
63Nov 18 16:15:46  path:     /sys/devices/pci0000:00/0000:00:14.0/usb2/2-9
64Nov 18 16:15:46  com port: /dev/ttyACM0
65Nov 18 16:15:46
66Nov 18 16:15:46 opening a connection to the CEC adapter...
67Nov 18 16:15:46 DEBUG:   [             386] Broadcast (F): osd name set to 'Broadcast'
68```
69
70### ts is part of the moreutils package
71
72```shell
73sudo apt-get install moreutils
74```
75
76## cheat sheets
77
78*   Show all connected devices
79
80    ```shell
81    $ echo scan | cec-client -s -d 1
82
83    ```
84
85## Available Commands
86
87[tx] \{bytes\}
88:   transfer bytes over the CEC line.
89
90[txn] \{bytes\}
91:   transfer bytes but don't wait for transmission ACK.
92
93[on] \{address\}
94:   power on the device with the given logical address.
95
96[standby] \{address\}
97:   put the device with the given address in standby mode.
98
99[la] \{logical address\}
100:   change the logical address of the CEC adapter.
101
102[p] \{device\} \{port\}
103:   change the HDMI port number of the CEC adapter.
104
105[pa] \{physical address\}
106:   change the physical address of the CEC adapter.
107
108[as]
109:   make the CEC adapter the active source.
110
111[is]
112:   mark the CEC adapter as inactive source.
113
114[osd] \{addr\} \{string\}
115:   set OSD message on the specified device.
116
117[ver] \{addr\}
118:   get the CEC version of the specified device.
119
120[ven] \{addr\}
121:   get the vendor ID of the specified device.
122
123[lang] \{addr\}
124:   get the menu language of the specified device.
125
126[pow] \{addr\}
127:   get the power status of the specified device.
128
129[name] \{addr\}
130:   get the OSD name of the specified device.
131
132[poll] \{addr\}
133:   poll the specified device.
134
135[lad]
136:   lists active devices on the bus
137
138[ad] \{addr\}
139:   checks whether the specified device is active.
140
141[at] \{type\}
142:   checks whether the specified device type is active.
143
144[sp] \{addr\}
145:   makes the specified physical address active.
146
147[spl] \{addr\}
148:   makes the specified logical address active.
149
150[volup]
151:   send a volume up command to the amp if present
152
153[voldown]
154:   send a volume down command to the amp if present
155
156[mute]
157:   send a mute/unmute command to the amp if present
158
159[self]
160:   show the list of addresses controlled by libCEC
161
162[scan]
163:   scan the CEC bus and display device info
164
165## Sending Remote Control Events
166
167You can send CEC remote events using the `tx` command above. The format is as
168follows:
169
170```
171tx <source id><destination id>:<command id>:<param value>
172```
173
174where all of the above parameters should be filled in with a single HEX digit
175(except `<command id>`, which requires 2 digits). Here, we want to send commands
176to the Android TV, so we will place its ID in `<destination id>`. The scan
177command above will give you the IDs for each device that the CEC adapter is
178aware of.
179
180In the examples below the DUT is a CEC player device with a logical address of
1814. Here are some useful commands to execute remote actions:
182
183*   Press home
184
185    ```
186    tx 04:44:09
187    ```
188
189*   Press select
190
191    ```
192    tx 04:44:00
193    ```
194
195*   Press d-pad up
196
197    ```
198    tx 04:44:01
199    ```
200
201*   Press d-pad down
202
203    ```
204    tx 04:44:02
205    ```
206
207*   Press d-pad left
208
209    ```
210    tx 04:44:03
211    ```
212
213*   Press d-pad right
214
215    ```
216    tx 04:44:04
217    ```
218
219You can check out [https://www.cec-o-matic.com/](https]://www.cec-o-matic.com/)
220for more info on formatting your request and a full list of commands and their
221respective parameters.
222