blob: 15e136cef6b2d6b3420b3eb3d0130af00ea2a442 [file] [log] [blame]
// Copyright 2021 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package chameleon
import (
// Port holds the chameleon board port information.
type Port struct {
ch *Chameleon
id int
// NewPort creates a new port object for the chameleon board.
func (ch *Chameleon) NewPort(ctx context.Context, portID int) (*Port, error) {
for _, p := range ch.ports {
if p == portID {
return &Port{ch: ch, id: portID}, nil
return nil, errors.Errorf("port %d is not supported on the chameleon board", portID)
// Plug calls the Chameleon plug method.
func (p *Port) Plug(ctx context.Context) error {
return, xmlrpc.NewCall("Plug",
// Unplug calls the Chameleon Unplug method.
func (p *Port) Unplug(ctx context.Context) error {
return, xmlrpc.NewCall("Unplug",
// WaitVideoInputStable calls the Chameleon WaitVideoInputStable method.
func (p *Port) WaitVideoInputStable(ctx context.Context, timeout time.Duration) error {
t := int(math.Ceil(timeout.Seconds())) // Convert to the least integer greater or equal.
var stable bool
if err :=, xmlrpc.NewCall("WaitVideoInputStable",, t), &stable); err != nil {
return err
if !stable {
return errors.New("video input has not been stable")
return nil