servo

package
v0.0.0-...-6e5b399 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: BSD-3-Clause Imports: 24 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 RemoveCCDWatchdogs(ctx) 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 (

	// MaxPorts specifies the maximum number of ports on the EC.
	MaxPorts int = 4
	// PDPortUnderTest indicates command should be sent to the PD port connected to servo.
	PDPortUnderTest int = MaxPorts
)
View Source
const (
	DROn     string = `on`
	DROff    string = `off`
	DRFreeze string = `freeze`
	DRSink   string = `sink`
	DRSource string = `source`
)

Supported DualRole states

View Source
const (
	PartnerDualRolePower = 1 << 1
	PartnerDualRoleData  = 1 << 2
	VCONNEnabled         = 1 << 12
)

TCPMv2 flags bitmask values. Source of truth for these values comes from the EC source [1]. [1] https://source.chromium.org/chromiumos/chromiumos/codesearch/+/HEAD:src/platform/ec/include/usb_pd.h

View Source
const (
	PDCtrlReserved pdControlMsgType = "Reserved"
	PDCtrlGoodCRC  pdControlMsgType = "GoodCRC"
	PDCtrlAccept   pdControlMsgType = "Accept"
	PDCtrlReject   pdControlMsgType = "Reject"
)

PD control message types

View Source
const (
	// PolarityUnknown (CC0) is observed on some DUTs when the polarity is unknown /
	// uninitialized.
	PolarityUnknown pdPolarityValue = "CC0"
	PolarityCC1     pdPolarityValue = "CC1"
	PolarityCC2     pdPolarityValue = "CC2"
	PolarityCC1DTS  pdPolarityValue = "CC3"
	PolarityCC2DTS  pdPolarityValue = "CC4"
)

List of polarity values.

View Source
const (
	PDEnabled  connectionValue = "enabled"
	PDDisabled connectionValue = "disabled"
)

List of PD status values.

View Source
const (
	PowerRoleSRC powerRoleValue = "SRC"
	PowerRoleSNK powerRoleValue = "SNK"
)

List of PD power roles.

View Source
const (
	DataRoleDFP dataRoleValue = "DFP"
	DataRoleUFP dataRoleValue = "UFP"
)

List of PD data roles

View Source
const (
	// PdControlMsgMask is a bitmask to extract the message type from PD control messages.
	PdControlMsgMask uint64 = 0x1f
)
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

This section is empty.

Functions

func ClearServoAccumulators

func ClearServoAccumulators(ctx context.Context, s *Servo, clearCtrls []IntControl) error

ClearServoAccumulators clears underlying accumulators given the controls.

func ConvertToStringArrayArray

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

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

func FindPowerRailsWithFilter

func FindPowerRailsWithFilter(ctx context.Context, s *Servo, useAccumulators bool, filters []*regexp.Regexp) ([]FloatControl, []IntControl, error)

FindPowerRailsWithFilter gets results for power rails and applies given filter to results.

If useAccumulators is false then this will fallback to using 'power_rails' rather than 'avg_power_rails'

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.

func PropertyToString

func PropertyToString(property interface{}, name string) (string, error)

PropertyToString returns the string value assigned to a property

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 CCDCap

type CCDCap string

CCDCap contains possible CCD capabilities.

const (
	UartGscRxAPTx   CCDCap = "UartGscRxAPTx"
	UartGscTxAPRx   CCDCap = "UartGscTxAPRx"
	UartGscRxECTx   CCDCap = "UartGscRxECTx"
	UartGscTxECRx   CCDCap = "UartGscTxECRx"
	FlashAP         CCDCap = "FlashAP"
	FlashEC         CCDCap = "FlashEC"
	OverrideWP      CCDCap = "OverrideWP"
	RebootECAP      CCDCap = "RebootECAP"
	GscFullConsole  CCDCap = "GscFullConsole"
	UnlockNoReboot  CCDCap = "UnlockNoReboot"
	UnlockNoShortPP CCDCap = "UnlockNoShortPP"
	OpenNoTPMWipe   CCDCap = "OpenNoTPMWipe"
	OpenNoLongPP    CCDCap = "OpenNoLongPP"
	BatteryBypassPP CCDCap = "BatteryBypassPP"
	Unused          CCDCap = "Unused"
	I2C             CCDCap = "I2C"
	FlashRead       CCDCap = "FlashRead"
	OpenNoDevMode   CCDCap = "OpenNoDevMode"
	OpenFromUSB     CCDCap = "OpenFromUSB"
	OverrideBatt    CCDCap = "OverrideBatt"
	APROCheckVC     CCDCap = "APROCheckVC"
)

CCD capabilities.

type CCDCapState

type CCDCapState string

CCDCapState contains possible states for a CCD capability.

const (
	CapDefault      CCDCapState = "Default"
	CapAlways       CCDCapState = "Always"
	CapUnlessLocked CCDCapState = "UnlessLocked"
	CapIfOpened     CCDCapState = "IfOpened"
)

CCD capability states

type ConnectInfo

type ConnectInfo struct {
	Hostname        string
	ServoPort       int
	ServoSSHPort    int
	DockerContainer string
	DockerHost      string
}

ConnectInfo stores connection information to servo.

func SplitHostPort

func SplitHostPort(servoHostPort string) (*ConnectInfo, error)

SplitHostPort parses a string that represents servo connection.

type DPModeValue

type DPModeValue int

DPModeValue is a type for storing a type-c alt state dp status

const (
	DPEnable  DPModeValue = 1
	DPDisable DPModeValue = 0
)

supported dp modes

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"
	DUTControllerCCDCr50    DUTController = "ccd_cr50"
	DUTControllerCCD        DUTController = "ccd_gsc"
	DUTControllerCCDTi50    DUTController = "ccd_ti50"
	DUTControllerServoMicro DUTController = "servo_micro"
)

Parameters that can be passed to SetActiveDUTController().

type DUTPDInfo

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

DUTPDInfo caches the fixed PD testing information for the DUT.

type DUTUSB3Value

type DUTUSB3Value string

A DUTUSB3Value is a string accepted by the dut_usb3 control.

const (
	DUTUSB3Enable  DUTUSB3Value = "enable"
	DUTUSB3Disable DUTUSB3Value = "disable"
)

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

type DetachableECButton

type DetachableECButton string

DetachableECButton holds ec button controls for a detachable, which can take customized durations in milliseconds.

const (
	ECVupButton   DetachableECButton = "button vup"
	ECVdownButton DetachableECButton = "button vdown"
	ECPwrButton   DetachableECButton = "powerbtn"
)

These are the available ec button controls for a detachable.

type ECChannelName

type ECChannelName string

ECChannelName holds the ec channel names.

const (
	ECChanKeyboard ECChannelName = "keyboard"
	ECChanSwitch   ECChannelName = "switch"
)

These are some of the ec channel names available. To-do: expand when necessary.

type ECHostevent

type ECHostevent int64

ECHostevent holds int codes for EC hostevents

const (
	// HosteventLidClosed is the event code for lid closed.
	HosteventLidClosed ECHostevent = 0x00000001
	// HosteventLidOpen is the event code for lid open.
	HosteventLidOpen ECHostevent = 0x00000002
	// HosteventPowerButton is the event code for power button.
	HosteventPowerButton ECHostevent = 0x00000004
	// HosteventAcConnected is the event code for ac connected.
	HosteventAcConnected ECHostevent = 0x00000008
	// HosteventAcDisconnected is the event code for ac disconnected.
	HosteventAcDisconnected ECHostevent = 0x00000010
	// HosteventBatteryLow is the event code for low battery.
	HosteventBatteryLow ECHostevent = 0x00000020
	// HosteventBatteryCritical is the event code for critical battery.
	HosteventBatteryCritical ECHostevent = 0x00000040
	// HosteventBattery is the event code for battery.
	HosteventBattery ECHostevent = 0x00000080
	// HosteventThermalThreshold is the event code for thermal threshold.
	HosteventThermalThreshold ECHostevent = 0x00000100
	// HosteventThermalOverload is the event code for thermal overload.
	HosteventThermalOverload ECHostevent = 0x00000200
	// HosteventThermal is the event code for thermal.
	HosteventThermal ECHostevent = 0x00000400
	// HosteventUsbCharger is the event code for usb charger.
	HosteventUsbCharger ECHostevent = 0x00000800
	// HosteventKeyPressed is the event code for key press.
	HosteventKeyPressed ECHostevent = 0x00001000
	// HosteventInterfaceReady is the event code for interface ready.
	HosteventInterfaceReady ECHostevent = 0x00002000
	// HosteventKeyboardRecovery is the event code for keyboard recovery combo has been pressed
	HosteventKeyboardRecovery ECHostevent = 0x00004000
	// HosteventThermalShutdown is the event code for shutdown due to thermal overload.
	HosteventThermalShutdown ECHostevent = 0x00008000
	// HosteventBatteryShutdown is the event code for shutdown due to battery level too low.
	HosteventBatteryShutdown ECHostevent = 0x00010000
	// HosteventInvalid is the event code for invalid host event.
	HosteventInvalid ECHostevent = 0x80000000
)

Hostevent codes, copied from ec/include/ec_commands.h.

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 (
	ChargerVoltageMV          FloatControl = "ppchg5_mv"
	BatteryTemperatureCelsius FloatControl = "battery_tempc"
	VBusVoltage               FloatControl = "vbus_voltage"
	VBusPower                 FloatControl = "vbus_power"
)

These are the Servo controls with floating-point values.

type HPDLevelValue

type HPDLevelValue string

HPDLevelValue is a type for storing a type-c alt state hpd level

const (
	HPDHigh HPDLevelValue = "h"
	HPDLow  HPDLevelValue = "l"
	HPDExt  HPDLevelValue = "ext"
	HPDirq  HPDLevelValue = "irq"
)

Supported hpd levels

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"
	BatteryDesignVoltageDesignMV IntControl = "battery_voltage_design_mv"
	BatteryFullDesignMAH         IntControl = "battery_full_design_mah"
	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 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"
	CtrlR        KeypressControl = "ctrl_r"
	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"
	SysRQR       KeypressControl = "sysrq_r"
	PowerKey     KeypressControl = "power_key"
	Pwrbutton    KeypressControl = "pwr_button"
	USBEnter     KeypressControl = "usb_keyboard_enter_key"
	ArrowUp      KeypressControl = "arrow_up"
	ArrowDown    KeypressControl = "arrow_down"
)

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 MultiFunctionPref

type MultiFunctionPref int

MultiFunctionPref is a type for storing a type-c alt state mf pref

const (
	MFPrefEnable  MultiFunctionPref = 1
	MFPrefDisable MultiFunctionPref = 0
)

supported mf pref modes

type OnOffControl

type OnOffControl string

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

const (
	ECUARTCapture   OnOffControl = "ec_uart_capture"
	ECUARTTimestamp OnOffControl = "ec_uart_timestamp"
	ECUARTFlush     OnOffControl = "ec_uart_flush"
)

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

const (
	BottomUSBKeyPwr OnOffControl = "bottom_usbkey_pwr"
	CCDCPUFWSPI     OnOffControl = "ccd_cpu_fw_spi"
	CCDKeepaliveEn  OnOffControl = "ccd_keepalive_en"
	CCDState        OnOffControl = "ccd_state"
	CPUFWSPI        OnOffControl = "cpu_fw_spi"
	ColdReset       OnOffControl = "cold_reset"
	DTSMode         OnOffControl = "servo_dts_mode"
	DutEthPwrEn     OnOffControl = "dut_eth_pwr_en"
	I2CMuxEn        OnOffControl = "i2c_mux_en"
	InitKeyboard    OnOffControl = "init_keyboard"
	RecMode         OnOffControl = "rec_mode"
	TopUSBKeyPwr    OnOffControl = "top_usbkey_pwr"
	USBKeyboard     OnOffControl = "init_usb_keyboard"
)

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

const (
	APUARTCapture OnOffControl = "cpu_uart_capture"
)

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

const (
	GSCUARTCapture OnOffControl = "gsc_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 PDState

type PDState struct {
	Version    TCPMVersion
	Port       int
	Polarity   pdPolarityValue
	Connection connectionValue
	PowerRole  powerRoleValue
	DataRole   dataRoleValue
	VConn      bool

	// Warning: PEStateName and PEFlags have different values and meanings
	// depending on TCPM version. Avoid accessing these members directly
	// and create a method such as IsSourceReady() to obtain the desired
	// info in a version-safe manner, referencing `.Version` if necessary.
	// Not used in PDC DUTs.
	PEStateName string
	PEFlags     uint32

	TCStateName string // TCPMv2 DUTs only
	TCFlags     uint32 // TCPMv2 DUTs only

	PDCState string // PDC DUTs only
}

PDState encapsulates the full PD port state on an EC or Servo

func (*PDState) Compare

func (pdState *PDState) Compare(pdStateAfter *PDState) error

Compare verifies that the connection state, power role, and data role between two PDState objects is equivalent and returns nil if so, or an error message.

func (*PDState) GetStateName

func (pdState *PDState) GetStateName() string

GetStateName returns the reported PD state name for a PDC or TCPM DUT. Note: each TCPMVersion has its own set of states. Use this only for logging or like-for-like comparison --never against fixed constants. Use IsSourceReady(), IsSinkReady(), or IsPDReady() helper methods for checking states instead.

func (*PDState) IsPDReady

func (pdState *PDState) IsPDReady() bool

IsPDReady returns true if the port is in a source- or sink-ready state

func (*PDState) IsSinkReady

func (pdState *PDState) IsSinkReady() bool

IsSinkReady returns true if port is in a sink-ready state

func (*PDState) IsSourceReady

func (pdState *PDState) IsSourceReady() bool

IsSourceReady returns true if port is in a source-ready state

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, sshClient *crypto_ssh.Client) (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) SeparatedOutputCommand

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

