stm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2018 License: Apache-2.0 Imports: 10 Imported by: 11

Documentation

Overview

Package stm implements communication with STM32F030 found on MuxPi.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterInterfaceService

func RegisterInterfaceService(server *rpc.Server, impl Interface) error

RegisterInterfaceService registers impl in server.

func RegisterUserInterfaceService

func RegisterUserInterfaceService(server *rpc.Server, impl UserInterface) error

RegisterUserInterfaceService registers impl in server.

Types

type AdminInterface

type AdminInterface interface {
	SetLED(led LED, r, g, b uint8) (err error)
	ClearDisplay() (err error)
	PrintText(x, y uint, color Color, text string) (err error)
}

AdminInterface contains methods of STM that are intended to be used by administrators only.

type Color

type Color string

Color denotes a string representation of a color accepted by STM.

MuxPi has only two colors available: orange (foreground), black (background).

const (
	// Foreground is displayed as orange, usually (255, 128, 0) in RGB notation.
	Foreground Color = "on"
	// Background is black, no pixels are lighted.
	Background Color = "off"
)

type Dummy

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

Dummy is a dummy implementation of Interface. It logs to the standard logger from "log" package.

func (*Dummy) ClearDisplay

func (d *Dummy) ClearDisplay() error

ClearDisplay prints "ClearDisplay" to the standard logger.

func (*Dummy) Close

func (d *Dummy) Close() error

Close prints "Close" to the standard logger.

func (*Dummy) DUT

func (d *Dummy) DUT() error

DUT prints "DUT" to the standard logger.

func (*Dummy) GetCurrent

func (d *Dummy) GetCurrent() (int, error)

GetCurrent prints "GetCurrent" to the standard logger and returns 0.

func (*Dummy) GetCurrentRecord

func (d *Dummy) GetCurrentRecord() ([]int, error)

GetCurrentRecord prints "GetCurrentRecord" to the standard logger and returns nil.

func (*Dummy) HDMI

func (d *Dummy) HDMI(on bool) (err error)

HDMI prints "HDMI" and argument to the standard logger.

func (*Dummy) PowerTick

func (d *Dummy) PowerTick(duration time.Duration) error

PowerTick prints "PowerTick" and duration argument to the standard logger.

func (*Dummy) PrintText

func (d *Dummy) PrintText(x, y uint, color Color, text string) error

PrintText prints "PrintText" and arguments to the standard logger.

func (*Dummy) SetDyper

func (d *Dummy) SetDyper(dyper Dyper, on bool) error

SetDyper prints "SetDyper" and arguments to the standard logger.

func (*Dummy) SetLED

func (d *Dummy) SetLED(led LED, r, g, b uint8) error

SetLED prints "SetLED" and arguments to the standard logger.

func (*Dummy) StartCurrentRecord

func (d *Dummy) StartCurrentRecord(samples int, interval time.Duration) error

StartCurrentRecord prints "StartCurrentRecord" and arguments to the standard logger.

func (*Dummy) StopCurrentRecord

func (d *Dummy) StopCurrentRecord() error

StopCurrentRecord prints "StopCurrentRecord" to the standard logger.

func (*Dummy) TS

func (d *Dummy) TS() error

TS prints "TS" to the standard logger.

type Dyper

type Dyper string

Dyper represents all DYPERs available via STM.

const (
	// DYPER1 is Dyper controlling the left column of pins.
	DYPER1 Dyper = "dyper 1"
	// DYPER2 is Dyper controlling the right column of pins.
	DYPER2 Dyper = "dyper 2"
)

type Interface

type Interface interface {
	UserInterface
	AdminInterface
}

Interface contains all methods of STM.

type InterfaceClearDisplayRequest

type InterfaceClearDisplayRequest struct {
}

InterfaceClearDisplayRequest is a helper structure for ClearDisplay method.

type InterfaceClearDisplayResponse

type InterfaceClearDisplayResponse struct {
}

InterfaceClearDisplayResponse is a helper structure for ClearDisplay method.

type InterfaceClient

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

InterfaceClient is generated client for Interface interface.

func DialInterfaceClient

func DialInterfaceClient(addr string) (*InterfaceClient, error)

