Documentation ¶
Overview ¶
Package hpsutil contains functionality used by the HPS tast tests.
Package hpsutil contains functionality used by the HPS tast tests.
Package hpsutil contains functionality used by the HPS tast tests.
Package hpsutil contains functionality used by the HPS tast tests.
Package hpsutil contains functionality used by the HPS tast tests.
Index ¶
- Constants
- func CheckHpsError(hctx *HpsContext) error
- func DecodePresenceResult(fullValue uint16) int
- func EnablePresence(hctx *HpsContext, feature string) (time.Duration, error)
- func EnsureLatestFirmware(hctx *HpsContext) error
- func GetNumberOfPresenceOps(hctx *HpsContext) (uint16, error)
- func GetPresenceResult(hctx *HpsContext, reg string) (int, error)
- func GetRegisterValue(hctx *HpsContext, register string) (uint16, error)
- func PercentileForSortedData(c []float64, percentile int) (float64, error)
- func Powerlog(ctx context.Context, csvFilename, boardFilename, scenarioFilename string, ...)
- func RunBuiltinI2CDetect(hctx *HpsContext) error
- func RunHpsTool(hctx *HpsContext, arg ...string) error
- func RunStatus(hctx *HpsContext) error
- func RunWithLog(hctx *HpsContext, outDir, logFilename string, cmdNum *int, args ...string) error
- func WaitForNPresenceOps(hctx *HpsContext, numOps int, feature string) ([]int, error)
- type DeviceType
- type HasHpsContext
- type HpsContext
- type PowerlogResult
Constants ¶
const ( // PersonPresentPageArchiveFilename the file name for persen present page. PersonPresentPageArchiveFilename = "person-present-page.tar.xz" // WaitNOpsBeforeStart How many ops to wait before starting to test after starting Chrome. // Since HPS has auto-exposure give it some time to figure the exposure. WaitNOpsBeforeStart = 10 // WaitNOpsBeforeExpectingPresenceChange How many ops to wait when changing from no person to person in frame or // vice versa. WaitNOpsBeforeExpectingPresenceChange = 1 // GetNOpsToVerifyPresenceWorks How many ops to run to ensure that presence model works reliably. GetNOpsToVerifyPresenceWorks = 10 )
const ( // DeviceTypeDevboard is Santa p2 board plugged using USB. DeviceTypeDevboard = iota // DeviceTypeBuiltin is the built-in HPS connected over i2c bus. DeviceTypeBuiltin )
const (
// P2PowerCycleFilename is the name of the script that power-cycles the p2 board.
P2PowerCycleFilename = "proto2-power-cycle.py"
)
Variables ¶
This section is empty.
Functions ¶
func CheckHpsError ¶
func CheckHpsError(hctx *HpsContext) error
CheckHpsError returns an error in case the HPS has seen an internal error.
func DecodePresenceResult ¶
DecodePresenceResult decodes a result of a presence operation: it's positive when a person is detected, and negative when no person is detected.
func EnablePresence ¶
func EnablePresence(hctx *HpsContext, feature string) (time.Duration, error)
EnablePresence power-cycles the HPS devboard and enables presence detection. TODO: fail the test if reg6 is not 0x0000 at any point in time? It takes ~2 minutes to enable presence after reset. 0 -- enable detecting one person 1 -- enable second person alert
func EnsureLatestFirmware ¶
func EnsureLatestFirmware(hctx *HpsContext) error
EnsureLatestFirmware flashes all firmware to the HPS board.
Prerequisites for Santa: 1. ./scripts/p2-stage0-run 2. cd mcu_rom/hps-factory && cargo run -- --mcp --one-time-init
func GetNumberOfPresenceOps ¶
func GetNumberOfPresenceOps(hctx *HpsContext) (uint16, error)
GetNumberOfPresenceOps return an increasing number of presence ops the HPS has executed. It's not guaranteed to start at 0 after power-cycle and is only valid if HPS is in presence mode.
func GetPresenceResult ¶
func GetPresenceResult(hctx *HpsContext, reg string) (int, error)
GetPresenceResult returns the decoded result of the last presence operation.
func GetRegisterValue ¶
func GetRegisterValue(hctx *HpsContext, register string) (uint16, error)
GetRegisterValue returns the integer value from the HPS register.
func PercentileForSortedData ¶
PercentileForSortedData returns the given percentile from c, or an error. Expects data to be sorted.
func Powerlog ¶
func Powerlog(ctx context.Context, csvFilename, boardFilename, scenarioFilename string, quit chan struct{}, result chan PowerlogResult)
Powerlog runs sweetberry power measurement for specified boardFilename and scenarioFilename, saves the resulting csvFilename, and parses it to the PowerlogResult.
func RunBuiltinI2CDetect ¶
func RunBuiltinI2CDetect(hctx *HpsContext) error
RunBuiltinI2CDetect runs i2cdetect to check in what state the HPS is.
func RunHpsTool ¶
func RunHpsTool(hctx *HpsContext, arg ...string) error
RunHpsTool runs the `hps device ...` command and writes both stdout and stderr to the log file.
func RunStatus ¶
func RunStatus(hctx *HpsContext) error
RunStatus runs the `hps status` command to help diagnose problems.
func RunWithLog ¶
func RunWithLog(hctx *HpsContext, outDir, logFilename string, cmdNum *int, args ...string) error
RunWithLog runs the specified command and writes both stdout and stderr to the log file. cmdNum is used to automatically generate a consistent numeric prefix.
func WaitForNPresenceOps ¶
func WaitForNPresenceOps(hctx *HpsContext, numOps int, feature string) ([]int, error)
WaitForNPresenceOps waits for the num of ops to be run.
Types ¶
type HasHpsContext ¶
type HasHpsContext interface {
HpsContext(ctx context.Context, outDir string) *HpsContext
}
HasHpsContext is an interface for fixture values that contain a HpsContext instance. It allows retrieval of the underlying HpsContext object.
type HpsContext ¶
type HpsContext struct { Ctx context.Context // Used as prefix for command logs. CmdNum int // String passed to the `hps` tool. Device string // Directory where the test results are stored. OutDir string // Ignore HPS error register errors when set to false. FailOnHPSErrorRegister bool DutConn *ssh.Conn // contains filtered or unexported fields }
HpsContext stores common information passed around when calling hps tool and flashing the devboards.
func NewHpsContext ¶
func NewHpsContext(ctx context.Context, p2PowerCycleFilename string, deviceType DeviceType, outDir string, dutConn *ssh.Conn) (*HpsContext, error)
NewHpsContext creates new HpsContext.
func (*HpsContext) HpsContext ¶
func (hctx *HpsContext) HpsContext(ctx context.Context, outDir string) *HpsContext
HpsContext returns the HpsContext instance. It implements the HasChrome interface.
func (*HpsContext) PowerCycle ¶
func (hctx *HpsContext) PowerCycle() error
PowerCycle power-cycles the HPS, and makes sure it's usable afterwards.
type PowerlogResult ¶
PowerlogResult returns all the power samples for all the columns returned by running powerlog.