SeparatedOutputCommand execs a command as the root user, and returns stdout, stderr and err.

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) CheckECActiveCopyMatch

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

CheckECActiveCopyMatch polls to check if the EC active copy matches the expected one.

func (*Servo) CheckGSCBootMode

func (s *Servo) CheckGSCBootMode(ctx context.Context, expectedModes []string) error

CheckGSCBootMode verifies that the boot mode as reported by GSC's ec_comm command is as expected.

func (*Servo) CheckGSCCommandOutput

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

CheckGSCCommandOutput is a wrapper function to that runs a GSC command and ensures all Python regex patterns appear at least once in the response. This function will throw a pretty printed error otherwise.

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) DUTPDPort

func (s *Servo) DUTPDPort() int

DUTPDPort returns the active PD port on the DUT.

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) DisablePDConsoleDebug

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

DisablePDConsoleDebug disables PD console debugging on the DUT.

func (*Servo) DisableServoPDConsoleDebug

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

DisableServoPDConsoleDebug disables PD console debugging on the Servo

func (*Servo) ECHibernate

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

ECHibernate puts the EC into hibernation mode, after removing the servo watchdogs.

func (*Servo) Echo

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

Echo calls the Servo echo method.

func (*Servo) EnablePDConsoleDebug

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

EnablePDConsoleDebug enables PD console debugging level 2 on the DUT.

func (*Servo) EnableServoConsoleChannel

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

EnableServoConsoleChannel enables the provided console log channel (and turns all but the console CLI off)

func (*Servo) EnableServoPDConsoleDebug

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

EnableServoPDConsoleDebug enables PD console debugging level 2 on the Servo

func (*Servo) EnableUARTCapture

func (s *Servo) EnableUARTCapture(ctx context.Context, uart OnOffControl) (closeUART func(ctx context.Context) error, err error)

EnableUARTCapture enables capture on the specified UART control, unless it is already enabled. Make sure you call the close function in a deferred call. I.e. closeUART, err := s.EnableUARTCapture(ctx, ECUARTCapture) if err != nil { ... } defer func() { retErr = errors.Join(retErr, closeUART(ctx)) } ... Do a reboot or something ... err = s.PollForRegexp(ctx, ECUARTStream, regex, time.Minute) if err != nil { ... }

func (*Servo) FindECChanMask

func (s *Servo) FindECChanMask(ctx context.Context, chanName ECChannelName) (maskVal string, retErr error)

FindECChanMask accepts an ec channel name, and runs ec 'chan' command to look for the corresponding mask value.

func (*Servo) GetAPState

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

GetAPState runs the 'ccdstate' command in the gsc console, and returns information about AP's status as follows: 1. "off", which means that the ap is off. 2. "on (K)", which means that the dut has jumped into kernel. 3. "on (F)", which means that the dut is on firmware.

func (*Servo) GetBatteryChargeMAH

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

GetBatteryChargeMAH returns the battery's charge in mAh.

func (*Servo) GetBatteryDesignVoltageDesignMV

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

GetBatteryDesignVoltageDesignMV returns the battery's design voltage in mV

func (*Servo) GetBatteryFullChargeMAH

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

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

func (*Servo) GetBatteryFullDesignMAH

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

GetBatteryFullDesignMAH returns the battery's full design capacity 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) GetCCDCapability

func (s *Servo) GetCCDCapability(ctx context.Context, capability CCDCap) (int, string, error)

GetCCDCapability will return the current state of a specific CCD capability. Possible states are:

0 = Default
1 = Always
2 = UnlessLocked
3 = IfOpened

It will also return "Y" if the capability is accessible, and "-" otherwise.

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) GetDUTDualRoleState

func (s *Servo) GetDUTDualRoleState(ctx context.Context, port int) (USBPdDualRoleValue, error)

