cec

package module
v0.0.0-...-921b101 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2024 License: MIT Imports: 9 Imported by: 2

README

cec.go - a golang binding for libcec

cec.go is a Go interface to LibCEC.

Install

Make sure you have libcec and it's header files installed (apt-get install libcec-dev)

go get github.com/chbmuc/cec

Getting Started

A simple example to turn on the TV:

package main

import (
	"fmt"
	"github.com/chbmuc/cec"
)

func main() {
	c, err := cec.Open("", "cec.go")
	if err != nil {
		fmt.Println(err)
	}
	c.PowerOn(0)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCommand

func CreateCommand(command string) C.cec_command

func CreateCommandString

func CreateCommandString(cmd *C.cec_command) string

func GetKeyCodeByName

func GetKeyCodeByName(name string) int

GetKeyCodeByName - get the keycode by its name

func GetLogicalAddressByName

func GetLogicalAddressByName(name string) int

GetLogicalAddressByName - get logical address by its name

func GetLogicalNameByAddress

func GetLogicalNameByAddress(addr int) string

GetLogicalNameByAddress - get logical name by address

func GetVendorByID

func GetVendorByID(id uint64) string

GetVendorByID - Get vendor by ID

Types

type Command

type Command struct {
	Initiator       uint32     /**< the logical address of the initiator of this message */
	Destination     uint32     /**< the logical address of the destination of this message */
	Ack             int8       /**< 1 when the ACK bit is set, 0 otherwise */
	Eom             int8       /**< 1 when the EOM bit is set, 0 otherwise */
	Opcode          int        /**< the opcode of this message */
	Parameters      DataPacket /**< the parameters attached to this message */
	OpcodeSet       int8       /**< 1 when an opcode is set, 0 otherwise (POLL message) */
	TransmitTimeout int32      /**< the timeout to use in ms */
	Operation       string
	CommandString   string
}

type Connection

type Connection struct {
	Commands          chan *Command
	KeyPresses        chan *KeyPress
	Messages          chan string
	SourceActivations chan *SourceActivation
	MenuActivations   chan bool
	// contains filtered or unexported fields
}

Connection class

func Open

func Open(name string, deviceName string) (*Connection, error)

Open - open a new connection to the CEC device with the given name

func (*Connection) Destroy

func (c *Connection) Destroy()

Destroy - destroy the cec connection

func (*Connection) GetActiveDevices

func (c *Connection) GetActiveDevices() [16]bool

GetActiveDevices - returns an array of active devices

func (*Connection) GetDeviceOSDName

func (c *Connection) GetDeviceOSDName(address int) string

GetDeviceOSDName - get the OSD name of the specified device

func (*Connection) GetDevicePhysicalAddress

func (c *Connection) GetDevicePhysicalAddress(address int) string

GetDevicePhysicalAddress - Get the physical address of the device at the given logical address

func (*Connection) GetDevicePowerStatus

func (c *Connection) GetDevicePowerStatus(address int) string

GetDevicePowerStatus - Get the power status of the device at the given address

func (*Connection) GetDeviceVendorID

func (c *Connection) GetDeviceVendorID(address int) uint64

GetDeviceVendorID - Get the Vendor-ID of the device at the given address

func (*Connection) IsActiveSource

func (c *Connection) IsActiveSource(address int) bool

IsActiveSource - check if the device at the given address is the active source

func (*Connection) Key

func (c *Connection) Key(address int, key interface{})

Key - send key press and release commands (hold key for 10ms) to the device at the given address, the key code can be specified as a hex-code or by its name

func (*Connection) KeyPress

func (c *Connection) KeyPress(address int, key int) error

KeyPress - send a key press (down) command code to the given address

func (*Connection) KeyRelease

func (c *Connection) KeyRelease(address int) error

KeyRelease - send a key releas command to the given address

func (*Connection) List

func (c *Connection) List() map[string]Device

List - list active devices (returns a map of Devices)

func (*Connection) Mute

func (c *Connection) Mute() error

Mute - send a mute/unmute command to the amp if present

func (*Connection) PollDevice

func (c *Connection) PollDevice(address int) string

Poll device - poll the device at the given logical address

func (*Connection) PowerOn

func (c *Connection) PowerOn(address int) error

PowerOn - power on the device with the given logical address

func (*Connection) RescanDevices

func (c *Connection) RescanDevices()

RescanDevices

func (*Connection) SetActiveSource

func (c *Connection) SetActiveSource(device_type int) bool

SetActiveSource

func (*Connection) SetOSDString

func (c *Connection) SetOSDString(address int, str string) error

func (*Connection) Standby

func (c *Connection) Standby(address int) error

Standby - put the device with the given address in standby mode

func (*Connection) Transmit

func (c *Connection) Transmit(command string)

Transmit CEC command - command is encoded as a hex string with colons (e.g. "40:04")

func (*Connection) VolumeDown

func (c *Connection) VolumeDown() error

VolumeDown - send a volume down command to the amp if present

func (*Connection) VolumeUp

func (c *Connection) VolumeUp() error

VolumeUp - send a volume up command to the amp if present

type DataPacket

type DataPacket struct {
	Data interface{}
	Size int
}

type Device

type Device struct {
	OSDName         string
	Vendor          string
	LogicalAddress  int
	ActiveSource    bool
	PowerStatus     string
	PhysicalAddress string
}

Device structure

type KeyPress

type KeyPress struct {
	KeyCode  int
	Duration int
}

type SourceActivation

type SourceActivation struct {
	LogicalAddress     int
	LogicalAddressName string
	State              bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL