Documentation
¶
Index ¶
- Variables
- type CommandCode
- type Config
- type Microcontroller
- func (mc *Microcontroller) BaudRate() int
- func (mc *Microcontroller) Close() error
- func (mc *Microcontroller) FlashPayload(bs []byte, addr uint32) error
- func (mc *Microcontroller) FlashPayloadFromFile(filePath string, addr uint32) error
- func (mc *Microcontroller) Identify() (string, error)
- func (mc *Microcontroller) IsOpen() bool
- func (mc *Microcontroller) Open() (err error)
- func (mc *Microcontroller) ReadN(n int, to time.Duration) ([]byte, error)
- func (mc *Microcontroller) Reset()
- func (mc *Microcontroller) TTY() string
- func (mc *Microcontroller) Write(bs ...[]byte) (err error)
Constants ¶
This section is empty.
Variables ¶
var DefaultBaud = 115200
var DefaultTTY = "/dev/ttyS1"
var ErrClosed = errors.New("serial port is closed")
var ErrSTMFailedToAck = errors.New("failed to read ack or nack from stm microcontroller")
var ErrSTMNACK = errors.New("received nack from stm microcontroller")
var ErrTimeout = errors.New("timed out reading from microcontroller")
var STMTimeout = 5 * time.Second
Functions ¶
This section is empty.
Types ¶
type CommandCode ¶
type CommandCode int
const ( CommandCodeSync CommandCode = -1 CommandCodeGet CommandCode = 0 CommandCodeGetVersion CommandCode = 1 CommandCodeGetID CommandCode = 2 CommandCodeReadMemory CommandCode = 3 CommandCodeGo CommandCode = 4 CommandCodeWriteMemory CommandCode = 5 CommandCodeErase CommandCode = 6 CommandCodeWriteProtect CommandCode = 7 CommandCodeWriteUnprotect CommandCode = 8 CommandCodeReadoutProtect CommandCode = 9 CommandCodeReadoutUnprotect CommandCode = 10 )
these must be the index of the bytes as received in the get data call
type Microcontroller ¶
type Microcontroller struct {
// contains filtered or unexported fields
}
Microcontroller represents an embedded microntroller chip that can be communicated with over UART
func NewMicrocontroller ¶
func NewMicrocontroller(c *Config) (*Microcontroller, error)
NewMicrocontroller will create a new reference to a particular chip
func (*Microcontroller) BaudRate ¶
func (mc *Microcontroller) BaudRate() int
BaudRate will return the baud rate used to connect to the TTY
func (*Microcontroller) Close ¶
func (mc *Microcontroller) Close() error
Close will close the connection and reset the MCU
func (*Microcontroller) FlashPayload ¶
func (mc *Microcontroller) FlashPayload(bs []byte, addr uint32) error
FlashPayload will flash the payload provided to the flash at the provided address
func (*Microcontroller) FlashPayloadFromFile ¶
func (mc *Microcontroller) FlashPayloadFromFile(filePath string, addr uint32) error
FlashPayloadFromFile will flash the requested file to the flash memory at the provided address
func (*Microcontroller) Identify ¶
func (mc *Microcontroller) Identify() (string, error)
Identify will report back a unique string with the ID of the chip
func (*Microcontroller) IsOpen ¶
func (mc *Microcontroller) IsOpen() bool
func (*Microcontroller) Open ¶
func (mc *Microcontroller) Open() (err error)
func (*Microcontroller) Reset ¶ added in v0.0.2
func (mc *Microcontroller) Reset()
Reset will force a power cycle on the microcontroller
func (*Microcontroller) TTY ¶
func (mc *Microcontroller) TTY() string
TTY will return the TTY that will be used
func (*Microcontroller) Write ¶
func (mc *Microcontroller) Write(bs ...[]byte) (err error)
Write will write the specified bytes to the microcontroller