GetDUTDualRoleState accepts a port ID and checks for the PD DRP status of this port.

func (*Servo) GetDUTPDState

func (s *Servo) GetDUTPDState(ctx context.Context) (*PDState, error)

GetDUTPDState returns PD state info for the PD port on the EC/DUT.

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) GetGscUSBSerialNumberDescriptor

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

GetGscUSBSerialNumberDescriptor uses the GSC `sysinfo` command to get the `DEV_ID`s for the device and format them as a USB serial number descriptor that can be used in the `flashrom` command. This is useful when many GSCs are attached to a host and we want to target our device specifically.

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) GetOnOff

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

GetOnOff gets an OnOffControl as a bool.

func (*Servo) GetPDAdapterSrcCaps

func (s *Servo) GetPDAdapterSrcCaps(ctx context.Context) ([]SrcCap, error)

GetPDAdapterSrcCaps gets the attached charger's source caps

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) GetServoChargerPortPDState

func (s *Servo) GetServoChargerPortPDState(ctx context.Context) (*PDState, error)

GetServoChargerPortPDState returns the state of the PD port on the servo that connects to the charger (C0)

func (*Servo) GetServoPDState

func (s *Servo) GetServoPDState(ctx context.Context) (*PDState, error)

GetServoPDState returns the state of the PD port on the servo that connects to the DUT (C1)

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) GetServodVersion

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

GetServodVersion gets the version of servod being used.

func (*Servo) GetSkuID

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

GetSkuID runs the ec command 'cbi' and checks for the sku-id.

func (*Servo) GetString

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

GetString returns the value of a specified control.

func (*Servo) GetStringArray

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

GetStringArray returns a result array of strings from a specified control string.

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) HasC2D2

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

HasC2D2 checks if the servo has a C2D2 connection.

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) HasServoMicro

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

HasServoMicro checks if the servo has a servo_micro connection.

func (*Servo) IsDUTPDSoftResetSupported

func (s *Servo) IsDUTPDSoftResetSupported() bool

IsDUTPDSoftResetSupported determines wither the attached DUT supports initiating PD soft resets

func (*Servo) IsServoTypeC

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

IsServoTypeC checks if the dut connection type is type-c.

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) LockCCD

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

LockCCD locks the CCD console by sending a GSC command.

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) PollForRegexp

func (s *Servo) PollForRegexp(ctx context.Context, uart StringControl, toFind *regexp.Regexp, timeout time.Duration) (bool, error)

PollForRegexp polls a UART for one or more strings for up to timeout, returning nil if found. You may need to call EnableUARTCapture() before rebooting to capture boot time logs.

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) PressECBtnVerifyOutput

func (s *Servo) PressECBtnVerifyOutput(ctx context.Context, button DetachableECButton, duration int, ecChanMasks map[ECChannelName]string) error

PressECBtnVerifyOutput sends a DetachableECButton and verifies in the output that the button was successfully pressed and released. Call FindECChanMask first to find the mask values for ECChanKeyboard and ECChanSwitch, and pass them to PressECBtnVerifyOutput.

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) PressKeys

func (s *Servo) PressKeys(ctx context.Context, keys []string, value KeypressDuration) error

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

func (*Servo) PressUSBKey

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

PressUSBKey sends an arbitrary USB KB key for a KeypressDuration.

func (*Servo) RemoveCCDWatchdogs

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

RemoveCCDWatchdogs enumerates over all servo devices, removes the watchdogs and enables CCDKeepaliveEn for any CCD devices.

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) RequireChargerAttached

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

RequireChargerAttached verifies that the Servo charger port (#0) is an active sink

func (*Servo) RequireDUTPDInfo

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

RequireDUTPDInfo allocates and caches the fixed information about the PD port under test.

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) RequirePDTester

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

RequirePDTester verifies that the servo has both sides of the PD connection.

func (*Servo) RestoreDUTConsoleChannelMask

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

RestoreDUTConsoleChannelMask stores the current console channel mask on the DUT

func (*Servo) RestorePDDataRole

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

RestorePDDataRole restores DUT PD port state to the DFP role.

func (*Servo) RestorePDPort

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

RestorePDPort restores DUT PD port state to the SNK role.

func (*Servo) RunAPCommand

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

RunAPCommand runs the given command on the AP-firmware console on the device.

func (*Servo) RunAPCommandGetOutput

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