DialInterfaceClient connects to addr and creates a new InterfaceClient instance.

func NewInterfaceClient

func NewInterfaceClient(client *rpc.Client) *InterfaceClient

NewInterfaceClient creates a new InterfaceClient instance.

func (*InterfaceClient) ClearDisplay

func (_c *InterfaceClient) ClearDisplay() (err error)

ClearDisplay is part of implementation of Interface calling corresponding method on RPC server.

func (*InterfaceClient) Close

func (_c *InterfaceClient) Close() error

Close terminates the connection.

func (*InterfaceClient) DUT

func (_c *InterfaceClient) DUT() (err error)

DUT is part of implementation of Interface calling corresponding method on RPC server.

func (*InterfaceClient) GetCurrent

func (_c *InterfaceClient) GetCurrent() (value int, err error)

GetCurrent is part of implementation of Interface calling corresponding method on RPC server.

func (*InterfaceClient) GetCurrentRecord

func (_c *InterfaceClient) GetCurrentRecord() (samples []int, err error)

GetCurrentRecord is part of implementation of Interface calling corresponding method on RPC server.

func (*InterfaceClient) HDMI

func (_c *InterfaceClient) HDMI(on bool) (err error)

HDMI is part of implementation of Interface calling corresponding method on RPC server.

func (*InterfaceClient) PowerTick

func (_c *InterfaceClient) PowerTick(d time.Duration) (err error)

PowerTick is part of implementation of Interface calling corresponding method on RPC server.

func (*InterfaceClient) PrintText

func (_c *InterfaceClient) PrintText(x, y uint, color Color, text string) (err error)

PrintText is part of implementation of Interface calling corresponding method on RPC server.

func (*InterfaceClient) SetDyper

func (_c *InterfaceClient) SetDyper(dyper Dyper, on bool) (err error)

SetDyper is part of implementation of Interface calling corresponding method on RPC server.

func (*InterfaceClient) SetLED

func (_c *InterfaceClient) SetLED(led LED, r, g, b uint8) (err error)

SetLED is part of implementation of Interface calling corresponding method on RPC server.

func (*InterfaceClient) StartCurrentRecord

func (_c *InterfaceClient) StartCurrentRecord(samples int, interval time.Duration) (err error)

StartCurrentRecord is part of implementation of Interface calling corresponding method on RPC server.

func (*InterfaceClient) StopCurrentRecord

func (_c *InterfaceClient) StopCurrentRecord() (err error)

StopCurrentRecord is part of implementation of Interface calling corresponding method on RPC server.

func (*InterfaceClient) TS

func (_c *InterfaceClient) TS() (err error)

TS is part of implementation of Interface calling corresponding method on RPC server.

type InterfaceCloser

type InterfaceCloser interface {
	Interface
	Close() error
}

InterfaceCloser is Interface expanded by Close method.

func GetDefaultSTM

func GetDefaultSTM() (InterfaceCloser, error)

GetDefaultSTM provides InterfaceCloser to STM with default values. The caller should call Close() to free the underlying serial connection. The returned instance is different for each call. Care should be taken to not use two such objects concurrently as they use the same device.

func NewDummy

func NewDummy(context string) InterfaceCloser

NewDummy return a dummy implementation of Interface. Each message will be prefixed with context.

type InterfaceDUTRequest

type InterfaceDUTRequest struct {
}

InterfaceDUTRequest is a helper structure for DUT method.

type InterfaceDUTResponse

type InterfaceDUTResponse struct {
}

InterfaceDUTResponse is a helper structure for DUT method.

type InterfaceGetCurrentRecordRequest

type InterfaceGetCurrentRecordRequest struct {
}

InterfaceGetCurrentRecordRequest is a helper structure for GetCurrentRecord method.

type InterfaceGetCurrentRecordResponse

type InterfaceGetCurrentRecordResponse struct {
	Samples []int
}

InterfaceGetCurrentRecordResponse is a helper structure for GetCurrentRecord method.

type InterfaceGetCurrentRequest

type InterfaceGetCurrentRequest struct {
}

InterfaceGetCurrentRequest is a helper structure for GetCurrent method.

