Documentation
¶
Index ¶
- Constants
- Variables
- func CheckDir(outputDir string) error
- func FrameCapture(ctx context.Context, conn *net.UDPConn, maxPkt uint16, timeout time.Duration, ...) struct{ ... }
- func GvspFrame(ctx context.Context, conn *net.UDPConn, udpPktBuffer []byte, ...) error
- func Init(deviceFile string) error
- func PixelFormatFromString(pixFmt string) (uint32, error)
- func ReadI2c(port string, i2cID uint32, rdLen int) ([]byte, error)
- func ReadI2cAddr(port string, i2cID uint32, addrBytes []byte, rdLen int) ([]byte, error)
- func SPIeraseBlocks(fileBytes int, chipSel uint8, addrSize uint8, startAddr uint32) error
- func SPIsetRegAddrCtrl(addr uint32)
- func SPIsetRegAddrData(addr uint32)
- func SPIwriteFile(f *os.File, fileBytes int, chipSel uint8, addrSize uint8, startAddr uint32) error
- func SetEevReqUdpPort(port uint16)
- func SetTokenLen(tokenLen uint8) error
- func SetupStreamListener(streamDestIP string, streamDestPort uint16, hostIP string) (*net.UDPConn, error)
- func WriteI2C(port string, i2cID uint32, addrBytes []byte, dataBytes []byte) error
- type CapabilitiesType
- type CoAPMessage
- type CoAPOption
- type CoapRespCode
- type DeviceMapType
- type DeviceRegisterAddrType
- type DeviceRegisterType
- type DeviceType
- func (Device *DeviceType) ReadReg(regName string) (uint32, map[string]uint32, error)
- func (Device *DeviceType) ReadRegString(regName string) (string, error)
- func (Device *DeviceType) RegReadRegAcc(uAddr uint32, regAccOpt EevRegAccOpt) ([]byte, error)
- func (Device *DeviceType) RegReadString(uAddr uint32) (string, error)
- func (Device *DeviceType) RegReadU32(uAddr uint32) (uint32, error)
- func (Device *DeviceType) RegWriteRegAcc(uAddr uint32, regAccOpt EevRegAccOpt, wrData []byte) error
- func (Device *DeviceType) RegWriteU32(uAddr uint32, uVal uint32) error
- func (Device *DeviceType) SPIdisable() error
- func (Device *DeviceType) SPIenable() error
- func (Device *DeviceType) SPIerase(chipSel uint8, addrSize uint8, addr uint32, eraseCmd uint8) error
- func (Device *DeviceType) SPIread(chipSel uint8, addrSize uint8, addr uint32, length uint32) ([]byte, error)
- func (Device *DeviceType) SPIreadDeviceID(chipSel uint8) (uint32, error)
- func (Device *DeviceType) SPIreadStatusReg(chipSel uint8) (uint8, error)
- func (Device *DeviceType) SPIwrite(chipSel uint8, addrSize uint8, addr uint32, wrData []byte) error
- func (Device *DeviceType) SPIwriteAddr(addrSize uint8, addr uint32) error
- func (Device *DeviceType) SPIwriteCmd(chipSel uint8, cmd uint8) error
- func (Device *DeviceType) StreamMaxPktSize(streamNum string, destIP string, delay uint32) (uint16, error)
- func (Device *DeviceType) StreamStart(streamNum string, destIP string, destPort uint16, delay uint32, maxPkt uint16) error
- func (Device *DeviceType) StreamStop(streamNum string) error
- func (Device *DeviceType) WriteReg(regName string, uVal uint32) error
- func (Device *DeviceType) WriteRegFields(regName string, fVals map[string]uint32) error
- type EevFeatureType
- type EevFeaturesStrType
- type EevFeaturesType
- type EevRegAccOpt
- type EevRegisterType
- type FieldType
- type GetAccType
- type I2cRxDataType
- type ImageBuffer
- type ImgCaptureResult
- type LocationType
- type PointerType
- type PutAccType
- type UDPListenerCfg
Constants ¶
const ( PacketTypeLeader = 0x1 PacketTypePayload = 0x3 PacketTypeTrailer = 0x2 )
Packet Types as defined in GVSP Protocol
const ( GvspImage = 1 GvspJPEG = 6 )
Payload Types
const ( MONO8 = 0x01080001 MONO16 = 0x01100007 GR8 = 0x01080008 RG8 = 0x01080009 GB8 = 0x0108000A BG8 = 0x0108000B RGB8 = 0x02180014 YUV422_8_UYVY = 0x0210001F )
Supported Pixel Formats
const ( OptionEevRegAccess uint16 = 65301 OptionEevBinaryAddress uint16 = 65305 )
const ( EevUdpPort int = 5683 EevTimeOut = 1000 * time.Millisecond )
const ( // SPI CTRL Register bitfields SPI_CTRL_EN uint8 = 0 // (r/w): SPI unit enable // SPI_CTRL_RX_AVAIL uint8 = 16 // (r/-): RX FIFO data available (RX FIFO not empty) // SPI_CTRL_TX_EMPTY uint8 = 17 // (r/-): TX FIFO empty SPI_CTRL_TX_FULL uint8 = 18 // (r/-): TX FIFO full // SPI_CTRL_CS_ACTIVE uint8 = 30 // (r/-): At least one CS line is active when set SPI_CTRL_BUSY uint8 = 31 // (r/-): SPI busy or TX FIFO not empty yet (read-only) // SPI DATA Register bitfields // SPI_DATA_LSB uint8 = 0 // (r/w): Data byte LSB SPI_DATA_CSEN uint8 = 3 // (-/w): Chip select enable (command-mode) // SPI_DATA_MSB uint8 = 7 // (r/w): Data byte MSB SPI_DATA_CMD uint8 = 31 // (-/w): 1=command, 0=data // SPI Flash Commands SPI_PAGE_PROG uint8 = 0x02 SPI_READ uint8 = 0x03 // SPI_WRITE_DIS uint8 = 0x04 SPI_READ_STATUS uint8 = 0x05 SPI_WRITE_EN uint8 = 0x06 SPI_4KB_ERASE uint8 = 0x20 SPI_32KB_ERASE uint8 = 0x52 SPI_64KB_ERASE uint8 = 0xD8 SPI_RDID uint8 = 0x9F // SPI flash Status Register bitfields SPI_SREG_BUSY uint8 = 0 // Busy, write/erase in progress when set, read-only // UDP packet related parameters SPI_RETRIES int = 20 // Register Read/Write retries SPI_SLEEP time.Duration = 100 // Register Read/Write retry delay in Milliseconds SPI_PAYLOAD_SIZE uint32 = 1450 // Max UDP payload size, standard MTU 1500-headers )
Variables ¶
var ( Device *DeviceType EevTokenLen uint8 EevReqUdpPort int Verbose int HostUDP *net.UDPAddr DeviceUDP *net.UDPAddr )
var CoapRespCodes = map[uint8]CoapRespCode{
64: {"2.00 Success"},
68: {"2.04 Changed"},
69: {"2.05 Content"},
128: {"4.00 Bad Request"},
129: {"4.01 Unauthorized"},
130: {"4.02 Bad Option"},
131: {"4.03 Forbidden"},
132: {"4.04 Not Found"},
160: {"5.00 Internal Server Error"},
161: {"5.01 Not Implemented"},
}
CoAP Message Response Codes (combined Class and Detail fields, c.dd)
var REGADDR_SPI_CTRL uint32 = 0x380000
SPI Peripheral Register Address
var REGADDR_SPI_DATA uint32 = 0x380004
var YamlFiles embed.FS
Functions ¶
func CheckDir ¶ added in v0.0.7
CheckDir checks if the provided file path directory exists, creates it if not, and also checks if it is writable
func FrameCapture ¶ added in v0.0.10
func FrameCapture(ctx context.Context, conn *net.UDPConn, maxPkt uint16, timeout time.Duration, dataCh chan<- *ImageBuffer) struct { Wg *sync.WaitGroup ErrCh chan error }
FrameCapture runs the frame collection go routine. Returns WaitGroup and an error channel (receives first fatal error or nil on clean exit).
func GvspFrame ¶ added in v0.0.7
func GvspFrame(ctx context.Context, conn *net.UDPConn, udpPktBuffer []byte, timeout time.Duration, dataCh chan<- *ImageBuffer) error
GvspFrame collects one complete frame and sends it to dataCh when complete. Returns nil on success (frame sent), or error on fatal issues. Non-fatal packet errors can be printed.
func PixelFormatFromString ¶ added in v0.0.7
PixelFormatFromString converts a pixel format string to the corresponding pixel format constant. If the string is empty or unsupported, return an error.
func ReadI2cAddr ¶ added in v0.0.8
func SPIeraseBlocks ¶ added in v0.0.12
Erase 64KB blocks for the provided amount of fileBytes beginning at startAddr
func SPIsetRegAddrCtrl ¶ added in v0.0.12
func SPIsetRegAddrCtrl(addr uint32)
Change SPI Peripheral Ctrl Register Address
func SPIsetRegAddrData ¶ added in v0.0.12
func SPIsetRegAddrData(addr uint32)
Change SPI Peripheral Data Register Address
func SPIwriteFile ¶ added in v0.0.12
SPIwriteFile writes the provided binary file of given fileBytes size to SPI flash, managing page boundaries and performing verification.
func SetEevReqUdpPort ¶ added in v0.0.2
func SetEevReqUdpPort(port uint16)
Sets the client side UDP port used for EEVideo commands (Default is 0 for random OS assigned Source Port). Typically set to a value in the Dynamic/Private Ports range (49152 - 65535)
func SetTokenLen ¶
Sets the Token Length for EEVideo commands. Default is 1.
Types ¶
type CapabilitiesType ¶ added in v0.0.2
type CapabilitiesType struct {
DecAvail bool `yaml:"decAvail"`
MultAddr bool `yaml:"multAddr"`
StringRd bool `yaml:"stringRd"`
FifoRd bool `yaml:"fifoRd"`
ReadRst bool `yaml:"readRst"`
MaskWr bool `yaml:"maskWr"`
BitTog bool `yaml:"bitTog"`
BitSet bool `yaml:"bitSet"`
BitClear bool `yaml:"bitClear"`
StaticIP bool `yaml:"staticIP"`
LinkLocIP bool `yaml:"linkLocIP"`
DhcpIP bool `yaml:"dhcpIP"`
MultiDisc bool `yaml:"multiDisc"`
}
type CoAPMessage ¶
type CoAPMessage struct {
Version uint8
Type uint8
TokenLen uint8
Code uint8
MessageID uint16
Token []byte
Options []CoAPOption
Payload []byte
}
CoAPMessage represents a parsed CoAP message
type CoAPOption ¶
CoAPOption represents a single CoAP option
type CoapRespCode ¶
type CoapRespCode struct {
Desc string
}
CoapRespCode represents the value(s) in one CoapRespCode key
type DeviceMapType ¶ added in v0.0.2
type DeviceRegisterAddrType ¶ added in v0.0.2
type DeviceRegisterType ¶ added in v0.0.2
type DeviceType ¶ added in v0.0.2
type DeviceType struct {
Location LocationType `yaml:"location"`
Capabilities CapabilitiesType `yaml:"capabilities"`
Map DeviceMapType `yaml:"map"`
Registers map[string]DeviceRegisterAddrType `yaml:"features"`
}
func DiscDevices ¶ added in v0.0.2
func DiscDevices(discNicName string, udpTimeout int) ([]DeviceType, error)
Top level function call for Discovering EEVideo Devices
func ReadDeviceYAML ¶ added in v0.0.10
func ReadDeviceYAML(file_loc string) (*DeviceType, error)
ReadDeviceYAML unmarshals/reads an EEVideo device YAML file
func (*DeviceType) ReadReg ¶ added in v0.0.4
ReadReg uses a register name string to read a register containing a uint32 value. It returns the uint32 value and a map of field and value pairs.
func (*DeviceType) ReadRegString ¶ added in v0.0.4
func (Device *DeviceType) ReadRegString(regName string) (string, error)
ReadRegString is used to read a register containing a string (using the provided register name string for address lookup in the Device).
func (*DeviceType) RegReadRegAcc ¶ added in v0.0.4
func (Device *DeviceType) RegReadRegAcc(uAddr uint32, regAccOpt EevRegAccOpt) ([]byte, error)
RegReadRegAcc reads a register address using an EevRegAccOpt
func (*DeviceType) RegReadString ¶ added in v0.0.4
func (Device *DeviceType) RegReadString(uAddr uint32) (string, error)
RegString is used to read a register that contains a string
func (*DeviceType) RegReadU32 ¶ added in v0.0.4
func (Device *DeviceType) RegReadU32(uAddr uint32) (uint32, error)
RegReadU32 is used to read a register containing a uint32 value
func (*DeviceType) RegWriteRegAcc ¶ added in v0.0.12
func (Device *DeviceType) RegWriteRegAcc(uAddr uint32, regAccOpt EevRegAccOpt, wrData []byte) error
RegWriteRegAcc writes a register address using an EevRegAccOpt
func (*DeviceType) RegWriteU32 ¶ added in v0.0.4
func (Device *DeviceType) RegWriteU32(uAddr uint32, uVal uint32) error
RegWriteU32 writes a uint32 value to a register
func (*DeviceType) SPIdisable ¶ added in v0.0.12
func (Device *DeviceType) SPIdisable() error
Disable SPI controller
func (*DeviceType) SPIenable ¶ added in v0.0.12
func (Device *DeviceType) SPIenable() error
Enable SPI controller
func (*DeviceType) SPIerase ¶ added in v0.0.12
func (Device *DeviceType) SPIerase(chipSel uint8, addrSize uint8, addr uint32, eraseCmd uint8) error
Erase SPI flash with the provided Erase cmd and address
func (*DeviceType) SPIread ¶ added in v0.0.12
func (Device *DeviceType) SPIread(chipSel uint8, addrSize uint8, addr uint32, length uint32) ([]byte, error)
SPIread reads 1 to 256 bytes from the SPI flash starting at addr. It handles single-word transfers via spiTransfer and bulk reads via RegReadRegAcc.
func (*DeviceType) SPIreadDeviceID ¶ added in v0.0.12
func (Device *DeviceType) SPIreadDeviceID(chipSel uint8) (uint32, error)
Reads SPI flash Device ID (RDID command)
func (*DeviceType) SPIreadStatusReg ¶ added in v0.0.12
func (Device *DeviceType) SPIreadStatusReg(chipSel uint8) (uint8, error)
Read SPI flash Status Register
func (*DeviceType) SPIwrite ¶ added in v0.0.12
SPIwrite writes 1 to 256 bytes to the SPI flash. It handles single-byte transfers via spiTransfer and bulk transfers via RegWriteRegAcc.
func (*DeviceType) SPIwriteAddr ¶ added in v0.0.12
func (Device *DeviceType) SPIwriteAddr(addrSize uint8, addr uint32) error
Write the address byte(s) to SPI flash
func (*DeviceType) SPIwriteCmd ¶ added in v0.0.12
func (Device *DeviceType) SPIwriteCmd(chipSel uint8, cmd uint8) error
Write SPI flash Command byte
func (*DeviceType) StreamMaxPktSize ¶ added in v0.0.9
func (Device *DeviceType) StreamMaxPktSize(streamNum string, destIP string, delay uint32) (uint16, error)
StreamMaxPktSize negotiates the largest usable packet size for the stream. It starts at 9000, decrements on failure, and increments back up when a good packet is received. Any size >= 200 that successfully delivers a packet is considered valid. If negotiation fails, it sets the device MaxPacketSize register to 1000
func (*DeviceType) StreamStart ¶ added in v0.0.6
func (Device *DeviceType) StreamStart(streamNum string, destIP string, destPort uint16, delay uint32, maxPkt uint16) error
Sets enable stream bit to start streaming on the provided stream number name (e.g. stream0). Also, configures streaming registers DestIPAddr, Delay, DestPort and MaxPacketSize. If the provided destPort value is 0 then a random, open dynamic port is assigned. If the provided maxPkt value is 0 then a system supported size is negotiated.
func (*DeviceType) StreamStop ¶ added in v0.0.6
func (Device *DeviceType) StreamStop(streamNum string) error
Clear enable stream bit to stop streaming on the provided stream number name (e.g. stream0)
func (*DeviceType) WriteReg ¶ added in v0.0.4
func (Device *DeviceType) WriteReg(regName string, uVal uint32) error
WriteReg is used to write a uint32 value to a register using the provided register name string for address lookup in the Device.
func (*DeviceType) WriteRegFields ¶ added in v0.0.4
func (Device *DeviceType) WriteRegFields(regName string, fVals map[string]uint32) error
WriteRegFields uses a register name string and writes the provide value(s) to the field(s)
type EevFeatureType ¶ added in v0.0.2
type EevFeatureType struct {
Name string `yaml:"name"`
ShortName string `yaml:"sname"`
Pointers []PointerType `yaml:"pointers"`
}
type EevFeaturesStrType ¶ added in v0.0.2
type EevFeaturesStrType map[string]EevFeatureType
Features is a map from hex ID to Feature
type EevFeaturesType ¶ added in v0.0.2
type EevFeaturesType map[uint32]EevFeatureType
func LoadEevFeaturesFromYAML ¶ added in v0.0.5
func LoadEevFeaturesFromYAML() (EevFeaturesType, error)
Load master EEV features list
type EevRegAccOpt ¶ added in v0.0.2
EevRegAccOpt struct used for creating a Register Access CoAP Option
type EevRegisterType ¶ added in v0.0.2
type GetAccType ¶
type GetAccType uint8
const ( GetRegAccTypeReg GetAccType = 0 GetRegAccTypeFIFO GetAccType = 1 GetRegAccTypeRegIncr GetAccType = 4 GetRegAccTypeString GetAccType = 5 )
func (GetAccType) IsValid ¶
func (accType GetAccType) IsValid() bool
type I2cRxDataType ¶ added in v0.0.6
type ImageBuffer ¶ added in v0.0.7
type ImageBuffer struct {
Data []byte
BlockID uint32
PacketID uint32
PayloadType uint16
Width uint32
Height uint32
PixelFormat uint32
Offset uint32
}
ImageBuffer holds the frame data and info for assembling an image
type ImgCaptureResult ¶ added in v0.0.10
RawImgCaptureResult bundles WaitGroup and error channel
func ImgCapture ¶ added in v0.0.10
func ImgCapture(ctx context.Context, frameCount uint32, imagePath string, imageName string, dataCh <-chan *ImageBuffer) ImgCaptureResult
ImgCapture runs a background consumer go routine that saves N frames Returns WaitGroup that completes when done or canceled
type LocationType ¶ added in v0.0.2
type PointerType ¶ added in v0.0.5
type PointerType struct {
Index int `yaml:"index"`
Name string `yaml:"name"`
Registers []EevRegisterType `yaml:"registers"`
}
type PutAccType ¶
type PutAccType uint8
const ( PutRegAccTypeWr PutAccType = 0 PutRegAccTypeSet PutAccType = 1 PutRegAccTypeClear PutAccType = 2 PutRegAccTypeToggle PutAccType = 3 PutRegAccTypeWrIncr PutAccType = 5 PutRegAccTypeMaskWrIncr PutAccType = 6 PutRegAccTypeRstAdvIncr PutAccType = 7 )
func (PutAccType) IsValid ¶
func (accType PutAccType) IsValid() bool