RunAPCommandGetOutput runs the given command on the AP 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. It is recommended to send "chan save", "chan 0" just before and "chan restore" afterwards to prevent other logging from interrupting your command. (RunECCommandGetOutputNoConsoleLogs() can handle this for you)

func (*Servo) RunECCommandGetOutputNoConsoleLogs

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

RunECCommandGetOutputNoConsoleLogs works like RunECCommandGetOutput but automatically disables all console logging, which could interfere with capturing command output.

func (*Servo) RunECCommandGetOutputNoConsoleLogsAllowRetries

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

RunECCommandGetOutputNoConsoleLogsAllowRetries works like RunECCommandGetOutputNoConsoleLogs but allows the command to be retried up to twice if unsuccessful.

func (*Servo) RunGSCCommand

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

RunGSCCommand runs the given command on the GSC on the device.

func (*Servo) RunGSCCommandGetOutput

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

RunGSCCommandGetOutput runs the given command on the GSC on the device and returns the output matching patterns.

func (*Servo) RunServoCommand

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

RunServoCommand runs the given command on the servo console.

func (*Servo) RunServoCommandGetOutput

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

RunServoCommandGetOutput runs the given command on the servo v4 UART and returns the output matching patterns.

func (*Servo) RunTabletModeCommandGetOutput

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

RunTabletModeCommandGetOutput runs EC commands to set tablet mode and returns the output matching pattern for the resulting tablet mode state. Before calling RunTabletModeCommand(), a test can call h.GetECTabletLaptopModeCommand() to determine the corresponding command.

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) SaveDUTConsoleChannelMask

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

SaveDUTConsoleChannelMask stores the current console channel mask on the DUT

func (*Servo) SendDataSwapRequest

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

SendDataSwapRequest sends data swap request to be initiated by the DUT.

func (*Servo) SendPowerSwapRequest

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

SendPowerSwapRequest sends power swap request to be initiated by the DUT.

func (*Servo) SendRequestSourceVoltage

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

SendRequestSourceVoltage sends a voltage request to the source that's initiated by the DUT.

func (*Servo) ServoCcOff

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

ServoCcOff runs the `cc off` console command on the Servo.

func (*Servo) ServoCcOn

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

ServoCcOn runs the `cc on` console command on the Servo.

func (*Servo) ServoGetConnectedStateAfterCCReconnect

func (s *Servo) ServoGetConnectedStateAfterCCReconnect(ctx context.Context, disconnectTime time.Duration) (string, error)

ServoGetConnectedStateAfterCCReconnect get the connected state after disconnect/reconnect using PDTester

PDTester supports a feature which simulates a USB Type C disconnect and reconnect. It returns the first connected state (either source or sink) after reconnect.

@param disconnectTime: Time in seconds for disconnect period. @returns: The connected PD state.

func (*Servo) ServoGetDualRoleState

func (s *Servo) ServoGetDualRoleState(ctx context.Context) (USBPdDualRoleValue, error)

ServoGetDualRoleState accepts a port ID and checks for the PD DRP status of this port.

func (*Servo) ServoSendDataSwapRequest

func (s *Servo) ServoSendDataSwapRequest(ctx context.Context) (pdControlMsgType, error)

ServoSendDataSwapRequest initiates a data swap request from the servo's PD port.

func (*Servo) ServoSendPowerSwapRequest

func (s *Servo) ServoSendPowerSwapRequest(ctx context.Context) (pdControlMsgType, error)

ServoSendPowerSwapRequest sends power swap request to be initiated by the Servo.

func (*Servo) ServoSetDPConfigs

func (s *Servo) ServoSetDPConfigs(ctx context.Context, config *TypeCInfo, mfPref MultiFunctionPref) error

ServoSetDPConfigs sets the DP configs for the DUT connection

func (*Servo) ServoSetDualRole

func (s *Servo) ServoSetDualRole(ctx context.Context, val USBPdDualRoleValue) error

ServoSetDualRole sets the PD DRP status of this port

func (*Servo) ServoSetUSBVersion3

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

ServoSetUSBVersion3 sets the DUT USB connection as version 2.0 or 3.0

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) SetCCDCapability

func (s *Servo) SetCCDCapability(ctx context.Context, capabilities map[CCDCap]CCDCapState) error

SetCCDCapability will try to set a CCD capability to a specific state. Possible states are:

Default
Always
UnlessLocked
IfOpened

func (*Servo) SetDUTConsoleChannelMask

func (s *Servo) SetDUTConsoleChannelMask(ctx context.Context, mask uint32) error