type InterfaceGetCurrentResponse

type InterfaceGetCurrentResponse struct {
	Value int
}

InterfaceGetCurrentResponse is a helper structure for GetCurrent method.

type InterfaceHDMIRequest

type InterfaceHDMIRequest struct {
	On bool
}

InterfaceHDMIRequest is a helper structure for HDMI method.

type InterfaceHDMIResponse

type InterfaceHDMIResponse struct {
}

InterfaceHDMIResponse is a helper structure for HDMI method.

type InterfacePowerTickRequest

type InterfacePowerTickRequest struct {
	D time.Duration
}

InterfacePowerTickRequest is a helper structure for PowerTick method.

type InterfacePowerTickResponse

type InterfacePowerTickResponse struct {
}

InterfacePowerTickResponse is a helper structure for PowerTick method.

type InterfacePrintTextRequest

type InterfacePrintTextRequest struct {
	X, Y  uint
	Color Color
	Text  string
}

InterfacePrintTextRequest is a helper structure for PrintText method.

type InterfacePrintTextResponse

type InterfacePrintTextResponse struct {
}

InterfacePrintTextResponse is a helper structure for PrintText method.

type InterfaceService

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

InterfaceService is generated service for Interface interface.

func NewInterfaceService

func NewInterfaceService(impl Interface) *InterfaceService

NewInterfaceService creates a new InterfaceService instance.

func (*InterfaceService) ClearDisplay

func (s *InterfaceService) ClearDisplay(request *InterfaceClearDisplayRequest, response *InterfaceClearDisplayResponse) (err error)

ClearDisplay is RPC implementation of ClearDisplay calling it.

func (*InterfaceService) DUT

func (s *InterfaceService) DUT(request *InterfaceDUTRequest, response *InterfaceDUTResponse) (err error)

DUT is RPC implementation of DUT calling it.

func (*InterfaceService) GetCurrent

func (s *InterfaceService) GetCurrent(request *InterfaceGetCurrentRequest, response *InterfaceGetCurrentResponse) (err error)

GetCurrent is RPC implementation of GetCurrent calling it.

func (*InterfaceService) GetCurrentRecord

func (s *InterfaceService) GetCurrentRecord(request *InterfaceGetCurrentRecordRequest, response *InterfaceGetCurrentRecordResponse) (err error)

GetCurrentRecord is RPC implementation of GetCurrentRecord calling it.

func (*InterfaceService) HDMI

func (s *InterfaceService) HDMI(request *InterfaceHDMIRequest, response *InterfaceHDMIResponse) (err error)

HDMI is RPC implementation of HDMI calling it.

func (*InterfaceService) PowerTick

func (s *InterfaceService) PowerTick(request *InterfacePowerTickRequest, response *InterfacePowerTickResponse) (err error)

PowerTick is RPC implementation of PowerTick calling it.

func (*InterfaceService) PrintText

func (s *InterfaceService) PrintText(request *InterfacePrintTextRequest, response *InterfacePrintTextResponse) (err error)

PrintText is RPC implementation of PrintText calling it.

func (*InterfaceService) SetDyper

func (s *InterfaceService) SetDyper(request *InterfaceSetDyperRequest, response *InterfaceSetDyperResponse) (err error)

SetDyper is RPC implementation of SetDyper calling it.

func (*InterfaceService) SetLED

func (s *InterfaceService) SetLED(request *InterfaceSetLEDRequest, response *InterfaceSetLEDResponse) (err error)

SetLED is RPC implementation of SetLED calling it.

func (*InterfaceService) StartCurrentRecord

func (s *InterfaceService) StartCurrentRecord(request *InterfaceStartCurrentRecordRequest, response *InterfaceStartCurrentRecordResponse) (err error)

StartCurrentRecord is RPC implementation of StartCurrentRecord calling it.

func (*InterfaceService) StopCurrentRecord

func (s *InterfaceService) StopCurrentRecord(request *InterfaceStopCurrentRecordRequest, response *InterfaceStopCurrentRecordResponse) (err error)

StopCurrentRecord is RPC implementation of StopCurrentRecord calling it.

func (*InterfaceService) TS

