HDMI CEC interface

I got the soldering station so soldered wires to the CEC and CEC Ground pins of the HDMI cable. My breadboard setup turned out to contain some shorts (first breadboard use ever :-[) which made the USB port of my pc disable due to overcurrent.

Anyhow, when I now power up the circuit (without HDMI cable connected, flashed with the latest checkout of the SVN repository) it prints a single value 't0' or 'u0' via the serial port. Sending 'l' does not result in activity (no blinking RX/TX leds on the Arduino board). Also, when I connect the Sony TV using the modified HDMI cable nothing else happens than the single 't0' or 'u0' values.

Any suggestions what this means?

Are you sure you set the port speed to match what is defined in the code? You should see text reporting the logical address assignment when the CEC_Logical object instantiates. I would suggest adding some debug statements in setup to validate your pc is correctly communicating via serial.

It's been a while, but I've seen several successful CEC transactions. Indeed, I used the wrong baud rate settings.

My Sony TV seems to support only a very small subset of CEC (power down, image on). When I switch on the TV, it first broadcasts a bunch of vendor-specific commands (which I cannot decode as they are undocumented). Then, it stays quiet. Probably it will talk if I reply in vendor-specific language after receiving the broadcast messages....

BTW: did anybody make progress on the protocol handling?

I'm 90% done with code for bridging the CEC packets over serial. I'm planning to write libraries in c, python, and c# for the PC side, I think this will make it easier to experiment.

I got a PS3 Slim, which supports CEC, and have obvserved communications for setting the device name string in the input menu on the tv, and remote control passthrough for navigating PS3 menus with the TV remote.

Hopefully I'll have the above code available to share in a couple weeks.

Hi,

about the higher level functionality, my CEC library have evolved a bit and I made a public available repository for it.
git://people.freedesktop.org/~deathsimple/cec

What's done:
Dumper functionality to get CEC packets in a human readable form
Reading Physical Address from EDID record
Logical Address allocation algorithm
Functionality to react correctly on standard packets (Report Physical Address, Report Power Status...)
Commandline interface for the library
ALSA plugin to control the volume of my AV receiver directly from vdr/GNOME

I'm still having trouble getting my TV to relay remote control commands, but this seems just a matter of time.

Regards,
Christian.

Not a lot of activity in this thread lately...

I created an svn branch with some modifications to Phil's code, and a python client (currently read only). Work in progress.

svn checkout http://cec-arduino.googlecode.com/svn/branches/anc cec-arduino-anc

Note: I'm using EDID to set the physical address. If you aren't tied into the EDID wires, you will want to manually specify the physical address in the CEC_Arduino.pde file.

Here is an example of the python client output after turning on my samsung lcd with ps3 slim connected:

CECPacket Source: 8, Destination: f CEC_INFO_PHYS_ADDR 
New source:  1.0.0.0 
CECPacket Source: 8, Destination: f CEC_VENDOR_ID
Vendor ID: 80046
CECPacket Source: 0, Destination: f CEC_ROUTING_CHANGED
Previous Source: 0.0.0.0  New Source: 1.0.0.0 
CECPacket Source: 0, Destination: f CEC_ROUTING_REQ_ACTIVE
CECPacket Source: 0, Destination: f CEC_ROUTING_CHANGED
Previous Source: 0.0.0.0  New Source: 1.0.0.0 
CECPacket Source: 8, Destination: f CEC_ROUTING_ACTIVE
Active Source:  1.0.0.0 
CECPacket Source: 0, Destination: f CEC_INFO_LANG
Lang: eng
CECPacket Source: 8, Destination: 0 CEC_MENU_STATUS
04 08 00 8e 00 
CECPacket Source: 0, Destination: 8 CEC_MENU_REQ
Menu Request: 2
CECPacket Source: 0, Destination: 8 CEC_DECK_REQ_STATUS
CECPacket Source: 8, Destination: 0 CEC_MENU_STATUS
04 08 00 8e 00 
CECPacket Source: 8, Destination: 0 CEC_FEATURE_ABORT
Abort reason: 1
CECPacket Source: 0, Destination: 8 Ping
CECPacket Source: 0, Destination: 8 CEC_VENDOR_ID_REQ
CECPacket Source: 8, Destination: f CEC_VENDOR_ID
Vendor ID: 80046
CECPacket Source: 0, Destination: 8 CEC_OSD_REQ_OSD
CECPacket Source: 8, Destination: 0 CEC_OSD_SET_OSD
OSD Name: PlayStation 3
CECPacket Source: 0, Destination: 8 CEC_VENDOR_COMMAND_ID
Vendor command:  00 00 f0 23 
CECPacket Source: 8, Destination: 0 CEC_FEATURE_ABORT
Abort reason: 4
CECPacket Source: 0, Destination: 8 CEC_VENDOR_CEC_VERSION_REQ 
CECPacket Source: 8, Destination: 0 CEC_VENDOR_CEC_VERSION
CEC Version: 1.3a
CECPacket Source: 0, Destination: f CEC_ROUTING_REQ_ACTIVE
CECPacket Source: 0, Destination: 8 CEC_MENU_REQ
Menu Request: 2
CECPacket Source: 8, Destination: f CEC_ROUTING_ACTIVE
Active Source:  1.0.0.0 
CECPacket Source: 0, Destination: 8 CEC_MENU_REQ
Menu Request: 2
CECPacket Source: 8, Destination: 0 CEC_MENU_STATUS
04 08 00 8e 00 
CECPacket Source: 8, Destination: 0 CEC_MENU_STATUS
04 08 00 8e 00 
CECPacket Source: 8, Destination: 0 CEC_MENU_STATUS
04 08 00 8e 00

Well, after think about trying to do this for a while and then stumbling upon this amazing thread, I have finally began to purchase all of the components to build.

My goal is to control my Samsung LN40A530P1F from my custom built HTPC.

My Arduino finally came in the mail today, just missing HDMI connector and few little resistors here and there. Then it's soldering time!

Any new recommendations or changes made since the schematic Mike T attached?

/me

The Eagle Cad files I attached use Mike's design, along with some wiring for the EDID i2c pins, hotplug and 5v. If you are going to etch a board and use the same hdmi connector, I can say it worked out well for me. The additional wiring is optional, and not really needed beyond experimenting.

Ah, finally some activity in the topic :). I spent several nights trying to make the Arduino appear as a HDMI control device for my Sony Bravia TV, with no success yet. I guess the Sony uses some kind of authentication based on vendor specific commands. A log of a working Bravia Sync connection would be appreciated..

