Output Data Format

Packets are provided with ndigo_read() (see Data Readout).

The following code snippet showcases how to unpack a packet containing regular ADC data. A complete coding example can be found on github.com/cronologic-de/ndigo5g_babel or in Code example.

bool = is_timestamp_only = packet->type & NDIGO_PACKET_TYPE_TIMESTAMP_ONLY;

printf("Card %d, Channel %d, Flags %d, Length %d, Timestamp %lu \n",
       packet->card,
       packet->channel,
       packet->flags,
       is_timestamp_only ? 0 : packet->length,
       packet->timestamp);

if (!is_timestamp_only)
{
    short* data = (short*)packet->data;
    for (unsigned int i = 0; i < packet->length * 4; i++)
        printf("%6d, ", *(data++));
    printf("\n\n");
}
struct ndigo_packet

Contains all packet information.

Packets are retrieved by ndigo_read().

Public Members

unsigned char channel

Enumeration of channels.

0 to 3 for the ADC input channels, 4 for the TDC, and 5 for the timestamp channel.

unsigned char card

Identify source card among others.

Defaults to 0 if no value is assigned to the parameter ndigo_init_parameters::board_id.

unsigned char type

Type indicator for ndigo_packet::data.

One of the following:

NDIGO_PACKET_TYPE_16_BIT_SIGNED 1

16-bit signed ADC data.

NDIGO_PACKET_TYPE_TDC_DATA 8

64-bit unsigned TDC data.

Only for internal processing.

NDIGO_PACKET_TYPE_TIMESTAMP_ONLY 128

Empty ndigo_packet::data.

ndigo_packet::length may contain alternative information.

NDIGO_PACKET_TYPE_END_OF_BUFFER 129

Empty ndigo_packet::data.

The packet may contain other data.

unsigned char flags

Contains packet flags.

One of the following:

NDIGO_PACKET_FLAG_SHORTENED 1

Less than the requested number of samples have been written due to a full FIFO.

NDIGO_PACKET_FLAG_PACKETS_LOST 2

Packets were discarded due to a full host buffer.

NDIGO_PACKET_FLAG_OVERFLOW 4

The previous packet included ADC samples with overflows.

NDIGO_PACKET_FLAG_TRIGGER_MISSED 8

The trigger unit has discarded packets due to a full FIFO.

NDIGO_PACKET_FLAG_DMA_FIFO_FULL 16

The internal DMA FIFO was full.

This may result in missed data, but only if NDIGO_PACKET_FLAG_SHORTENED or NDIGO_PACKET_FLAG_TRIGGER_MISSED are set.

NDIGO_PACKET_FLAG_HOST_BUFFER_FULL 32

Host buffer was full.

This may result in missed data, but only if NDIGO_PACKET_FLAG_PACKETS_LOST is set.

NDIGO_PACKET_FLAG_TDC_NO_EDGE 64

No valid edge was found in TDC packet, timestamp uncorrected.

unsigned int length

Length of ndigo_packet::data in units of 64 bit.

Number of 64-bit elements (each containing 4 samples) in the data array as long as ndigo_packet::type < NDIGO_PACKET_TYPE_TIMESTAMP_ONLY.

If ndigo_packet::type = NDIGO_PACKET_TYPE_TIMESTAMP_ONLY. this is the pattern of trigger sources that where active in the clock cycle given by ndigo_packet::timestamp. Bits are set according to the trigger sources, i.e. bit 0 is set if trigger NDIGO_TRIGGER_SOURCE_A0 was active, bit 29 is set if NDIGO_TRIGGER_SOURCE_BUS3_PE was active, etc, as listed in ndigo_trigger_block::sources.

uint64_t timestamp

Timestamp in ps.

ADC channels A to D: timestamp of the last word in the packet.

TDC channel (ndigo_packet::channel = 4): timestamp of the trigger event (falling edge) of the TDC channel. When ndigo_process_tdc_packet() is called once on the the packet, the timestamp is replaced with the precise timestamp for the edge.

Timestamp channel (ndigo_packet::channel = 5): timestamp of the trigger event.

uint64_t data[1]

Sample data.

For the Ndigo5G each 64-bit word contains four 16bit signed words from the ADC.

The user can cast the array to short* to directly operate on the sample data.