func (s *InterfaceService) TS(request *InterfaceTSRequest, response *InterfaceTSResponse) (err error)

TS is RPC implementation of TS calling it.

type InterfaceSetDyperRequest

type InterfaceSetDyperRequest struct {
	Dyper Dyper
	On    bool
}

InterfaceSetDyperRequest is a helper structure for SetDyper method.

type InterfaceSetDyperResponse

type InterfaceSetDyperResponse struct {
}

InterfaceSetDyperResponse is a helper structure for SetDyper method.

type InterfaceSetLEDRequest

type InterfaceSetLEDRequest struct {
	Led     LED
	R, G, B uint8
}

InterfaceSetLEDRequest is a helper structure for SetLED method.

type InterfaceSetLEDResponse

type InterfaceSetLEDResponse struct {
}

InterfaceSetLEDResponse is a helper structure for SetLED method.

type InterfaceStartCurrentRecordRequest

type InterfaceStartCurrentRecordRequest struct {
	Samples  int
	Interval time.Duration
}

InterfaceStartCurrentRecordRequest is a helper structure for StartCurrentRecord method.

type InterfaceStartCurrentRecordResponse

type InterfaceStartCurrentRecordResponse struct {
}

InterfaceStartCurrentRecordResponse is a helper structure for StartCurrentRecord method.

type InterfaceStopCurrentRecordRequest

type InterfaceStopCurrentRecordRequest struct {
}

InterfaceStopCurrentRecordRequest is a helper structure for StopCurrentRecord method.

type InterfaceStopCurrentRecordResponse

type InterfaceStopCurrentRecordResponse struct {
}

InterfaceStopCurrentRecordResponse is a helper structure for StopCurrentRecord method.

type InterfaceTSRequest

type InterfaceTSRequest struct {
}

InterfaceTSRequest is a helper structure for TS method.

type InterfaceTSResponse

type InterfaceTSResponse struct {
}

InterfaceTSResponse is a helper structure for TS method.

type LED

type LED string

LED represents all LEDs available via STM.

const (
	// LED1 is an RGB LED located in the bottom-left corner of MuxPi.
	LED1 LED = "1"
	// LED2 is an RGB LED located on the right of the OLED display.
	LED2 LED = "2"
)

type STM

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

STM provides methods to execute commands via serial interface.

It is safe for concurrent use.

func NewSTM

func NewSTM(ttyPath string, baudrate int) *STM

NewSTM prepares STM structure with serial configuration.

func (*STM) ClearDisplay

func (stm *STM) ClearDisplay() error

ClearDisplay clears the OLED display.

func (*STM) Close

func (stm *STM) Close() error

Close terminates the serial connection.

It should be called only once after the connection has been created with Open().

func (*STM) DUT

func (stm *STM) DUT() error

DUT instructs STM to connect microSD card and power to a DUT (Device Under Test).

func (*STM) GetCurrent

func (stm *STM) GetCurrent() (int, error)

GetCurrent reads value of current drawn by DUT. The value is in milliamperes [mA].

func (*STM) GetCurrentRecord

func (stm *STM) GetCurrentRecord() (samples []int, err error)

GetCurrentRecord returns all samples of GetCurrent made. It may be called before StopCurrentRecord.

func (*STM) HDMI

func (stm *STM) HDMI(on bool) (err error)

HDMI sets (or unsets) HDMI HOTPLUG pin.

func (*STM) Open

func (stm *STM) Open() (err error)

Open starts a serial connection.

It should be called only once after structure creation or in case the connection has been terminated with Close().

func (*STM) PowerTick

func (stm *STM) PowerTick(d time.Duration) error

PowerTick cuts power off DUT, waits specified time and switches power back on.

func (*STM) PrintText

func (stm *STM) PrintText(x, y uint, color Color, text string) error

PrintText prints text at x,y position (from top-left corner) in color.

func (*STM) SetDyper

func (stm *STM) SetDyper(dyper Dyper, on bool) (err error)

SetDyper switches dyper, specified by 1st argument, on or off depending on 2nd argument.

func (*STM) SetLED

func (stm *STM) SetLED(led LED, r, g, b uint8) error