I found and fixed a bug that caused the arduino to never recognize that a message was addressed to it, thus never acking (including pings). This was causing my TV to not consistently recognize my device.

If you are using the svn trunk code, make sure to "svn up", or at least grab the updated CEC.cpp file.

mervel: I think this will solve your issue, let me know!

Your fix solves a part of my problem. After updating to the newest version of the SVN trunk, I receive more messages from the TV. It now also starts to request the physical address, which should be replied with a "report physical address" message. I'm still trying to wrestle through the code (never worked in C++ before...) to find out where to add the message protocal handling nicely...

mervel: if you are connecting from a linux machine, try my anc branch that is in svn, the python client now handles all the requests from my Samsung LCD when it scans for new devices from the input menu, and also handles enough to successfully switch input when selecting it as an Anynet+ device. The code is a little messy still, and there is more to add, this is the most complex task I've undertaken in python. I plan a c# client library too, for Windows and mono.

G'day all.

I've just started playing with phil123's code - hooked everything up to my Samsung TV this afternoon and was pleasantly surprised to see the messages appearing on my first attempt!

I'm intending to use my arduino to relay commands from the TV remote to my media PC (and perhaps switch to it automatically when the TV turns on). Down the track I might add some TV controls and live TV pause/record functionality.

Here's a picture of my setup:

It's connected between a Samsung LA32B550K1FXXY and an Acer Aspire Revo AR1600. So far my soldering looks good: I'm seeing a bunch of traffic on the bus and have managed to wake the TV up from standby. Thanks heaps to everyone who's contributed so far - it makes it easier for the rest of us!

For those that are interested, my Samsung's init sequence looks something like this:

<Set Menu Language> received at 2101152: 0 -> 15    32 65 6E 67 
<Polling Message> received at 2101793: 0 -> 4    
<Give Device Vendor ID> received at 2103857: 0 -> 4    8C 
<Give OSD Name> received at 2105367: 0 -> 4    46 
<Vendor Command With ID> received at 2105707: 0 -> 4    A0 00 00 F0 23 
<Get CEC Version> received at 2107117: 0 -> 4    9F 
<Give Physical Address> received at 2108627: 0 -> 4    83 
<Active Source> received at 2110193: 0 -> 15    82 00 00

I've implemented a few responses and a default for other requests. Can anyone guess what the (A0 00 00 F0 23) might be?

All done: CEC_Player.zip

