servo

package
v0.0.0-...-9474aff Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Overview

Package servo is used to communicate with servo devices connected to DUTs. It communicates with servod over XML-RPC. More details on servo: https://www.chromium.org/chromium-os/servo

Caution: If you reboot the ChromeOS EC: - If using a CCD servo, you should call WatchdogRemove(ctx, CCD) or servod will fail. - Use Helper.WaitConnect instead of DUT.WaitConnect.

Index

Constants

View Source
const (
	Open   string = "open"
	Lock   string = "lock"
	Unlock string = "unlock"
)

CCD levels

View Source
const ServoKeypressDelay = 100 * time.Millisecond

ServoKeypressDelay comes from hdctools/servo/drv/keyboard_handlers.py. It is the minimum time interval between 'press' and 'release' keyboard events.

Variables

View Source
var KeyMatrix = map[string]KBMatrixPair{
	"<esc>":       KBMatrixPair{1, 1},
	"<f1>":        KBMatrixPair{0, 2},
	"<f2>":        KBMatrixPair{3, 2},
	"<f3>":        KBMatrixPair{2, 2},
	"<f4>":        KBMatrixPair{1, 2},
	"<f5>":        KBMatrixPair{3, 4},
	"<f6>":        KBMatrixPair{2, 4},
	"<f7>":        KBMatrixPair{1, 4},
	"<f8>":        KBMatrixPair{2, 9},
	"<f9>":        KBMatrixPair{1, 9},
	"<f10>":       KBMatrixPair{0, 4},
	"`":           KBMatrixPair{3, 1},
	"1":           KBMatrixPair{6, 1},
	"2":           KBMatrixPair{6, 4},
	"3":           KBMatrixPair{6, 2},
	"4":           KBMatrixPair{6, 3},
	"5":           KBMatrixPair{3, 3},
	"6":           KBMatrixPair{3, 6},
	"7":           KBMatrixPair{6, 6},
	"8":           KBMatrixPair{6, 5},
	"9":           KBMatrixPair{6, 9},
	"0":           KBMatrixPair{6, 8},
	"-":           KBMatrixPair{3, 8},
	"=":           KBMatrixPair{0, 8},
	"<backspace>": KBMatrixPair{1, 11},
	"<tab>":       KBMatrixPair{2, 1},
	"q":           KBMatrixPair{7, 1},
	"w":           KBMatrixPair{7, 4},
	"e":           KBMatrixPair{7, 2},
	"r":           KBMatrixPair{7, 3},
	"t":           KBMatrixPair{2, 3},
	"y":           KBMatrixPair{2, 6},
	"u":           KBMatrixPair{7, 6},
	"i":           KBMatrixPair{7, 5},
	"o":           KBMatrixPair{7, 9},
	"p":           KBMatrixPair{7, 8},
	"[":           KBMatrixPair{2, 8},
	"]":           KBMatrixPair{2, 5},
	"\\":          KBMatrixPair{3, 11},
	"<search>":    KBMatrixPair{0, 1},
	"a":           KBMatrixPair{4, 1},
	"s":           KBMatrixPair{4, 4},
	"d":           KBMatrixPair{4, 2},
	"f":           KBMatrixPair{4, 3},
	"g":           KBMatrixPair{1, 3},
	"h":           KBMatrixPair{1, 6},
	"j":           KBMatrixPair{4, 6},
	"k":           KBMatrixPair{4, 5},
	"l":           KBMatrixPair{4, 9},
	";":           KBMatrixPair{4, 8},
	"'":           KBMatrixPair{1, 8},
	"<enter>":     KBMatrixPair{4, 11},
	"<shift_l>":   KBMatrixPair{5, 7},
	"z":           KBMatrixPair{5, 1},
	"x":           KBMatrixPair{5, 4},
	"c":           KBMatrixPair{5, 2},
	"v":           KBMatrixPair{5, 3},
	"b":           KBMatrixPair{0, 3},
	"n":           KBMatrixPair{0, 6},
	"m":           KBMatrixPair{5, 6},
	",":           KBMatrixPair{5, 5},
	".":           KBMatrixPair{5, 9},
	"/":           KBMatrixPair{5, 8},
	"<shift_r>":   KBMatrixPair{7, 7},
	"<ctrl_l>":    KBMatrixPair{2, 0},
	"<alt_l>":     KBMatrixPair{6, 10},
	" ":           KBMatrixPair{5, 1},
	"<alt_r>":     KBMatrixPair{0, 10},
	"<ctrl_r>":    KBMatrixPair{4, 0},
	"<left>":      KBMatrixPair{7, 12},
	"<up>":        KBMatrixPair{7, 11},
	"<down>":      KBMatrixPair{6, 11},
	"<right>":     KBMatrixPair{6, 12},
}