SetLED sets color of an RGB LED.

func (*STM) StartCurrentRecord

func (stm *STM) StartCurrentRecord(samples int, interval time.Duration) (err error)

StartCurrentRecord starts a goroutine that periodically calls GetCurrent and saves the returned value. User who wants more samples should periodically call GetCurrent() instead.

func (*STM) StopCurrentRecord

func (stm *STM) StopCurrentRecord() (err error)

StopCurrentRecord stops the goroutine that records the sample.

func (*STM) TS

func (stm *STM) TS() error

TS instructs STM to connect microSD card to TS (test server) and disconnect power source from a DUT.

type UserInterface

type UserInterface interface {
	PowerTick(d time.Duration) (err error)
	DUT() (err error)
	TS() (err error)
	GetCurrent() (value int, err error)
	StartCurrentRecord(samples int, interval time.Duration) (err error)
	StopCurrentRecord() (err error)
	GetCurrentRecord() (samples []int, err error)
	HDMI(on bool) (err error)
	SetDyper(dyper Dyper, on bool) (err error)
}

UserInterface contains methods of STM that are intended to be used by a regular user and admin.

type UserInterfaceClient

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

UserInterfaceClient is generated client for UserInterface interface.

func DialUserInterfaceClient

func DialUserInterfaceClient(addr string) (*UserInterfaceClient, error)

DialUserInterfaceClient connects to addr and creates a new UserInterfaceClient instance.

func NewUserInterfaceClient

func NewUserInterfaceClient(client *rpc.Client) *UserInterfaceClient

NewUserInterfaceClient creates a new UserInterfaceClient instance.

func (*UserInterfaceClient) Close

func (_c *UserInterfaceClient) Close() error

Close terminates the connection.

func (*UserInterfaceClient) DUT

func (_c *UserInterfaceClient) DUT() (err error)

DUT is part of implementation of UserInterface calling corresponding method on RPC server.

func (*UserInterfaceClient) GetCurrent

func (_c *UserInterfaceClient) GetCurrent() (value int, err error)

GetCurrent is part of implementation of UserInterface calling corresponding method on RPC server.

func (*UserInterfaceClient) GetCurrentRecord

func (_c *UserInterfaceClient) GetCurrentRecord() (samples []int, err error)

GetCurrentRecord is part of implementation of UserInterface calling corresponding method on RPC server.

func (*UserInterfaceClient) HDMI

func (_c *UserInterfaceClient) HDMI(on bool) (err error)

HDMI is part of implementation of UserInterface calling corresponding method on RPC server.

func (*UserInterfaceClient) PowerTick

func (_c *UserInterfaceClient) PowerTick(d time.Duration) (err error)

PowerTick is part of implementation of UserInterface calling corresponding method on RPC server.

func (*UserInterfaceClient) SetDyper

func (_c *UserInterfaceClient) SetDyper(dyper Dyper, on bool) (err error)

SetDyper is part of implementation of UserInterface calling corresponding method on RPC server.

func (*UserInterfaceClient) StartCurrentRecord

func (_c *UserInterfaceClient) StartCurrentRecord(samples int, interval time.Duration) (err error)

StartCurrentRecord is part of implementation of UserInterface calling corresponding method on RPC server.

func (*UserInterfaceClient) StopCurrentRecord

func (_c *UserInterfaceClient) StopCurrentRecord() (err error)

StopCurrentRecord is part of implementation of UserInterface calling corresponding method on RPC server.

func (*UserInterfaceClient) TS

func (_c *UserInterfaceClient) TS() (err error)

TS is part of implementation of UserInterface calling corresponding method on RPC server.

type UserInterfaceDUTRequest

type UserInterfaceDUTRequest struct {
}

UserInterfaceDUTRequest is a helper structure for DUT method.

type UserInterfaceDUTResponse

type UserInterfaceDUTResponse struct {
}

UserInterfaceDUTResponse is a helper structure for DUT method.

type UserInterfaceGetCurrentRecordRequest

type UserInterfaceGetCurrentRecordRequest struct {
}

UserInterfaceGetCurrentRecordRequest is a helper structure for GetCurrentRecord method.

