ironman package

Submodules

ironman.communicator module

This file implements all of the various communications one might need to do.

Jarvis provides a callback structure that looks up (in its registry) for an appropriate communication protocol.

class ironman.communicator.ComplexIO[source]

Bases: object

read(offset, size)[source]
write(offset, data)[source]
class ironman.communicator.Jarvis[source]

Bases: object

This is the general communication slave.

Jarvis is what lets us pass around communications to various routes/protocols while keeping the details separated from us. Here’s an example of how one might use it:

>>> from ironman.communicator import Jarvis, SimpleIO
>>> # create a Jarvis instance to manage what we want to register
>>> j = Jarvis()
>>> # tell Jarvis to register this class for the given route
>>> @j.register('fpgaOne')
... class FileOne(SimpleIO):
...     __f__ = '/path/to/fileOne'
...
>>> # tell Jarvis to register this class for the given route
>>> @j.register('fpgaTwo')
... class FileTwo(SimpleIO):
...     __f__ = '/path/to/fileTwo'
...
>>> # print the available registered classes
>>> import pprint
>>> pprint.pprint(j.registry)
{'fpgaOne': <class 'ironman.communicator.FileOne'>,
 'fpgaTwo': <class 'ironman.communicator.FileTwo'>}

Jarvis does the wrapping for Jarvis.register() so that a class defined at run-time is automatically inserted.

parse_address(address)[source]
register(route)[source]
set_hardware_manager(hwmanager)[source]
unregister(route)[source]
class ironman.communicator.SimpleIO[source]

Bases: object

read(offset, size)[source]
write(offset, data)[source]

ironman.globals module

ironman.hardware module

class ironman.hardware.BlockMemHardwareManager[source]

Bases: ironman.hardware.HardwareManager

get_node(address)[source]
class ironman.hardware.HardwareManager[source]

Bases: dict

add(new_hw_map)[source]

Add the HW map only if it doesn’t exist for a given key, and no address collisions

check_address(address)[source]
check_data(address, data)[source]
find_address(address)[source]
get_checksum(map_name)[source]
get_node(address)[source]
get_route(address)[source]
raw_maps = {}
subtract(route)[source]

Remove the route entirely.

class ironman.hardware.HardwareMap(yml, route)[source]

Bases: dict

isOk()[source]
parse(yml)[source]
class ironman.hardware.HardwareNode(node, hw_map)[source]

Bases: dict

property allowed
property disallowed
property isOk
isValueValid(val)[source]
property permissions
property readable
property writeable
class ironman.hardware.NullHardwareMap[source]

Bases: dict

isOk()[source]
parse(yml)[source]
route = None
class ironman.hardware.NullHardwareNode[source]

Bases: dict

allowed = {}
disallowed = {}
hw_map = {}
isOk = False
isValueValid = False
permissions = {}
readable = False
writeable = False

ironman.history module

class ironman.history.History(maxlen=100)[source]

Bases: dict

record(packet)[source]

ironman.interfaces module

interface ironman.interfaces.ICommunicationDriver[source]

The standard driver that is expected for all methods of communication on the board

read(offset, size)

Read from the given address (offset) for N bytes (size)

write(offset, value)

Write to the given address (offset) for N bytes (len(value))

interface ironman.interfaces.ICommunicationSlave[source]

Manages the communication with the programmable logic for us

__call__(packet)

A non-blocking I/O call passing along the packet

Returns the responses

__transaction__(transaction)

Handle a single transaction and return the response

parse_address(address)

Parses address and returns what function to call

set_hardware_manager(hwmanager)

Set the hardware manager that the slave communications with

interface ironman.interfaces.IHardwareManager[source]

Our Hardware Maps manager

add(hw_map)

Add the Map object to the Hardware

check_address(address)

Given an address, checks if it is valid

check_data(address, data)

Given an address, checks if the data is a valid value to write

get_checksum(route)

Look up the checksum for a given map name (route)

get_node(address)

Given an address, return the node associated with it

get_route(address)

Given an address, return the route for it

raw_maps

A dictionary of the maps added so we can keep track which makes it easier to add and remove.

subtract(route)