KeyMatrix is a map that stores a row/col pair for each key using KBMatrixPair It's stored in order of appearance in a keyboard

Functions

func ConvertToStringArrayArray

func ConvertToStringArrayArray(ctx context.Context, stringList []interface{}) ([][]string, error)

ConvertToStringArrayArray takes a stringList from GetStringList and converts it to [][]string

func ParseQuotedString

func ParseQuotedString(value string) (string, error)

ParseQuotedString returns a new string with the quotes and escaped chars from `value` removed.

func ParseStringList

func ParseStringList(value string) ([]interface{}, error)

ParseStringList parses `value` as a possibly nested list of strings, each quoted and separated by commas.

Types

type BoolControl

type BoolControl string

A BoolControl contains the name of a gettable/settable Control which takes a boolean value.

const (
	ChargerAttached BoolControl = "charger_attached"
)

These are the Servo controls which can be get/set with a boolean value.

type DUTConnTypeValue

type DUTConnTypeValue string

A DUTConnTypeValue is a string that would be returned by the DUTConnectionType control.

const (
	DUTConnTypeA DUTConnTypeValue = "type-a"
	DUTConnTypeC DUTConnTypeValue = "type-c"

	// DUTConnTypeNA indicates a non-v4 servo.
	DUTConnTypeNA DUTConnTypeValue = "n/a"
)

These are the string values that can be returned by DUTConnectionType

type DUTController

type DUTController string

DUTController is the active controller on a dual mode servo.

const (
	DUTControllerC2D2       DUTController = "c2d2"
	DUTControllerCCD        DUTController = "ccd_cr50"
	DUTControllerCCDGSC     DUTController = "ccd_gsc"
	DUTControllerServoMicro DUTController = "servo_micro"
)

Parameters that can be passed to SetActiveDUTController().

type FWWPStateValue

type FWWPStateValue string

A FWWPStateValue is a string accepted by the FWWPState control.

const (
	FWWPStateOff FWWPStateValue = "force_off"
	FWWPStateOn  FWWPStateValue = "force_on"
)

These are the string values that can be passed to the FWWPState control.

type FloatControl

type FloatControl string

A FloatControl contains the name of a gettable/settable Control which takes a floating-point value.

const (
	BatteryTemperatureCelsius FloatControl = "battery_tempc"
	VBusVoltage               FloatControl = "vbus_voltage"
)

These are the Servo controls with floating-point values.

type HibernationOpt

type HibernationOpt string

HibernationOpt is an option for hibernating DUT.

const (
	// UseKeyboard uses keyboard shortcut for hibernating DUT: alt+vol_up+h.
	UseKeyboard HibernationOpt = "keyboard"
	// UseConsole uses the EC command `hibernate` to put DUT in hibernation.
	UseConsole HibernationOpt = "console"
)

Available options for triggering hibernation.

type IntControl

type IntControl string

An IntControl contains the name of a gettable/settable Control which takes an integer value.

const (
	BatteryChargeMAH     IntControl = "battery_charge_mah"
	BatteryCurrentMA     IntControl = "ppvar_vbat_ma"
	BatteryFullChargeMAH IntControl = "battery_full_charge_mah"
	BatteryVoltageMV     IntControl = "ppvar_vbat_mv"
	VolumeDownHold       IntControl = "volume_down_hold"    // Integer represents a number of milliseconds.
	VolumeUpHold         IntControl = "volume_up_hold"      // Integer represents a number of milliseconds.
	VolumeUpDownHold     IntControl = "volume_up_down_hold" // Integer represents a number of milliseconds.
)

These are the Servo controls which can be get/set with an integer value.

type KBMatrixPair

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

KBMatrixPair is a struct to store key row and col for the kbpress cmd

type KeypressControl

type KeypressControl StringControl

A KeypressControl is a special type of Control which can take either a numerical value or a KeypressDuration.

