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
- Variables
- func ConvertToStringArrayArray(ctx context.Context, stringList []interface{}) ([][]string, error)
- func ParseQuotedString(value string) (string, error)
- func ParseStringList(value string) ([]interface{}, error)
- type BoolControl
- type DUTConnTypeValue
- type DUTController
- type FWWPStateValue
- type FloatControl
- type HibernationOpt
- type IntControl
- type KBMatrixPair
- type KeypressControl
- type KeypressDuration
- type LidOpenValue
- type OnOffControl
- type OnOffValue
- type PDRoleValue
- type PowerStateValue
- type Proxy
- func (p *Proxy) Close(ctx context.Context)
- func (p *Proxy) GetFile(ctx context.Context, asRoot bool, remoteFile, localFile string) error
- func (p *Proxy) GetPort() int
- func (p *Proxy) InputCommand(ctx context.Context, asRoot bool, stdin io.Reader, name string, args ...string) error
- func (p *Proxy) NewForwarder(ctx context.Context, hostPort string) (*ssh.Forwarder, error)
- func (p *Proxy) OutputCommand(ctx context.Context, asRoot bool, name string, args ...string) ([]byte, error)
- func (p *Proxy) Proxied() bool
- func (p *Proxy) PutFiles(ctx context.Context, asRoot bool, fileMap map[string]string) error
- func (p *Proxy) Reconnect(ctx context.Context) error
- func (p *Proxy) RunCommand(ctx context.Context, asRoot bool, name string, args ...string) error
- func (p *Proxy) RunCommandQuiet(ctx context.Context, asRoot bool, name string, args ...string) error
- func (p *Proxy) Servo() *Servo
- type Servo
- func (s *Servo) CheckAndRunTabletModeCommand(ctx context.Context, command string) (string, error)
- func (s *Servo) CheckUnresponsiveEC(ctx context.Context) error
- func (s *Servo) Close(ctx context.Context) error
- func (s *Servo) CloseLid(ctx context.Context) error
- func (s *Servo) DUTVoltageMV(ctx context.Context) (string, error)
- func (s *Servo) ECHibernate(ctx context.Context, option HibernationOpt) error
- func (s *Servo) ECPressKey(ctx context.Context, key string) error
- func (s *Servo) Echo(ctx context.Context, message string) (string, error)
- func (s *Servo) GetBatteryChargeMAH(ctx context.Context) (int, error)
- func (s *Servo) GetBatteryFullChargeMAH(ctx context.Context) (int, error)
- func (s *Servo) GetBool(ctx context.Context, control BoolControl) (bool, error)
- func (s *Servo) GetCCDSerial(ctx context.Context) (string, error)
- func (s *Servo) GetChargerAttached(ctx context.Context) (bool, error)
- func (s *Servo) GetDUTConnectionType(ctx context.Context) (DUTConnTypeValue, error)
- func (s *Servo) GetECChip(ctx context.Context) (string, error)
- func (s *Servo) GetECFlashSize(ctx context.Context) (int, error)
- func (s *Servo) GetECSystemPowerState(ctx context.Context) (string, error)
- func (s *Servo) GetFloat(ctx context.Context, control FloatControl) (float64, error)
- func (s *Servo) GetInt(ctx context.Context, control IntControl) (int, error)
- func (s *Servo) GetKBBacklight(ctx context.Context) (int, error)
- func (s *Servo) GetKeyRowCol(key string) (int, int, error)
- func (s *Servo) GetOnOff(ctx context.Context, ctrl OnOffControl) (bool, error)
- func (s *Servo) GetPDCommunication(ctx context.Context) (string, error)
- func (s *Servo) GetPDRole(ctx context.Context) (PDRoleValue, error)
- func (s *Servo) GetQuotedString(ctx context.Context, control StringControl) (string, error)
- func (s *Servo) GetServoSerials(ctx context.Context) (map[string]string, error)
- func (s *Servo) GetServoType(ctx context.Context) (string, error)
- func (s *Servo) GetServoVersion(ctx context.Context) (string, error)
- func (s *Servo) GetString(ctx context.Context, control StringControl) (string, error)
- func (s *Servo) GetStringList(ctx context.Context, control StringControl) ([]interface{}, error)
- func (s *Servo) GetStringTimeout(ctx context.Context, control StringControl, timeout time.Duration) (string, error)
- func (s *Servo) GetUSBMuxState(ctx context.Context) (USBMuxState, error)
- func (s *Servo) HasCCD(ctx context.Context) (bool, error)
- func (s *Servo) HasControl(ctx context.Context, ctrl string) (bool, error)
- func (s *Servo) HasKBBacklight(ctx context.Context) bool
- func (s *Servo) IsServoV4(ctx context.Context) (bool, error)
- func (s *Servo) KeypressWithDuration(ctx context.Context, control KeypressControl, value KeypressDuration) error
- func (s *Servo) LidOpenState(ctx context.Context) (string, error)
- func (s *Servo) OpenCCD(ctx context.Context) error
- func (s *Servo) OpenLid(ctx context.Context) error
- func (s *Servo) PowerNormalPress(ctx context.Context) (bool, error)
- func (s *Servo) PreferDebugHeader(ctx context.Context) (bool, error)
- func (s *Servo) PressKey(ctx context.Context, key string, value KeypressDuration) error
- func (s *Servo) RequireCCD(ctx context.Context) error
- func (s *Servo) RequireDebugHeader(ctx context.Context) error
- func (s *Servo) RunCR50Command(ctx context.Context, cmd string) error
- func (s *Servo) RunCR50CommandGetOutput(ctx context.Context, cmd string, patterns []string) ([][]string, error)
- func (s *Servo) RunECCommand(ctx context.Context, cmd string) error
- func (s *Servo) RunECCommandGetOutput(ctx context.Context, cmd string, patterns []string) ([][]string, error)
- func (s *Servo) RunUSBCDPConfigCommand(ctx context.Context, args ...string) error
- func (s *Servo) SetActChgPort(ctx context.Context, port string) error
- func (s *Servo) SetActiveDUTController(ctx context.Context, adc DUTController) error
- func (s *Servo) SetCC(ctx context.Context, val OnOffValue) error
- func (s *Servo) SetDUTPDDataRole(ctx context.Context, role USBCDataRole) error
- func (s *Servo) SetFWWPState(ctx context.Context, value FWWPStateValue) error
- func (s *Servo) SetInt(ctx context.Context, control IntControl, value int) error
- func (s *Servo) SetKBBacklight(ctx context.Context, percent int) error
- func (s *Servo) SetOnOff(ctx context.Context, ctrl OnOffControl, value OnOffValue) error
- func (s *Servo) SetPDRole(ctx context.Context, newRole PDRoleValue) error
- func (s *Servo) SetPowerState(ctx context.Context, value PowerStateValue) error
- func (s *Servo) SetString(ctx context.Context, control StringControl, value string) error
- func (s *Servo) SetStringAndCheck(ctx context.Context, control StringControl, value string) error
- func (s *Servo) SetStringList(ctx context.Context, control StringControl, values []string) error
- func (s *Servo) SetStringTimeout(ctx context.Context, control StringControl, value string, ...) error
- func (s *Servo) SetUSBMuxState(ctx context.Context, value USBMuxState) error
- func (s *Servo) ToggleOffOn(ctx context.Context, ctrl OnOffControl) error
- func (s *Servo) ToggleOnOff(ctx context.Context, ctrl OnOffControl) error
- func (s *Servo) WatchdogAdd(ctx context.Context, val WatchdogValue) error
- func (s *Servo) WatchdogRemove(ctx context.Context, val WatchdogValue) error
- type StringControl
- type USBCDataRole
- type USBMuxState
- type WatchdogValue
Constants ¶
const ( Open string = "open" Lock string = "lock" Unlock string = "unlock" )
CCD levels
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 ¶
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 ¶
ConvertToStringArrayArray takes a stringList from GetStringList and converts it to [][]string
func ParseQuotedString ¶
ParseQuotedString returns a new string with the quotes and escaped chars from `value` removed.
func ParseStringList ¶
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" 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 ¶
func Dur(dur time.Duration) KeypressDuration
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) 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 ¶
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) RunCommand ¶
RunCommand execs a command on the servo host, optionally as root.
type Servo ¶
type Servo struct {
// contains filtered or unexported fields
}
Servo holds the servod connection information.
func Default ¶
Default creates a Servo object for communicating with a local servod instance using the default port.
func New ¶
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 ¶
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 ¶
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 ¶
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) DUTVoltageMV ¶
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 ¶
ECPressKey simulates a keypress on the DUT from the servo using kbpress.
func (*Servo) GetBatteryChargeMAH ¶
GetBatteryChargeMAH returns the battery's charge in mAh.
func (*Servo) GetBatteryFullChargeMAH ¶
GetBatteryFullChargeMAH returns the battery's last full charge in mAh.
func (*Servo) GetCCDSerial ¶
GetCCDSerial returns the serial number of the CCD interface.
func (*Servo) GetChargerAttached ¶
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) GetECFlashSize ¶
GetECFlashSize returns the size of EC in KB e.g. 512
func (*Servo) GetECSystemPowerState ¶
GetECSystemPowerState returns the power state, like "S0" or "G3"
func (*Servo) GetKBBacklight ¶
GetKBBacklight gets the DUT keyboards backlight value in percent (0 - 100).
func (*Servo) GetKeyRowCol ¶
GetKeyRowCol returns the key row and column for kbpress cmd
func (*Servo) GetPDCommunication ¶
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 ¶
GetQuotedString parses the value of a control as a quoted string
func (*Servo) GetServoSerials ¶
GetServoSerials returns a map of servo serial numbers. Interesting map keys are "ccd", "main", "servo_micro", but there are others also.
func (*Servo) GetServoType ¶
GetServoType gets the type of the servo.
func (*Servo) GetServoVersion ¶
GetServoVersion gets the version of Servo being used.
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) HasControl ¶
HasControl determines whether the Servo being used supports the given control.
func (*Servo) HasKBBacklight ¶
HasKBBacklight checks if the DUT keyboards has backlight functionality.
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 ¶
LidOpenState checks whether DUT's lid is open or closed, and returns yes/no.
func (*Servo) OpenCCD ¶
OpenCCD checks if a CCD connection exists, and then opens CCD if it's locked.
func (*Servo) PowerNormalPress ¶
PowerNormalPress calls the Servo power_normal_press method.
func (*Servo) PreferDebugHeader ¶
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 ¶
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 ¶
RequireCCD verifies that the servo has a CCD connection, and switches to it for dual v4 servos.
func (*Servo) RequireDebugHeader ¶
RequireDebugHeader verifies that the servo has a servo_micro or C2D2 connection, and switches to it for dual v4 servos.
func (*Servo) RunCR50Command ¶
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 ¶
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 ¶
RunUSBCDPConfigCommand executes the "usbc_action dp" command with the specified args on the servo console.
func (*Servo) SetActChgPort ¶
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) SetKBBacklight ¶
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) SetStringAndCheck ¶
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 ¶
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.