exlink

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2017 License: MIT Imports: 3 Imported by: 1

README

A Go library for controlling Samsung TVs through the EX-Link serial port included on most models.

The EX-Link connection is 3.5mm stereo jack identical to a standard headphone connector. In order to connect your TV to a computer, you'll need a 3.5mm stereo jack to serial adapter along with a serial to USB adapter such as the Keyspan USA-19H or IOGEAR GUC232A. These models have been tested successfully to control 2011 and 2015 model year Samsung TVs from both a Raspberry Pi 3 and a MacBook Pro.

The EX-Link protocol consists of byte codes sent through the serial connection that can control the majority of Samsung TV features, settings, and remote control buttons. See exlink.go for the list of codes that this library supports.

Usage

Call exlink.Open with the path to your serial port such as /dev/ttyUSB0 or /dev/tty.KeySerial1. Then call various functions to control the TV. Sleeps have been included between function calls in the example below to allow you to see the results of the commands through your TV's on-screen display.

	package main

	import (
		"github.com/mgoff/go-samsung-exlink"
		"log"
		"time"
	)

	func main() {

		// open the connection to the EX-Link device
		device, err := exlink.Open("/dev/ttyUSB0")
		if err != nil {
			log.Fatal(err)
		}

		// close the connection at the end
		defer device.Close()

		// turn on the EX-Link device
		err = device.PowerOn()
		if err != nil {
			log.Fatal(err)
		}
		time.Sleep(10 * time.Second)

		// switch to HDMI 1
		err = device.SourceHDMI1()
		if err != nil {
			log.Fatal(err)
		}
		time.Sleep(10 * time.Second)

		// switch to HDMI 2
		err = device.SourceHDMI2()
		if err != nil {
			log.Fatal(err)
		}
		time.Sleep(10 * time.Second)

		// turn off the EX-Link device
		err = device.PowerOff()
		if err != nil {
			log.Fatal(err)
		}
	}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exlink struct {
	// contains filtered or unexported fields
}

struct used to hold our serial connection

func Open

func Open(device string) (Exlink, error)

open a serial connection to the EX-Link device

func (Exlink) Close

func (e Exlink) Close() error

close the serial connection to the EX-Link device

func (Exlink) PowerOff

func (e Exlink) PowerOff() error

power off the EX-Link device

func (Exlink) PowerOn

func (e Exlink) PowerOn() error

power on the EX-Link device

func (Exlink) Send

func (e Exlink) Send(code string) error

send a hex code to the EX-Link device

func (Exlink) SourceHDMI1

func (e Exlink) SourceHDMI1() error

switch to source input HDMI1

func (Exlink) SourceHDMI2

func (e Exlink) SourceHDMI2() error

switch to source input HDMI2

func (Exlink) SpeakerOff

func (e Exlink) SpeakerOff() error

turn on speakers

func (Exlink) SpeakerOn

func (e Exlink) SpeakerOn() error

turn on speakers

func (Exlink) VolumeDown

func (e Exlink) VolumeDown() error

volume down

func (Exlink) VolumeUp

func (e Exlink) VolumeUp() error

volume up

Jump to

Keyboard shortcuts

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