const (
	CtrlD        KeypressControl = "ctrl_d"
	CtrlS        KeypressControl = "ctrl_s"
	CtrlU        KeypressControl = "ctrl_u"
	CtrlEnter    KeypressControl = "ctrl_enter"
	Ctrl         KeypressControl = "ctrl_key"
	Enter        KeypressControl = "enter_key"
	Refresh      KeypressControl = "refresh_key"
	CtrlRefresh  KeypressControl = "ctrl_refresh_key"
	ImaginaryKey KeypressControl = "imaginary_key"
	SysRQX       KeypressControl = "sysrq_x"
	PowerKey     KeypressControl = "power_key"
	Pwrbutton    KeypressControl = "pwr_button"
	USBEnter     KeypressControl = "usb_keyboard_enter_key"
)

These are the Servo controls which can be set with either a numerical value or a KeypressDuration.

type KeypressDuration

type KeypressDuration string

A KeypressDuration is a string accepted by a KeypressControl.

const (
	DurTab        KeypressDuration = "tab"
	DurPress      KeypressDuration = "press"
	DurShortPress KeypressDuration = "short_press"
	DurLongPress  KeypressDuration = "long_press"
)

These are string values that can be passed to a KeypressControl.

func Dur

Dur returns a custom duration that can be passed to KeypressWithDuration

type LidOpenValue

type LidOpenValue string

A LidOpenValue is a string accepted by the LidOpen control.

const (
	LidOpenYes LidOpenValue = "yes"
	LidOpenNo  LidOpenValue = "no"
)

These are the string values that can be passed to the LidOpen control.

type OnOffControl

type OnOffControl string

A OnOffControl accepts either "on" or "off" as a value.

const (
	CCDKeepaliveEn OnOffControl = "ccd_keepalive_en"
	CCDState       OnOffControl = "ccd_state"
	DTSMode        OnOffControl = "servo_dts_mode"
	RecMode        OnOffControl = "rec_mode"
	USBKeyboard    OnOffControl = "init_usb_keyboard"
	I2CMuxEn       OnOffControl = "i2c_mux_en"
	ColdReset      OnOffControl = "cold_reset"
)

These controls accept only "on" and "off" as values.

const (
	CR50UARTCapture OnOffControl = "cr50_uart_capture"
)

These controls accept only "on" and "off" as values.

const (
	ECUARTCapture OnOffControl = "ec_uart_capture"
)

These controls accept only "on" and "off" as values.

type OnOffValue

type OnOffValue string

An OnOffValue is a string value that would be accepted by an OnOffControl.

const (
	Off OnOffValue = "off"
	On  OnOffValue = "on"
)

These are the values used by OnOff controls.

type PDRoleValue

type PDRoleValue string

A PDRoleValue is a string that would be accepted by the PDRole control.

const (
	PDRoleSnk PDRoleValue = "snk"
	PDRoleSrc PDRoleValue = "src"

	// PDRoleNA indicates a non-v4 servo.
	PDRoleNA PDRoleValue = "n/a"
)

These are the string values that can be passed to PDRole.

type PowerStateValue

type PowerStateValue string

A PowerStateValue is a string accepted by the PowerState control.

const (
	PowerStateCR50Reset   PowerStateValue = "cr50_reset"
	PowerStateOff         PowerStateValue = "off"
	PowerStateOn          PowerStateValue = "on"
	PowerStateRec         PowerStateValue = "rec"
	PowerStateRecForceMRC PowerStateValue = "rec_force_mrc"
	PowerStateReset       PowerStateValue = "reset"
	PowerStateWarmReset   PowerStateValue = "warm_reset"
)

These are the string values that can be passed to the PowerState control.

type Proxy

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

Proxy wraps a Servo object and forwards connections to the servod instance over SSH if needed.

func NewProxy

func NewProxy(ctx context.Context, servoHostPort, keyFile, keyDir string) (newProxy *Proxy, retErr error)

NewProxy returns a Proxy object for communicating with the servod instance at spec, which can be blank (defaults to localhost:9999) or a hostname (defaults to hostname:9999:ssh:22) or a host:port (ssh port defaults to 22) or to fully qualify everything host:port:ssh:sshport.

Use hostname:9999:nossh to prevent the use of ssh at all. You probably don't ever want to use this.

