Documentation

Overview

Package ipbus enables communication with FPGAs using the IPbus UDP protocol.

Index

Constants

const DefaultAutoDispatch = false

const DefaultTimeout = 3 * time.Second

const IPbusVersion = 2.0

Supported IPbus protocol version


const PackageVersion = 1.0 // 23 Jun 17

Variables

var MaxPacketSize = uint(1500)

Maxiumum Ethernet packet size (bytes)


Functions

func License

func License()

Print the license the goipbus package is relased under.

Types

type CM

type CM struct {
	Devices []string
	// contains filtered or unexported fields
}

Connection Manager

func NewCM

func NewCM(fn string) (CM, error)

func (CM) Target

func (cm CM) Target(name string) (Target, error)

type InfoCode

type InfoCode uint8

Information codes

const BadHeader InfoCode = 0x1
const BusReadError InfoCode = 0x4
const BusReadTimeout InfoCode = 0x6
const BusWriteError InfoCode = 0x5
const Request InfoCode = 0xf
const Success InfoCode = 0x0

type Register

type Register struct {
	Name  string
	Addr  uint32   // Global IPbus address
	Masks []string // List of names bitmasks
	// contains filtered or unexported fields
}

func (Register) ReadMask

func (r Register) ReadMask(mask string, val uint32) (uint32, error)

Read the value of masked part of register

func (Register) String

func (r Register) String() string

func (Register) WriteMask

func (r Register) WriteMask(mask string, val uint32) (uint32, uint32, error)

type Response

type Response struct {
	Err   error
	Code  InfoCode
	Data  []uint32
	DataB []byte
}

Response to a control transaction

type Target

type Target struct {
	Name string
	// TimeoutPeriod defines the period to wait after queuing an initial transaction
	// before sending all queued transactions, if AutoDispatch is true.
	// The Timeout is restarted each time a transaction is added when the queue is empty.
	TimeoutPeriod time.Duration
	Regs          map[string]Register
	// Enable/disable automatic dispatch of transactions.
	// If enabled transactions are sent at the first opportunity when:
	// a) A full UDP packet worth of transactions can be sent
	// b) Target.dt has elapsed since the first queued transaction
	// or
	// c) Target.Dispatch() is called.
	// If disabled transactions are only sent when Target.Dispatch() is called.
	AutoDispatch bool

	Addr net.Addr
	// contains filtered or unexported fields
}

func New

func New(name, fn string, conn net.Conn) (Target, error)

Create a new target by parsing an XML file description.

func (Target) Dispatch

func (t Target) Dispatch()

Blocking call to send queued transactions, returns once all replies are received.

func (Target) MaskedReadNow

func (t Target) MaskedReadNow(reg Register, mask string) (uint32, error)

Immediately perform a read on a register and return the masked value once return packet is received

func (Target) MaskedWrite

func (t Target) MaskedWrite(reg Register, mask string, value uint32) (chan Response, error)

MaskedWrite performs a RMWbits for updarting the masked part of the register to the given value

func (Target) MaskedWriteNow

func (t Target) MaskedWriteNow(reg Register, mask string, value uint32) (uint32, error)

Immediately perform a masked write on a register and return the previous value once return packet is received

func (Target) RMWbits

func (t Target) RMWbits(reg Register, andterm, orterm uint32) chan Response

Update reg by operation: x = (x & andterm) | orterm. Receive previous value of reg in reply.

func (Target) RMWsum

func (t Target) RMWsum(reg Register, addend uint32) chan Response

Update reg by operation: x <= (x + addend). Receive previous value of reg in reply.

func (Target) Read

func (t Target) Read(reg Register, nword uint) chan Response

Read nword words from register reg.

func (Target) ReadB

func (t Target) ReadB(reg Register, nword uint) chan Response

Read transaction where reply is kept in []byte array.

func (Target) ReadNow

func (t Target) ReadNow(reg Register, nword uint) ([]uint32, error)

Immediately send read command and return all read words once all return packets are recieved

func (Target) String

func (t Target) String() string

func (Target) Write

func (t Target) Write(reg Register, data []uint32) chan Response

Write words in data to register reg.

func (Target) WriteNow

func (t Target) WriteNow(reg Register, data []uint32) error

Immediately send a write command and return any error once all return packets are received