PACMAN IO Interface

class larpix.io.pacman_io.PACMAN_IO(config_filepath=None, hwm=20000, relaxed=True, timeout=-1, raw_directory='./', raw_filename=None)[source]

The PACMAN_IO object interfaces with a network of PACMAN boards each running a pacman-cmdserver and pacman-dataserver.

This object handles the ZMQ messaging protocol to send and receive formatted messages to/from the PACMAN boards. If you want more info on how messages are formatted, see larpix.format.pacman_msg_format.

The PACMAN_IO object has five flags for optimizing communications which you may or may not want to enable:

  • group_packets_by_io_group
  • interleave_packets_by_io_channel
  • double_send_packets
  • enable_raw_file_writing
  • disable_packet_parsing

To enable each option set the flag to True; to disable, set to False.

  • The group_packets_by_io_group option is enabled by default and assembles the packets sent in each call to send into as few messages as possible destined for a single io group. E.g. sending three packets (2 for io_group=1, 1 for io_group=2) will combine the packets for io_group=1 into a single message to transfer over the network. This reduces overhead associated with network latency and allows large data transfers to happen much faster.
  • The interleave_packets_by_io_channel option is enabled by default and interleaves packets within a given message to each io_channel on a given io_group. E.g. 3 packets destined for io_channel=1, io_channel=1, and io_channel=2 will be reordered to io_channel=1, io_channel=2, and io_channel=1. The order of the packets is preserved for each io_channel. This increases the data throughput by about a factor of N, where N is the number of io channels in the message.
  • The double_send_packets option is disabled by default and duplicates each packet sent to the PACMAN by a call to send(). This is potentially useful for working around the 512 bug when you need to insure that a packet reaches a chip, but you don’t care about introducing extra packets into the system (i.e. when configuring chips).
  • The enable_raw_file_writing option will directly dump data to a larpix raw hdf5 formatted file. This is used as a more performant means of logging data (see larpix.format.rawhdf5format). The data file name can be accessed or changed via the raw_filename attribute, or can be set when creating the PACMAN_IO object with the raw_directory and raw_filename keyword args.
  • The disable_packet_parsing option will skip converting PACMAN messages into larpix.packet types. Thus if disable_packet_parsing=True, every call to empty_queue will return [], b''. Typically used in conjunction with enable_raw_file_writing, this allows the PACMAN_IO class to read data much faster.
send(packets)[source]

Sends a request message to PACMAN boards to send designated packets.

start_listening()[source]

Start keeping msgs from data server

stop_listening()[source]

Stop keeping msgs from data server

empty_queue()[source]

Fetch and parse waiting packets on pacman data socket

returns tuple of list of packets, full bytestream of all messages

cleanup()[source]

Close the ZMQ objects to prevent a memory leak.

This method is only required if you plan on instantiating a new PACMAN_IO object.

join()[source]

Wait for raw file worker to finish

set_reg(reg, val, io_group=None)[source]

Set a 32-bit register in the pacman PL

get_reg(reg, io_group=None)[source]

Read a 32-bit register from the pacman PL

If no io_group is specified, returns a dict of io_group, reg_value else returns reg_value

ping(io_group=None)[source]

Send a ping message

If no io_group is specified, returns a dict of io_group, response else returns response

get_vddd(io_group=None)[source]

Gets PACMAN VDDD voltage

Returns VDDD and IDDD values from the built-in ADC as a tuple of mV and mA respectively

set_vddd(vddd_dac=54691, io_group=None, settling_time=0.1)[source]

Sets PACMAN VDDD voltage

If no vddd_dac value is specified, sets VDDD to default of ~1.8V

Returns the resulting VDDD and IDDD values from the built-in ADC as a tuple of mV and mA respectively

get_vdda(io_group=None)[source]

Gets PACMAN VDDA voltage

Returns VDDA and IDDA values from the built-in ADC as a tuple of mV and mA respectively

set_vdda(vdda_dac=54691, io_group=None, settling_time=0.1)[source]

Sets PACMAN VDDA voltage

If no vdda_dac value is specified, sets VDDA to default of ~1.8V

Returns the resulting VDDA and IDDA values from the built-in ADC as a tuple of mV and mA respectively

get_vplus(io_group=None)[source]

Gets PACMAN Vplus voltage

Returns Vplus and Iplus values from the built-in ADC as a tuple of mV and mA respectively

enable_tile(tile_indices=None, io_group=None)[source]

Enables the specified pixel tile(s) (first tile is index=0, second tile is index=1, …).

Returns the value of the new tile enable mask

disable_tile(tile_indices=None, io_group=None)[source]

Disables the specified pixel tile(s) (first tile is index=0, second tile is index=1, …).

Returns the value of the new tile enable mask

set_uart_clock_ratio(channel, ratio, io_group=None)[source]

Sets PACMAN UART clock speed relative to the larpix master clock for the specified channel

For a nominal 10MHz clock, a ratio value of 4 results in a 2.5MHz UART clock.

Returns the value of the UART clock register that was set

reset_larpix(length=256, io_group=None)[source]

Issues a reset of the specified length (in larpix MCLK cycles).

If no length specified, issue a hard reset.

Returns the value of the clock/reset control register after the reset