You can also use IPv4 addresses as the hostnames, or IPv6 addresses in square brackets [::1].

If you are using ssh port forwarding, please note that the host and ssh port will be evaluated locally, but the servo port should be the real servo port on the servo host. So if you used the ssh command `ssh -L 2223:localhost:22 -L 2222:${DUT_HOSTNAME?}:22 root@${SERVO_HOSTNAME?}` then you would start tast with `tast run --var=servo=localhost:${SERVO_PORT?}:ssh:2223 localhost:2222 firmware.Config*`

If the instance is not running on the local system, an SSH connection will be opened to the host running servod and servod connections will be forwarded through it. keyFile and keyDir are used for establishing the SSH connection and should typically come from dut.DUT's KeyFile and KeyDir methods.

If the servod is running in a docker container, the serverHostPort expected to be in form "${CONTAINER_NAME}:9999:docker:". The port of the servod host is defaulted to 9999, user only needs to provide the container name. CONTAINER_NAME must end with docker_servod.

func (*Proxy) Close

func (p *Proxy) Close(ctx context.Context)

Close closes the proxy's SSH connection if present.

func (*Proxy) GetFile

func (p *Proxy) GetFile(ctx context.Context, asRoot bool, remoteFile, localFile string) error

GetFile copies a servo host file to a local file.

func (*Proxy) GetPort

func (p *Proxy) GetPort() int

GetPort returns the port where servod is running on the server.

func (*Proxy) InputCommand

func (p *Proxy) InputCommand(ctx context.Context, asRoot bool, stdin io.Reader, name string, args ...string) error

InputCommand execs a command and redirects stdin.

func (*Proxy) NewForwarder

func (p *Proxy) NewForwarder(ctx context.Context, hostPort string) (*ssh.Forwarder, error)

NewForwarder forwards a local port to a remote port on the servo host.

func (*Proxy) OutputCommand

func (p *Proxy) OutputCommand(ctx context.Context, asRoot bool, name string, args ...string) ([]byte, error)

OutputCommand execs a command as the root user and returns stdout.

func (*Proxy) Proxied

func (p *Proxy) Proxied() bool

Proxied returns true if the servo host is connected via ssh proxy.

func (*Proxy) PutFiles

func (p *Proxy) PutFiles(ctx context.Context, asRoot bool, fileMap map[string]string) error

PutFiles copies a local file to a servo host file.

func (*Proxy) Reconnect

func (p *Proxy) Reconnect(ctx context.Context) error

Reconnect closes the ssh connection, and reconnects.

func (*Proxy) RunCommand

func (p *Proxy) RunCommand(ctx context.Context, asRoot bool, name string, args ...string) error

RunCommand execs a command on the servo host, optionally as root.

func (*Proxy) RunCommandQuiet

func (p *Proxy) RunCommandQuiet(ctx context.Context, asRoot bool, name string, args ...string) error

RunCommandQuiet execs a command on the servo host, optionally as root, does not log output.

func (*Proxy) Servo

func (p *Proxy) Servo() *Servo

Servo returns the proxy's encapsulated Servo object.

type Servo

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

Servo holds the servod connection information.

func Default

func Default(ctx context.Context) (*Servo, error)

Default creates a Servo object for communicating with a local servod instance using the default port.

func New

func New(ctx context.Context, host string, port int) (*Servo, error)

New creates a new Servo object for communicating with a servod instance. connSpec holds servod's location, either as "host:port" or just "host" (to use the default port).

func NewDirect

func NewDirect(ctx context.Context, spec string) (*Servo, error)

NewDirect returns a servo object for communication with a servod instance running at spec. During local tests, instead of establishing a ssh proxy with servo host, creating a direct connection is preferred. Param spec is either "host:port" or just "host" to use default port. Please make sure "host" is the address reachable from DUT.

func (*Servo) CheckAndRunTabletModeCommand

func (s *Servo) CheckAndRunTabletModeCommand(ctx context.Context, command string) (string, error)

CheckAndRunTabletModeCommand checks if relevant EC commands exist and use them for setting tablet mode. For example, detachables use 'basestate (attach|detach)', and convertibles use 'tabletmode (on|off)'.

func (*Servo) CheckUnresponsiveEC

func (s *Servo) CheckUnresponsiveEC(ctx context.Context) error

CheckUnresponsiveEC verifies that EC console is unresponsive in situations such as hibernation and battery cutoff. Ignore null chars, sometimes the servo returns null when the EC is off.

func (*Servo) Close

func (s *Servo) Close(ctx context.Context) error

Close performs Servo cleanup.

func (*Servo) CloseLid

func (s *Servo) CloseLid(ctx context.Context) error

CloseLid sends the ec command to simulate DUT lid closing

func (*Servo) DUTVoltageMV

func (s *Servo) DUTVoltageMV(ctx context.Context) (string, error)

DUTVoltageMV reads the voltage present on the DUT port on fluffy.

func (*Servo) ECHibernate

func (s *Servo) ECHibernate(ctx context.Context, option HibernationOpt) error

ECHibernate puts the EC into hibernation mode, after removing the servo watchdog for CCD if necessary.

func (*Servo) ECPressKey

func (s *Servo) ECPressKey(ctx context.Context, key string) error

ECPressKey simulates a keypress on the DUT from the servo using kbpress.

func (*Servo) Echo

func (s *Servo) Echo(ctx context.Context, message string) (string, error)

Echo calls the Servo echo method.

func (*Servo) GetBatteryChargeMAH

func (s *Servo) GetBatteryChargeMAH(ctx context.Context) (int, error)

GetBatteryChargeMAH returns the battery's charge in mAh.

func (*Servo) GetBatteryFullChargeMAH

func (s *Servo) GetBatteryFullChargeMAH(ctx context.Context) (int, error)

GetBatteryFullChargeMAH returns the battery's last full charge in mAh.

func (*Servo) GetBool

func (s *Servo) GetBool(ctx context.Context, control BoolControl) (bool, error)

GetBool returns the boolean value of a specified control.

func (*Servo) GetCCDSerial

func (s *Servo) GetCCDSerial(ctx context.Context) (string, error)

GetCCDSerial returns the serial number of the CCD interface.

func (*Servo) GetChargerAttached

func (s *Servo) GetChargerAttached(ctx context.Context) (bool, error)

GetChargerAttached returns the boolean value to indicate whether charger is attached.

func (*Servo) GetDUTConnectionType

func (s *Servo) GetDUTConnectionType(ctx context.Context) (DUTConnTypeValue, error)

GetDUTConnectionType gets the type of connection between the Servo and the DUT. If Servo is not V4, returns DUTConnTypeNA.

func (*Servo) GetECChip

func (s *Servo) GetECChip(ctx context.Context) (string, error)

GetECChip returns the DUT chip e.g. "npcx_uut"

func (*Servo) GetECFlashSize

func (s *Servo) GetECFlashSize(ctx context.Context) (int, error)

GetECFlashSize returns the size of EC in KB e.g. 512

func (*Servo) GetECSystemPowerState

func (s *Servo) GetECSystemPowerState(ctx context.Context) (string, error)

GetECSystemPowerState returns the power state, like "S0" or "G3"

func (*Servo) GetFloat

func (s *Servo) GetFloat(ctx context.Context, control FloatControl) (float64, error)

GetFloat returns the floating-point value of a specified control.

func (*Servo) GetInt

func (s *Servo) GetInt(ctx context.Context, control IntControl) (int, error)

GetInt returns the integer value of a specified control.

func (*Servo) GetKBBacklight

func (s *Servo) GetKBBacklight(ctx context.Context) (int, error)

GetKBBacklight gets the DUT keyboards backlight value in percent (0 - 100).

func (*Servo) GetKeyRowCol

func (s *Servo) GetKeyRowCol(key string) (int, int, error)

GetKeyRowCol returns the key row and column for kbpress cmd

func (*Servo) GetOnOff

func (s *Servo) GetOnOff(ctx context.Context, ctrl OnOffControl) (bool, error)

GetOnOff gets an OnOffControl as a bool.

func (*Servo) GetPDCommunication

func (s *Servo) GetPDCommunication(ctx context.Context) (string, error)

GetPDCommunication returns the current value from servo_v4_PD_comm.

func (*Servo) GetPDRole

func (s *Servo) GetPDRole(ctx context.Context) (PDRoleValue, error)

GetPDRole returns the servo's current PDRole (SNK or SRC), or PDRoleNA if Servo is not V4.

func (*Servo) GetQuotedString

func (s *Servo) GetQuotedString(ctx context.Context, control StringControl) (string, error)

GetQuotedString parses the value of a control as a quoted string

func (*Servo) GetServoSerials

func (s *Servo) GetServoSerials(ctx context.Context) (map[string]string, error)

GetServoSerials returns a map of servo serial numbers. Interesting map keys are "ccd", "main", "servo_micro", but there are others also.

func (*Servo) GetServoType

func (s *Servo) GetServoType(ctx context.Context) (string, error)

GetServoType gets the type of the servo.

func (*Servo) GetServoVersion

func (s *Servo) GetServoVersion(ctx context.Context) (string, error)

GetServoVersion gets the version of Servo being used.

func (*Servo) GetString

func (s *Servo) GetString(ctx context.Context, control StringControl) (string, error)

GetString returns the value of a specified control.

func (*Servo) GetStringList

func (s *Servo) GetStringList(ctx context.Context, control StringControl) ([]interface{}, error)

GetStringList parses the value of a control as an encoded list

func (*Servo) GetStringTimeout

func (s *Servo) GetStringTimeout(ctx context.Context, control StringControl, timeout time.Duration) (string, error)

GetStringTimeout returns the value of a specified control with a custom timeout.

func (*Servo) GetUSBMuxState

func (s *Servo) GetUSBMuxState(ctx context.Context) (USBMuxState, error)

GetUSBMuxState determines whether the servo USB mux is on, and if so, which direction it is pointed.

func (*Servo) HasCCD

func (s *Servo) HasCCD(ctx context.Context) (bool, error)

HasCCD checks if the servo has a CCD connection.

func (*Servo) HasControl

func (s *Servo) HasControl(ctx context.Context, ctrl string) (bool, error)

HasControl determines whether the Servo being used supports the given control.

func (*Servo) HasKBBacklight

func (s *Servo) HasKBBacklight(ctx context.Context) bool

HasKBBacklight checks if the DUT keyboards has backlight functionality.

func (*Servo) IsServoV4

func (s *Servo) IsServoV4(ctx context.Context) (bool, error)

IsServoV4 determines whether the Servo being used is v4.

func (*Servo) KeypressWithDuration

func (s *Servo) KeypressWithDuration(ctx context.Context, control KeypressControl, value KeypressDuration) error

KeypressWithDuration sets a KeypressControl to a KeypressDuration value.

func (*Servo) LidOpenState

func (s *Servo) LidOpenState(ctx context.Context) (string, error)

LidOpenState checks whether DUT's lid is open or closed, and returns yes/no.

func (*Servo) OpenCCD

func (s *Servo) OpenCCD(ctx context.Context) error

OpenCCD checks if a CCD connection exists, and then opens CCD if it's locked.

func (*Servo) OpenLid

func (s *Servo) OpenLid(ctx context.Context) error

OpenLid sends the ec command to simulate DUT lid opening

func (*Servo) PowerNormalPress

func (s *Servo) PowerNormalPress(ctx context.Context) (bool, error)

PowerNormalPress calls the Servo power_normal_press method.

func (*Servo) PreferDebugHeader

func (s *Servo) PreferDebugHeader(ctx context.Context) (bool, error)

PreferDebugHeader switches to the servo_micro or C2D2 for dual v4 servos, but doesn't fail on CCD only servos. Returns true if the servo has a debug header connection, false if it only has CCD.

func (*Servo) PressKey

func (s *Servo) PressKey(ctx context.Context, key string, value KeypressDuration) error

PressKey presses an arbitrary key for a KeypressDuration. This either uses EC keyboard emulation or the servo's emulated USB keyboard depending on the setting of USBKeyboard.

func (*Servo) RequireCCD

func (s *Servo) RequireCCD(ctx context.Context) error

RequireCCD verifies that the servo has a CCD connection, and switches to it for dual v4 servos.

func (*Servo) RequireDebugHeader

func (s *Servo) RequireDebugHeader(ctx context.Context) error

RequireDebugHeader verifies that the servo has a servo_micro or C2D2 connection, and switches to it for dual v4 servos.

func (*Servo) RunCR50Command

func (s *Servo) RunCR50Command(ctx context.Context, cmd string) error

RunCR50Command runs the given command on the Cr50 on the device.

func (*Servo) RunCR50CommandGetOutput

