ti50

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package ti50 implements shared libraries for ti50 testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Demo

func Demo(ctx context.Context, board DevBoard, image string) error

Demo uses some of the CrOSImage to control the board. Image is optional, will demo on existing image if set to "".

func DemoCommand

func DemoCommand(ctx context.Context, i *CrOSImage, cmd string) error

DemoCommand demos the Command method.

func DemoHelp

func DemoHelp(ctx context.Context, i *CrOSImage) error

DemoHelp demos the Help method.

func DemoRawCommand

func DemoRawCommand(ctx context.Context, i *CrOSImage, cmd string, re *regexp.Regexp) error

DemoRawCommand demos the RawCommand method.

func ListConnectedUltraDebugTargets

func ListConnectedUltraDebugTargets(ctx context.Context) ([]string, error)

ListConnectedUltraDebugTargets finds list of UltraDebug targets connected.

func ParseUltraDebugTargets

func ParseUltraDebugTargets(devs string) []string

ParseUltraDebugTargets extracts list of UltraDebug target ports from device file listings.

Types

type Andreiboard

type Andreiboard struct {
	// contains filtered or unexported fields
}

Andreiboard contains common implementations boards.

func NewAndreiboard

func NewAndreiboard(bufMax int, portOpener serial.PortOpener, spiFlash string) *Andreiboard

NewAndreiboard creates a new port, bufMax should be set to the max number of bytes read that are not yet matched by ReadSerialSubmatch.

func (*Andreiboard) Close

func (a *Andreiboard) Close(ctx context.Context) error

Close closes the console port.

func (*Andreiboard) FlushSerial

func (a *Andreiboard) FlushSerial(ctx context.Context) error

FlushSerial flushes un-read/written chars.

func (*Andreiboard) GetSpiFlash

func (a *Andreiboard) GetSpiFlash() string

GetSpiFlash gets the path to previously set spiflash.

func (*Andreiboard) IsOpen

func (a *Andreiboard) IsOpen() bool

IsOpen returns true iff the port is open.

func (*Andreiboard) Open

func (a *Andreiboard) Open(ctx context.Context) error

Open opens the console port.

func (*Andreiboard) ReadSerialSubmatch

func (a *Andreiboard) ReadSerialSubmatch(ctx context.Context, re *regexp.Regexp) (output [][]byte, err error)

ReadSerialSubmatch reads from the serial port until regex is matched.

func (*Andreiboard) WriteSerial

func (a *Andreiboard) WriteSerial(ctx context.Context, b []byte) error

WriteSerial writes to the serial port.

type CommandImage

type CommandImage struct {
	// contains filtered or unexported fields
}

CommandImage displays a prompt and responds to cli commands.

func NewCommandImage

func NewCommandImage(board DevBoard, promptCmd, promptPattern string) *CommandImage

NewCommandImage creates a new CommandImage. Typical examples of promptCmd and promptPattern are "\r" and "\n\r> " respectively.

func (*CommandImage) Command

func (i *CommandImage) Command(ctx context.Context, cmd string) (string, error)

Command sends the command to the image and returns the output from after the command up to the next prompt.

func (*CommandImage) GetPrompt

func (i *CommandImage) GetPrompt(ctx context.Context) error

GetPrompt gets a fresh prompt from the image by the prompt.

func (*CommandImage) RawCommand

func (i *CommandImage) RawCommand(ctx context.Context, rawCmd string, re *regexp.Regexp) ([]string, error)

RawCommand sends a command to the image and waits for the regex to be matched before returning the captured groups. It does not append the promptCmd as opposed to Command.

func (*CommandImage) WaitUntilBooted

func (i *CommandImage) WaitUntilBooted(ctx context.Context, interval time.Duration) error

WaitUntilBooted by checking that prompts are consistently displayed.

type ConnectedAndreiboard

type ConnectedAndreiboard struct {
	*Andreiboard
}

ConnectedAndreiboard is one that is directly connected via serial port to the localhost. Localhost being the dut for a test in the local bundle and the drone/workstation for one that's in the remote bundle.

func NewConnectedAndreiboard

func NewConnectedAndreiboard(targetDevice string, bufSize int, spiFlash string, readTimeout time.Duration) *ConnectedAndreiboard

NewConnectedAndreiboard creates a ConnectedAndreiboard. bufSize is the max number of expected un-read bytes. spiFlash is the path to the spiflash executable. readTimeout is the max duration of expected silence during reads.

Example:

device, _ := ListConnectedUltraDebugTargets(ctx)
if len(device) == 0 {
    testing.ContextLog(ctx, "Could not find any UD device")
}
board := NewConnectedAndreiboard(device, 4096, "/path/to/spi/flash", 1 * time.Second)

func (*ConnectedAndreiboard) FlashImage

func (a *ConnectedAndreiboard) FlashImage(ctx context.Context, image string) error

FlashImage flashes an image to the board.

func (*ConnectedAndreiboard) Reset

func (a *ConnectedAndreiboard) Reset(ctx context.Context) error

Reset causes the board FlashImage flashes an image to the board.

type CrOSImage

type CrOSImage struct {
	*CommandImage
}

CrOSImage interacts with a board running ti50.

func NewCrOSImage

func NewCrOSImage(board DevBoard) *CrOSImage

NewCrOSImage creates a new CrOSImage.

func (*CrOSImage) Help

Help issues 'help' and parses its output.

func (*CrOSImage) WaitUntilBooted

func (i *CrOSImage) WaitUntilBooted(ctx context.Context) error

WaitUntilBooted waits until the image is fully booted.

type CrOSImageHelpOutput

type CrOSImageHelpOutput struct {
	Raw      string
	Commands []string
}

CrOSImageHelpOutput holds relevant data from the 'help' command.

type DevBoard

type DevBoard interface {
	// Open opens the console port.
	Open(ctx context.Context) error
	// ReadSerialSubmatch reads output from port until regex is matched.
	ReadSerialSubmatch(ctx context.Context, re *regexp.Regexp) (output [][]byte, err error)
	// WriteSerial writes to port.
	WriteSerial(ctx context.Context, bytes []byte) error
	// FlushSerial flushes un-read/written chars from port.
	FlushSerial(ctx context.Context) error
	// FlashImage flashes image on DevBoard.
	FlashImage(ctx context.Context, imagePath string) error
	// Reset the DevBoard.
	Reset(ctx context.Context) error
	// Close closes the console port.
	Close(ctx context.Context) error
}

DevBoard is the generic interface for development boards.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL