PDChannelLogger

group PDChannelLogger

PDChannelLogger: Provides an interface for managing BrainStem Power Delivery Packets. Packets are accepted and decoded asynchronously. Pay careful attention to packet cleanup. Portions of the structure do not belong to the caller.

struct BS_PD_Packet_CCA

BrainStem Power Delivery Packet Structure - Contains information representing a Power Delivery packet along with contextual device information

Public Members

unsigned char channel

Channel/Index

unsigned int seconds

Seconds in device time since power on.

unsigned int uSeconds

Micro Seconds in device time since power on .

unsigned char direction

Direction of packet transmission relative to the device.

unsigned char sop

See bs_pd_packet.h for more details

unsigned int event

Packet type - See powerdeliveryLogEvent in aProtocolDefs.h

unsigned int payloadSize

Length of the payload.

unsigned char *payload

Raw PD Packet data

void PDChannelLogger_create(unsigned int *id, struct Result *result, const int index, const unsigned int bufferLength)

Creates internal object for managing BrainStem Power Delivery logging packets.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The current upstream port.

  • index – The index of the entity in question.

  • bufferLength – Number of packets the class should queue before dropping.

void PDChannelLogger_destroy(unsigned int *id, struct Result *result, const int index)

Destroys internal object for managing BrainStem Power Delivery logging packets.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The current upstream port.

  • index – The index of the entity in question.

void PDChannelLogger_setEnabled(unsigned int *id, struct Result *result, const int index, const bool enable)

Enables Power Delivery logging.

True on success.

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The current upstream port.

  • index – The index of the entity in question.

  • enable – True enables logging; False disables logging

void PDChannelLogger_getPacket(unsigned int *id, struct Result *result, const int index, struct BS_PD_Packet_CCA *packet)

Attempts to takes a packet from the internal buffer.

True if the function successfully acquired any number of packets. False if no packets were available.

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The current upstream port.

  • index – The index of the entity in question.

  • packet – Reference to a packet to be filled by the function.

void PDChannelLogger_getPackets(unsigned int *id, struct Result *result, const int index, struct BS_PD_Packet_CCA *packetBuffer, const unsigned int bufferLength)

Attempts to take a multiple packets (up to a maximum) from the internal buffer.

True if the function successfully acquired any number of packets. False if no packets were available.

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The current upstream port.

  • index – The index of the entity in question.

  • packetBuffer – pointer to a buffer to be filled

  • bufferLength – The length of the buffer provided.

void PDChannelLogger_freePayloadBuffer(unsigned int *id, struct Result *result, struct BS_PD_Packet_CCA *packet)

Releases the internal memory contained within the payload parameter.

Returns common entity return values

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Object containing aErrNone and the requested value on success. Non-zero error code on failure. The current upstream port.

  • packet – Reference to a packet to have its memory freed.