func (s *Servo) RunCR50CommandGetOutput(ctx context.Context, cmd string, patterns []string) ([][]string, error)

RunCR50CommandGetOutput runs the given command on the Cr50 on the device and returns the output matching patterns.

func (*Servo) RunECCommand

func (s *Servo) RunECCommand(ctx context.Context, cmd string) error

RunECCommand runs the given command on the EC on the device.

func (*Servo) RunECCommandGetOutput

func (s *Servo) RunECCommandGetOutput(ctx context.Context, cmd string, patterns []string) ([][]string, error)

RunECCommandGetOutput runs the given command on the EC on the device and returns the output matching patterns.

func (*Servo) RunUSBCDPConfigCommand

func (s *Servo) RunUSBCDPConfigCommand(ctx context.Context, args ...string) error

RunUSBCDPConfigCommand executes the "usbc_action dp" command with the specified args on the servo console.

func (*Servo) SetActChgPort

func (s *Servo) SetActChgPort(ctx context.Context, port string) error

SetActChgPort enables a charge port on fluffy.

func (*Servo) SetActiveDUTController

func (s *Servo) SetActiveDUTController(ctx context.Context, adc DUTController) error

SetActiveDUTController sets the active controller on a dual mode v4 servo

func (*Servo) SetCC

func (s *Servo) SetCC(ctx context.Context, val OnOffValue) error

SetCC sets the CC line to the specified value.

func (*Servo) SetDUTPDDataRole

func (s *Servo) SetDUTPDDataRole(ctx context.Context, role USBCDataRole) error

SetDUTPDDataRole tries to find the port attached to the servo, and performs a data role swap if the role doesn't match `role`. Will fail if there is no chromeos EC.

func (*Servo) SetFWWPState

func (s *Servo) SetFWWPState(ctx context.Context, value FWWPStateValue) error

SetFWWPState sets the FWWPState control. Because this is particularly disruptive, it is always logged.

func (*Servo) SetInt

func (s *Servo) SetInt(ctx context.Context, control IntControl, value int) error

SetInt sets a Servo control to an integer value.

func (*Servo) SetKBBacklight

func (s *Servo) SetKBBacklight(ctx context.Context, percent int) error

SetKBBacklight sets the DUT keyboards backlight to the given value (0 - 100).

func (*Servo) SetOnOff

func (s *Servo) SetOnOff(ctx context.Context, ctrl OnOffControl, value OnOffValue) error

SetOnOff sets an OnOffControl setting to the specified value.

func (*Servo) SetPDRole

func (s *Servo) SetPDRole(ctx context.Context, newRole PDRoleValue) error

SetPDRole sets the PDRole control for a servo v4. On a Servo version other than v4, this does nothing.

func (*Servo) SetPowerState

func (s *Servo) SetPowerState(ctx context.Context, value PowerStateValue) error

SetPowerState sets the PowerState control. Because this is particularly disruptive, it is always logged. It can be slow, because some boards are configured to hold down the power button for 12 seconds.

func (*Servo) SetString

func (s *Servo) SetString(ctx context.Context, control StringControl, value string) error

SetString sets a Servo control to a string value.

func (*Servo) SetStringAndCheck

func (s *Servo) SetStringAndCheck(ctx context.Context, control StringControl, value string) error

SetStringAndCheck sets a control to a specified value, and then verifies that it was set correctly. Unless you have a good reason to check, just use SetString.

func (*Servo) SetStringList

func (s *Servo) SetStringList(ctx context.Context, control StringControl, values []string) error

SetStringList sets a Servo control to a list of string values.

func (*Servo) SetStringTimeout

func (s *Servo) SetStringTimeout(ctx context.Context, control StringControl, value string, timeout time.Duration) error

SetStringTimeout sets a Servo control to a string value.

func (*Servo) SetUSBMuxState

func (s *Servo) SetUSBMuxState(ctx context.Context, value USBMuxState) error

SetUSBMuxState switches the servo's USB mux to the specified power/direction state.

func (*Servo) ToggleOffOn

func (s *Servo) ToggleOffOn(ctx context.Context, ctrl OnOffControl) error

ToggleOffOn turns a switch off and on again.

func (*Servo) ToggleOnOff

func (s *Servo) ToggleOnOff(ctx context.Context, ctrl OnOffControl) error