Remove the route from the hardware manager

interface ironman.interfaces.IHardwareMap[source]

Manages information about a single map, should be an overloaded dictionary

__init__(xml, route)

Initialize a hardware map object by giving it the data to parse and associate it with a route

isOk()

Whether or not the given hardware map is ok. Should just be a loop over IHardwareNode.isOk().

parse(xml)

Parse the xml hardware map data to set things up

route

The route associated for this hardware map.

interface ironman.interfaces.IHardwareNode[source]

Manages information about a single address. Simply a well-defined dictionary.

__init__(node, hw_map)

Initialize the node by giving it the parsed xml data as well as the hw_map

allowed

A list of allowed values for the node.

disallowed

A list of disallowed values for the node.

hw_map

The hardware map this is associated with.

isOk

Is the given node ok? EG: can’t set allowed and disallowed objects at the same time and cannot block a node from being readable.

isValueValid(val)

Whether the given value is a valid value for the node

permissions

Mark the node’s read/write capabilities.

readable

Is the given node readable?

writeable

Is the given node writeable?

interface ironman.interfaces.IHistory[source]

Enhanced dictionary to store inbound and outbound packet pairs

record(packet)

record the packet

interface ironman.interfaces.IIPBusPacket[source]

IPBus Packet object

__eq__(other)

Define a way to identify two packets as being equivalent. Best way is to compare the underlying structs

__init__(blob)

Packet is initialized with a data blob to decode. Determine if it is big or little endian.

__ne__(other)

This should just be return not self.__eq__(other).

_raw

The raw request packet

byteorder

The byte-order in the header. Should assert == 0xf.

packet_id

The id of the ipbus packet.

packet_type

The type of packet.

Value

Type

0x0

Control

0x1

Status

0x2

Re-send request

0x3-f

Reserved

protocol_version

The packet header protocol version. This does not check that the encapsulated transactions also match.

raw

The raw datagram blob.

request

The parsed request packet

reserved

Reserved. Should be 0x0.

response

The data response to be passed along to another function that builds the response packet. This should be a list [] to append responses to.

ironman.packet module

class ironman.packet.IPBusPacket(blob)[source]

Bases: object

property byteorder
property packet_id
property packet_type
property protocol_version
property raw
property reserved

ironman.server module

class ironman.server.FauxCP(dgen)[source]

Bases: twisted.internet.protocol.Protocol

dataReceived(data)[source]

After receiving the data, generate the deferreds and add myself to it.

class ironman.server.FauxFactory(dgen)[source]

Bases: twisted.internet.protocol.ServerFactory

buildProtocol(addr)[source]

Create an instance of a subclass of Protocol.

The returned instance will handle input on an incoming server connection, and an attribute “factory” pointing to the creating factory.

Alternatively, L{None} may be returned to immediately close the new connection.

Override this method to alter how Protocol instances get created.

@param addr: an object implementing L{twisted.internet.interfaces.IAddress}

protocol

alias of ironman.server.FauxCP

ironman.server.ServerFactory(proto, dgen)[source]
class ironman.server.TCP(dgen)[source]

Bases: twisted.internet.protocol.Protocol

dataReceived(data)[source]

After receiving the data, generate the deferreds and add myself to it.

class ironman.server.TCPFactory(dgen)[source]

Bases: twisted.internet.protocol.ServerFactory

buildProtocol(addr)[source]

Create an instance of a subclass of Protocol.

The returned instance will handle input on an incoming server connection, and an attribute “factory” pointing to the creating factory.

Alternatively, L{None} may be returned to immediately close the new connection.

Override this method to alter how Protocol instances get created.

@param addr: an object implementing L{twisted.internet.interfaces.IAddress}

protocol

alias of ironman.server.TCP

class ironman.server.UDP(dgen)[source]

Bases: twisted.internet.protocol.DatagramProtocol

datagramReceived(datagram, address)[source]

After receiving a datagram, generate the deferreds and add myself to it.

ironman.utilities module

class ironman.utilities.PrintContext[source]

Bases: construct.core.Construct

ironman.utilities.chunks(mylist, chunk_size)[source]

Yield successive n-sized chunks from a list.