Serial Port IO Interface

The serial port IO interface.

class larpix.io.serialport.SerialPort(port=None, baudrate=1000000, timeout=0)[source]

Wrapper for various serial port interfaces across platforms.

Automatically loads correct driver based on the supplied port name:

  • '/dev/anything' ==> Linux ==> pySerial
  • 'scan-ftdi' ==> MacOS ==> libFTDI
classmethod encode(packets)[source]

Encodes a list of packets into a list of bytestream messages

classmethod decode(msgs, leftover_bytes=b'')[source]

Decodes a list of serial port bytestreams to packets

classmethod is_valid_chip_key(key)[source]

Valid chip keys must be strings formatted as: '<io_chain>-<chip_id>'

send(packets)[source]

Format the packets as a bytestream and send it to the FPGA and on to the LArPix ASICs.

start_listening()[source]

Start listening for incoming LArPix data by opening the serial port.

stop_listening()[source]

Stop listening for LArPix data by closing the serial port.

empty_queue()[source]

Empty the incoming data buffer and return (packets, bytestream).

set_larpix_uart_clk_ratio(value)[source]

Sends a special command to modify the larpix uart clk ratio (how many clock cycles correspond to one bit). A value of 2 means 1 uart bit == 2 clk cycles

set_larpix_reset_cnt(value)[source]

Sends a special command to modify the length of the reset signal sent to the larpix chips. The reset will be held low for value + 1 larpix clk rising edges

larpix_reset()[source]

Sends a special command to issue a larpix reset pulse. Pulse length is set by set_larpix_reset_cnt().

set_utility_pulse(pulse_len=None, pulse_rep=None)[source]

Sends a special command to issue set up utility pulser. Pulse length is the number of larpix clk cyles pulse is high, and pulse rep is the number of clk cycles until the next pulse.

enable_utility_pulse()[source]

Sends a special command to enable the utility pulser. Pulse characteristics can be set by set_utility_pulse().

disable_utility_pulse()[source]

Sends a special command to disable the utility pulser. Pulse characteristics can be set by set_utility_pulse().

reset()[source]

Sends a special command to reset FPGA and larpix.

larpix.io.serialport.enable_logger(filename=None)[source]

Enable serial data logger

larpix.io.serialport.disable_logger()[source]

Disable serial data logger

larpix.io.serialport.flush_logger()[source]

Flush serial data logger data to output file