Raspberry Pi CEC Setup

Submitted by code_admin on Mon, 07/23/2018 - 15:03

This document describes how I set up CEC on a Raspbian instalisation

Packages to install:

  1. sudo apt-get install cmake
  2. sudo apt-get install checkinstall
  3. sudo apt-get install liblockdev1-dev
  4. sudo apt-get install libudev-dev  (Rasp3 needed apt-get update)
  5. sudo apt-get install swig
  6. sudo apt-get install g++-4.8 (Rasp3 didn't do this as g++ -v showed I already had 4.9)

The following I had problems with (fix-missing)

  1. ***???sudo apt-get install libxrandr-dev
  2. ***???sudo apt-get install python-dev

Download from git

  1. CECDIR=/home/pi/libcecworkarea
  2. echo ${CECDIR}
  3. mkdir ${CECDIR}
  4. cd ${CECDIR}

Building **Rasp3 Changed compiler to 4.9

  1. cd ${CECDIR}/libcec/src/platform
  2. mkdir build
  3. cd build
  4. cmake -DRPI_INCLUDE_DIR=/opt/vc/include -DRPI_LIB_DIR=/opt/vc/lib -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=1 -DCMAKE_CXX_COMPILER=g++-4.8 ..
  5. make
  6. sudo make install

Building something else

  1. cd ${CECDIR}/libcec
  2. mkdir build
  3. cd build
  4. export LIBRARY_PATH=/opt/vc/lib
  5. cmake -DRPI_INCLUDE_DIR=/opt/vc/include -DRPI_LIB_DIR=/opt/vc/lib -DCMAKE_CXX_COMPILER=g++-4.8 -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=1 ..
  6. make
  7. sudo -E bash -c 'make install'

Commands

  1. cec-client -l
Command Function
  1. echo h | cec-client -s -d 1
List Commands
  1. echo scan | cec-client -s -d 1
Scan Devices
  1. echo "standby 0" | cec-client -s
Turn TV Off
  1. echo "on 0" | cec-client -s
Turn TV On
  1. echo "NA" | cec-client -o "UnderTV" -s
Set OSD Text

http://www.cec-o-matic.com/

Sources

https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=117019

Getting commands working

I have made a script on the pi. (To backup here later) I will put all my commands in here

/home/pi/libcecworkarea/send.sh

RJM Article Type
Work Notes