servo

package
v0.0.0-...-b5d9cbe Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

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

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartServo

func StartServo(ctx context.Context, servoHostPort, keyFile, keyDir string) (retErr error)

StartServo start servod and verify every 2 second until it is ready. Add check to avoid repeated attempting.

Types

type DUTController

type DUTController string

DUTController is the active controller on a dual mode servo.

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

Parameters that can be passed to SetActiveDUTController().

type OnOffControl

type OnOffControl string

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

const (
	CCDState OnOffControl = "ccd_state"
)

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 PowerStateValue

type PowerStateValue string

A PowerStateValue is a string accepted by the PowerState control.

const (
	PowerStateReset PowerStateValue = "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:ssh:22) 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) 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 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 (*Servo) Close

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

Close performs Servo cleanup.

func (*Servo) GetOnOff

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

GetOnOff gets an OnOffControl as a bool.

func (*Servo) GetServoType

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

GetServoType gets the type of the servo.

func (*Servo) GetServoVersion

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

GetServoVersion gets the version of Servo being used.

func (*Servo) GetString

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

GetString returns the value of a specified control.

func (*Servo) 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) IsServoV4

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

IsServoV4 determines whether the Servo being used is v4.

func (*Servo) SetPowerState

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

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

func (*Servo) SetString

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

SetString sets a Servo control to a string value.

func (*Servo) 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) 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 (
	PowerState     StringControl = "power_state"
	Type           StringControl = "servo_type"
	WatchdogAdd    StringControl = "watchdog_add"
	WatchdogRemove StringControl = "watchdog_remove"
)

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

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