BPacket

BPacket — the UDP packet used to transport a single frame

Synopsis




struct      BPacket;
union       BPacketHeader;
BPacket*    b_packet_new                    (gint width,
                                             gint height,
                                             gint channels,
                                             gint maxval,
                                             gint *data_size);
gsize       b_packet_size                   (BPacket *packet);
void        b_packet_hton                   (BPacket *packet);
void        b_packet_ntoh                   (BPacket *packet);

Description

A BPacket consists of a mcu_frame_header struct followed by the actual frame data. It corresponds to a single animation frame.

Details

struct BPacket

struct BPacket {

  BPacketHeader      header;
  guchar             data[0];
};

The BPacket struct has a variable size which is determined by the values passed to b_packet_new().

BPacketHeader headerthe Blinkenlights frame header
guchar data[0]the frame data

union BPacketHeader

union BPacketHeader
{
  mcu_frame_header_t  mcu_frame_h;
  heartbeat_header_t  heartbeat_h;
};


b_packet_new ()

BPacket*    b_packet_new                    (gint width,
                                             gint height,
                                             gint channels,
                                             gint maxval,
                                             gint *data_size);

Allocates a new BPacket structure and initializes it with the given values. If data_size is non-NULL the size of the data area (in bytes) is returned via this variable.

The packet should be freed with g_free() when it is not needed any longer.

width : the number of pixels per row
height : the number of pixels per column
channels : the number of channels per pixels
maxval : the maximum value
data_size : returns the size of the packet data
Returns : a newly allocated BPacket.

b_packet_size ()

gsize       b_packet_size                   (BPacket *packet);

packet :
Returns :

b_packet_hton ()

void        b_packet_hton                   (BPacket *packet);

Converts all members of packet from host to network byteorder.

packet : pointer to a BPacket

b_packet_ntoh ()

void        b_packet_ntoh                   (BPacket *packet);

Converts all members of packet from network to host byteorder.

packet : pointer to a BPacket