I've added the following to the SVN trunk:

  • CEC_Debug.cpp/h - Parses all the CEC commands listed in the HDMI 1.3a spec and (almost) all of their parameters into human readable format. Good for debugging but takes up a large chunk of the flash memory. I can post some example output (communication between a Samsung TV and PVR) if anyone is interested. I haven't been able to test it on the scheduling commands so no guarantees there.
  • CEC_Player.cpp/h - Identifies itself to the TV as a Player Device with a (always active) menu and deck control. Forwards all menu and playback commands to the HTPC via the serial port. No input required from HTPC.
  • CEC_OpCodes.h - #defines for all the OpCodes, used by the two classes above.
  • xbmc-cec.cpp - An XBMC EventClient written in C++ under linux to send the remote control commands output by CEC_Player to XBMC.

Thanks again to Phil and Andrew for their code. Feel free to incorporate my code into the repository (I can do it if you give me svn access).

Hey Biffidus,

Great work, that must have taken quite some time! Your board looks great, too -- did you mount the components on both sides? It looks a little light.

I'd like to see some examples of the output of the debug. I'm currently waiting for my arduino to arrive and getting started on the specifics of what I'd like to program would be nice.

Thanks! The board is single sided - Mike T's circuit from page 1 crammed onto the smallest shield I could manage (more pics).

Here's an example of my CEC_Player talking to a Samsung TV. I'm printing out a debug and raw version of each packet.

ADDR  8
DEBUG ON
RAW ON
RECV  0 ->  8       <Give Device Power Status> 
RECV  0 ->  8       8F 
SEND    ->  0       <Report Power Status> On
SEND    ->  0       90 00 
RECV  0 ->  8       <Give Physical Address> 
RECV  0 ->  8       83 
SEND    -> 15       <Report Physical Address> 1.0.0.0 Playback Device
SEND    -> 15       84 10 00 04 
RECV  0 -> 15       <Set Stream Path> 1.0.0.0
RECV  0 -> 15       86 10 00 
SEND    -> 15       <Active Source> 1.0.0.0
SEND    -> 15       82 10 00 
RECV  0 ->  8       <Menu Request> Query
RECV  0 ->  8       8D 02 
SEND    ->  0       <Menu Status> Activated
SEND    ->  0       8E 00 
RECV  0 ->  8       <Give Deck Status> On
RECV  0 ->  8       1A 01 
SEND    ->  0       <Deck Status> Stop
SEND    ->  0       1B 1A

At this point the TV will send most of the remote control button presses through to the arduino. My htpc ignores everything except the "CTRL XX" lines.

RECV  0 ->  8       <User Control Pressed> Up 
RECV  0 ->  8       44 01 
CTRL  01
RECV  0 ->  8       <User Control Released> 
RECV  0 ->  8       45 
RECV  0 ->  8       <User Control Pressed> Right 
RECV  0 ->  8       44 04 
CTRL  04
RECV  0 ->  8       <User Control Released> 
RECV  0 ->  8       45 
RECV  0 ->  8       <User Control Pressed> Left 
RECV  0 ->  8       44 03 
CTRL  03
RECV  0 ->  8       <User Control Pressed> Left 
RECV  0 ->  8       44 03 
CTRL  03
RECV  0 ->  8       <User Control Released> 
RECV  0 ->  8       45 
RECV  0 ->  8       <User Control Pressed> Down 
RECV  0 ->  8       44 02 
CTRL  02
RECV  0 ->  8       <User Control Pressed> Down 
RECV  0 ->  8       44 02 
CTRL  02
RECV  0 ->  8       <User Control Released> 
RECV  0 ->  8       45 
RECV  0 ->  8       <Vendor Remote Button Down> 91 
RECV  0 ->  8       8A 91 
CTRL  91
RECV  0 ->  8       <Vendor Remote Button Down> 91 
RECV  0 ->  8       8A 91 
CTRL  91

The rest of the output shows the TV talking to the PVR with my arduino (running in promiscuous mode) happily replying to everyone's messages.

Thanks very much, your setup looks great!

I am still waiting for my arduino but have mapped out the handshake between my Onkyo receiver and Toshiba TV. The Onkyo displays a nice menu of items on the TV's HDMI input, so I'll just copy the vendor specific commands. I'm planning to switch a power outlet on and off as I click through things like games consoles.

Does anyone have any idea about emulating/repeating the EDID info from my TV? I know some of the posters here had hooked up EDID paths and was wondering if you'd done anything with them. My HTPC has an issue whereby the TV is never given a signal if the HTPC is started when the TV is turned off. I figure if I can send the EDID info of the TV, a la the DVI Detective, I'd avoid the issue, and this seems the perfect device to do the job.

Biffidus: great work. I haven't been able to test your code but gave a quick look through the files.

Some small remark: in CEC_Debug.cpp at line 386, it states:

case 0x1010:

where the other case statements are bit patterns (eg, case 0b1011)
Perhaps this is a small bug?