How to listen/snoop on all HDMI-CEC traffic?

2.6k Views Asked by At

I'd like to see all traffic between connected HDMI devices using a Raspberry PI 4. I need to do this to debug incorrect CEC behaviour. (To sus out what's switching active sources unexpectedly, and where are remote control passthrough messages disappearing.)

I tried launching cec-client -m in monitor mode, expecting it would not talk on the CEC line and not influence normal behaviour, although this behaviour is poorly specified. It outputs DEBUG: [ 290] logical address changed to Free use (e) which I cannot reconcile with the assumption that cec-client doesn't generate traffic in this mode. Why does it need a logical address if it's only listening?

I've also observed that my Sony Bravia TV periodically says >> 0e:83 (give physical address), which is strange considering no device should be seen with logical address E.

It could be, that the TV is trying to discover new devices, hence it pings addresses that are seemingly empty. This would also explain why the cec-adapter assumes logical adress E on the PI: to filter messages. cec-client only outputs messages addressed to E and F. I see no traffic between my TV (0) and amplifier (5). To test this, I tried changing the logical address to something else la 13, but i get

la 13
NOTICE:  [           10167]     setting primary logical address to d
Segmentation fault

This command doesn't work in monitoring mode. In standard mode it doesn't crash the client, but it's still unable to change the device type from the default Recording 1 to Playback 1 (la 4 as an example). I verify this by scan.

I would like to silently listen in on all messages passed thruogh the CEC line. This question is similar to an unaswered one asked 3 years ago: spy with LibCEC on Raspberry pi

1

There are 1 best solutions below

0
On

I just stumbled upon this trying to accomplish a similar thing. I suspect the reason for this behavior is due to the underlying Broadcom driver filtering out "irrelevant" messages before passing them to higher levels. Unfortunately, this means a true passive CEC logger built on RPI is probably out of reach for most.

However, I found a project that tries to accomplish something along these lines using the Broadcom APIs directly: https://github.com/glywood/cec-fix. With some tweaking, it may be possible to create a program that listens specifically for TV addressed messages and logs the ones you want (e.g. the ones being sent from the TV with remote control passthrough codes).