ToggleOnOff turns a switch on and off again.

func (*Servo) WatchdogAdd

func (s *Servo) WatchdogAdd(ctx context.Context, val WatchdogValue) error

WatchdogAdd adds the specified watchdog to the servod instance.

func (*Servo) WatchdogRemove

func (s *Servo) WatchdogRemove(ctx context.Context, val WatchdogValue) error

WatchdogRemove removes the specified watchdog from the servod instance. Servo.Close() will restore the watchdog.

type StringControl

type StringControl string

A StringControl contains the name of a gettable/settable Control which takes a string value.

const (
	GSCCCDLevel    StringControl = "gsc_ccd_level"
	CR50Testlab    StringControl = "cr50_testlab"
	CR50UARTCmd    StringControl = "cr50_uart_cmd"
	CR50UARTRegexp StringControl = "cr50_uart_regexp"
	CR50UARTStream StringControl = "cr50_uart_stream"
)

These are the Cr50 Servo controls which can be get/set with a string value.

const (
	ECBoard            StringControl = "ec_board"
	ECSystemPowerState StringControl = "ec_system_powerstate"
	ECUARTCmd          StringControl = "ec_uart_cmd"
	ECUARTRegexp       StringControl = "ec_uart_regexp"
	ECUARTStream       StringControl = "ec_uart_stream"
	ECChip             StringControl = "ec_chip"
	ECFlashSize        StringControl = "ec_flash_size"
	DUTPDDataRole      StringControl = "dut_pd_data_role"
)

These are the EC Servo controls which can be get/set with a string value.

const (
	ActiveChgPort         StringControl = "active_chg_port"
	ActiveDUTController   StringControl = "active_dut_controller"
	ArbKey                StringControl = "arb_key"
	ArbKeyConfig          StringControl = "arb_key_config"
	DUTVoltageMV          StringControl = "dut_voltage_mv"
	DownloadImageToUSBDev StringControl = "download_image_to_usb_dev"
	ECActiveCopy          StringControl = "ec_active_copy"
	FWWPState             StringControl = "fw_wp_state"
	ImageUSBKeyDev        StringControl = "image_usbkey_dev"
	ImageUSBKeyDirection  StringControl = "image_usbkey_direction"
	ImageUSBKeyPwr        StringControl = "image_usbkey_pwr"
	LidOpen               StringControl = "lid_open"
	PowerState            StringControl = "power_state"
	Type                  StringControl = "servo_type"
	UARTCmd               StringControl = "servo_v4_uart_cmd"
	UARTCmdV4p1           StringControl = "servo_v4p1_uart_cmd"
	Watchdog              StringControl = "watchdog"
	WatchdogAdd           StringControl = "watchdog_add"
	WatchdogRemove        StringControl = "watchdog_remove"
	PDCommunication       StringControl = "servo_pd_comm"

	// DUTConnectionType was previously known as V4Type ("servo_v4_type")
	DUTConnectionType StringControl = "root.dut_connection_type"

	// PDRole was previously known as V4Role ("servo_v4_role")
	PDRole StringControl = "servo_pd_role"
)

These are the Servo controls which can be get/set with a string value.

type USBCDataRole

type USBCDataRole string

USBCDataRole is a USB-C data role.

const (
	// UFP is Upward facing partner, i.e. a peripheral. The servo should normally be in this role.
	UFP USBCDataRole = "UFP"
	// DFP is Downward facing partner, i.e. a host. The DUT should normally be in this role.
	DFP USBCDataRole = "DFP"
)

USB-C data roles.

type USBMuxState

type USBMuxState string

A USBMuxState indicates whether the servo's USB mux is on, and if so, which direction it is powering.

const (
	USBMuxOff  USBMuxState = "off"
	USBMuxDUT  USBMuxState = "dut_sees_usbkey"
	USBMuxHost USBMuxState = "servo_sees_usbkey"
)

These are the possible states of the USB mux.

type WatchdogValue

type WatchdogValue string

A WatchdogValue is a string that would be accepted by WatchdogAdd & WatchdogRemove control.

const (
	WatchdogCCD  WatchdogValue = "ccd"
	WatchdogMain WatchdogValue = "main"
)

These are the string watchdog type values that can be passed to WatchdogAdd & WatchdogRemove.

Jump to

Keyboard shortcuts

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