SetDUTConsoleChannelMask sets a give console channel mask on the EC

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) SetDualroleState

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

SetDualroleState sets the dual-role state of the DUT

func (*Servo) SetECChanMasks

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

SetECChanMasks accepts a map of ec channel names with their masks, and sets them.

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) SetHPD

func (s *Servo) SetHPD(ctx context.Context, HPDLevel HPDLevelValue) error

SetHPD sets the HPD value for an active dp-alt connection

func (*Servo) SetHostevent

func (s *Servo) SetHostevent(ctx context.Context, event ECHostevent) error

SetHostevent sets host event in ec console using `hostevet set` cmd.

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) SetPDCommunication

func (s *Servo) SetPDCommunication(ctx context.Context, value OnOffValue) error

SetPDCommunication sets servo_pd_comm to the specified value, if it is not set to that value already.

func (*Servo) SetPDPowerRole

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

SetPDPowerRole sets the PD power role for a PD port on the DUT.

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) SetPDTrySrc

func (s *Servo) SetPDTrySrc(ctx context.Context, port, enable int) (bool, error)

SetPDTrySrc attempts to set PD TrySrc enable or disabled. returns True is setting was successful, False if feature not supported by the device, or not set as desired.

func (*Servo) SetPlug

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

SetPlug sets the PLug status for an active dp-alt connection

func (*Servo) SetPowerState

func (s *Servo) SetPowerState(ctx context.Context, value PowerStateValue) (retErr 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) SetTestlab

func (s *Servo) SetTestlab(ctx context.Context, option TestlabState) error

SetTestlab will perform the required power button presses to disable or enable CCD testlab mode.

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) TriggerPDHardReset

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

TriggerPDHardReset triggers a USB-PD Hard Reset from the EC/DUT-side

func (*Servo) TriggerPDSoftReset

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

TriggerPDSoftReset triggers a USB-PD Soft Reset from the EC/DUT-side

func (*Servo) TriggerServoPDHardReset

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

TriggerServoPDHardReset triggers a USB-PD Hard Reset from the Servo-side

func (*Servo) TriggerServoPDSoftReset

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

TriggerServoPDSoftReset triggers a USB-PD Soft Reset from the Servo-side

func (*Servo) VerifyPins

func (s *Servo) VerifyPins(input, output *TypeCInfo, mfPref MultiFunctionPref) error

VerifyPins checks that the type-c pin setting is the same as the assignment

func (*Servo) WaitFirmwareKeyboardNoCmd

func (s *Servo) WaitFirmwareKeyboardNoCmd(ctx context.Context, timeout time.Duration) (retErr error)

WaitFirmwareKeyboardNoCmd waits until the DUT is in firmware with keyboard enabled On entry the DUT can be in firmware or kernel. This function works by waiting for the "KB enable" message shown by the EC when it boots. It does not issue commands to the EC.

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.

type SrcCap

type SrcCap struct {
	Voltage int // Voltage in mV
	Current int // Current in mA
}

SrcCap stores the voltage and current values of a PDO.

type StringControl

type StringControl string

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

const (
	APUARTCmd    StringControl = "cpu_uart_cmd"
	APUARTRegexp StringControl = "cpu_uart_regexp"
	APUARTStream StringControl = "cpu_uart_stream"
)

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

const (
	GSCCCDLevel     StringControl = "gsc_ccd_level"
	GSCECReset      StringControl = "gsc_ec_reset"
	GSCECResetPulse StringControl = "gsc_ecrst_pulse"
	GSCTestlab      StringControl = "gsc_testlab"
	GSCUARTCmd      StringControl = "gsc_uart_cmd"
	GSCUARTRegexp   StringControl = "gsc_uart_regexp"
	GSCUARTStream   StringControl = "gsc_uart_stream"
	GSCVersion      StringControl = "gsc_version"
)

These are the GSC 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"
	ArbKeysConfig         StringControl = "arb_keys_config"
	BottomUSBKeyMux       StringControl = "bottom_usbkey_mux"
	ColdResetSelect       StringControl = "cold_reset_select"
	DUTUSB3EnV4p1         StringControl = "servo_v4p1_dut_usb3_en"
	DUTVoltageMV          StringControl = "dut_voltage_mv"
	Devices               StringControl = "devices"
	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"
	PDCommunication       StringControl = "servo_pd_comm"
	PowerState            StringControl = "power_state"
	PwrButtonCtrl         StringControl = "pwr_button"
	SecondUSBKeyDirection StringControl = "second_usbkey_direction"
	ServoDUTSBU1MV        StringControl = "servo_dut_sbu1_mv"
	ServoDUTSBU2MV        StringControl = "servo_dut_sbu2_mv"
	SupportCrosECComm     StringControl = "supports_cros_ec_communication"
	TopUSBKeyMux          StringControl = "top_usbkey_mux"
	Type                  StringControl = "servo_type"
	UARTCmd               StringControl = "servo_uart_cmd"
	UARTRegexp            StringControl = "servo_uart_regexp"
	USBArbKey             StringControl = "usb_arb_key"
	USBArbKeyConfig       StringControl = "usb_arb_key_config"
	USBCPolarity          StringControl = "usbc_polarity"
	WarmReset             StringControl = "warm_reset"
	Watchdog              StringControl = "watchdog"
	WatchdogAdd           StringControl = "watchdog_add"
	WatchdogRemove        StringControl = "watchdog_remove"
	PDAdapterSrcCaps      StringControl = "ada_srccaps"

	// 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 TCPMVersion

type TCPMVersion int

TCPMVersion is a type for denoting a TCPM stack version

const (
	TCPMv1 TCPMVersion = 1
	TCPMv2 TCPMVersion = 2
	PDC    TCPMVersion = 3
)

Supported TCPM Versions

type TabletModeCmdUnsupportedErr

type TabletModeCmdUnsupportedErr struct {
	*errors.E
}

TabletModeCmdUnsupportedErr is the error returned by RunTabletModeCommandGetOutput when the ec command is found unsupported. To detect this error, use something like: if _, ok := err.(*TabletModeCmdUnsupportedErr); ok {}

type TestlabState

type TestlabState string

TestlabState contains possible ccd testlab states.

const (
	Enable  TestlabState = "on"
	Disable TestlabState = "off"
)

Possible testlab states.

type TypeCInfo

type TypeCInfo struct {
	DPMode   DPModeValue
	PinsCDEF string
}

TypeCInfo stores information retrieved from probing a type-c connection by the DUT.

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 USBPdDualRoleValue

type USBPdDualRoleValue string

USBPdDualRoleValue contains a gettable/settable string accepted by the ec command, 'pd <port> dualrole'.

const (
	USBPdDualRoleOn     USBPdDualRoleValue = "on"
	USBPdDualRoleOff    USBPdDualRoleValue = "off"
	USBPdDualRoleFreeze USBPdDualRoleValue = "freeze"
	USBPdDualRoleSink   USBPdDualRoleValue = "force sink"
	USBPdDualRoleSource USBPdDualRoleValue = "force source"
)

These are acceptable states for the USB PD dual-role.

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.

Directories

Path Synopsis
Package ctxutil provides convenience functions for working with context.Context objects.
Package ctxutil provides convenience functions for working with context.Context objects.
Package errors provides basic utilities to construct errors.
Package errors provides basic utilities to construct errors.
stack
Package stack provides a utility to capture and format a stack trace.
Package stack provides a utility to capture and format a stack trace.
Package exec is common code used by both ssh and testexec for command execution.
Package exec is common code used by both ssh and testexec for command execution.
Package logging provides the standard logging mechanism for Tast.
Package logging provides the standard logging mechanism for Tast.
loggingtest
Package loggingtest provides logging utilities for unit tests.
Package loggingtest provides logging utilities for unit tests.
Package shutil provides shell-related utility functions.
Package shutil provides shell-related utility functions.
ssh
Package ssh provides means to communicate with remote host through SSH.
Package ssh provides means to communicate with remote host through SSH.
linuxssh
Package linuxssh provides Linux specific operations conducted via SSH
Package linuxssh provides Linux specific operations conducted via SSH
Package sshtest provides support code for testing the host package.
Package sshtest provides support code for testing the host package.
Package testexec is a wrapper of the standard os/exec package optimized for use cases of Tast.
Package testexec is a wrapper of the standard os/exec package optimized for use cases of Tast.
Package testing provides public API for tests.
Package testing provides public API for tests.
Package testingutil is a kitchen sink of utilities shared by Tast tests and Tast framework.
Package testingutil is a kitchen sink of utilities shared by Tast tests and Tast framework.
Package testutil provides support code for unit tests.
Package testutil provides support code for unit tests.
Package xmlrpc implements the XML-RPC client library.
Package xmlrpc implements the XML-RPC client library.

Jump to

Keyboard shortcuts

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