type UserInterfaceGetCurrentRecordResponse

type UserInterfaceGetCurrentRecordResponse struct {
	Samples []int
}

UserInterfaceGetCurrentRecordResponse is a helper structure for GetCurrentRecord method.

type UserInterfaceGetCurrentRequest

type UserInterfaceGetCurrentRequest struct {
}

UserInterfaceGetCurrentRequest is a helper structure for GetCurrent method.

type UserInterfaceGetCurrentResponse

type UserInterfaceGetCurrentResponse struct {
	Value int
}

UserInterfaceGetCurrentResponse is a helper structure for GetCurrent method.

type UserInterfaceHDMIRequest

type UserInterfaceHDMIRequest struct {
	On bool
}

UserInterfaceHDMIRequest is a helper structure for HDMI method.

type UserInterfaceHDMIResponse

type UserInterfaceHDMIResponse struct {
}

UserInterfaceHDMIResponse is a helper structure for HDMI method.

type UserInterfacePowerTickRequest

type UserInterfacePowerTickRequest struct {
	D time.Duration
}

UserInterfacePowerTickRequest is a helper structure for PowerTick method.

type UserInterfacePowerTickResponse

type UserInterfacePowerTickResponse struct {
}

UserInterfacePowerTickResponse is a helper structure for PowerTick method.

type UserInterfaceService

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

UserInterfaceService is generated service for UserInterface interface.

func NewUserInterfaceService

func NewUserInterfaceService(impl UserInterface) *UserInterfaceService

NewUserInterfaceService creates a new UserInterfaceService instance.

func (*UserInterfaceService) DUT

DUT is RPC implementation of DUT calling it.

func (*UserInterfaceService) GetCurrent

GetCurrent is RPC implementation of GetCurrent calling it.

func (*UserInterfaceService) GetCurrentRecord

GetCurrentRecord is RPC implementation of GetCurrentRecord calling it.

func (*UserInterfaceService) HDMI

HDMI is RPC implementation of HDMI calling it.

func (*UserInterfaceService) PowerTick

PowerTick is RPC implementation of PowerTick calling it.

func (*UserInterfaceService) SetDyper

SetDyper is RPC implementation of SetDyper calling it.

func (*UserInterfaceService) StartCurrentRecord

StartCurrentRecord is RPC implementation of StartCurrentRecord calling it.

func (*UserInterfaceService) StopCurrentRecord

StopCurrentRecord is RPC implementation of StopCurrentRecord calling it.

func (*UserInterfaceService) TS

TS is RPC implementation of TS calling it.

type UserInterfaceSetDyperRequest

type UserInterfaceSetDyperRequest struct {
	Dyper Dyper
	On    bool
}

UserInterfaceSetDyperRequest is a helper structure for SetDyper method.

type UserInterfaceSetDyperResponse

type UserInterfaceSetDyperResponse struct {
}

UserInterfaceSetDyperResponse is a helper structure for SetDyper method.

type UserInterfaceStartCurrentRecordRequest

type UserInterfaceStartCurrentRecordRequest struct {
	Samples  int
	Interval time.Duration
}

UserInterfaceStartCurrentRecordRequest is a helper structure for StartCurrentRecord method.

type UserInterfaceStartCurrentRecordResponse

type UserInterfaceStartCurrentRecordResponse struct {
}

UserInterfaceStartCurrentRecordResponse is a helper structure for StartCurrentRecord method.

type UserInterfaceStopCurrentRecordRequest

type UserInterfaceStopCurrentRecordRequest struct {
}

UserInterfaceStopCurrentRecordRequest is a helper structure for StopCurrentRecord method.

type UserInterfaceStopCurrentRecordResponse

type UserInterfaceStopCurrentRecordResponse struct {
}

UserInterfaceStopCurrentRecordResponse is a helper structure for StopCurrentRecord method.

type UserInterfaceTSRequest

type UserInterfaceTSRequest struct {
}

UserInterfaceTSRequest is a helper structure for TS method.

type UserInterfaceTSResponse

type UserInterfaceTSResponse struct {
}

UserInterfaceTSResponse is a helper structure for TS method.

Jump to

Keyboard shortcuts

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