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 ¶
- func StartServo(ctx context.Context, servoHostPort, keyFile, keyDir string) (retErr error)
- type DUTController
- type OnOffControl
- type OnOffValue
- type PowerStateValue
- type Proxy
- type Servo
- func (s *Servo) Close(ctx context.Context) error
- func (s *Servo) GetOnOff(ctx context.Context, ctrl OnOffControl) (bool, 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) HasControl(ctx context.Context, ctrl string) (bool, error)
- func (s *Servo) IsServoV4(ctx context.Context) (bool, 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) SetStringTimeout(ctx context.Context, control StringControl, value string, ...) error
- func (s *Servo) WatchdogAdd(ctx context.Context, val WatchdogValue) error
- func (s *Servo) WatchdogRemove(ctx context.Context, val WatchdogValue) error
- type StringControl
- type WatchdogValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.
type Servo ¶
type Servo struct {
// contains filtered or unexported fields
}
Servo holds the servod connection information.
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 (*Servo) GetServoType ¶
GetServoType gets the type of the servo.
func (*Servo) GetServoVersion ¶
GetServoVersion gets the version of Servo being used.
func (*Servo) HasControl ¶
HasControl determines whether the Servo being used supports the given control.
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) 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.