PPD (Packet Property Data)

Available 16 ~ 254 for Non-Stream Mode.

Predefined PPD values : 32, 34, 48, 64, 128 for designated communication types.

  • 32 : Data send without request result.
  • 34 : Data send with request result.
  • 48 : Send result in response to PPD=34
  • 64 : Request data.
  • 128 : Send data in response to PPD=64.

 

PBS (Packet Byte Size)

Packet byte size is allocated. Packet bytes size is equal to the packet index maximum plus 1.

 

IID (Information Identification Data)

Identification number is allocated. The purpose of  ID number is identifying the packet contents.

 

Code Example

Packet detection and save to array PACKET_NS_T5A[100] from serial received non-stream LXSDF T5A.

/*
LXSDF T5A Non Stream example codes.
feature : Parsing and After processing for each PPD value. 

inputs
byte_now : One byte per call
*/

uint8_t PACKET_NS_T5A[100]; // array for gathering the received bytes. 

void Proc_NS_T5A(uint8_t byte_data)
{
  int ppd = Parsing_NS_T5A(byte_data);

  if(ppd == -1) return ; // not completed packet

  switch(ppd)
  {
    case 128:  // response from the opposite for this request 64
            //do something
    break;

    case 64:  // request 64 from the opposite, should response 128
            //do something
    break;

    case 34: // request 34 from the opposite, shoulde response 48
            //do something
    break;

    case 32: // request 32 from the opposite. no need to response tx.
            //do something
    break;

  }
}


/*
inputs
byte_now : One byte per call

return
-1 : when packet not complete
PPD : when packet completed
*/
int Parsing_NS_T5A(uint8_t byte_now)
{

  static uint8_t byte_prev8[8]    = {0};   // for accumulateing the byte_now
  static uint8_t sync_after       = 0;	// marking 1 when T5A SyncBytes detected
  static uint32_t PacketIndex_T5A = 0;  // LXSDF T5A Packet Index

  /// fast shifting the byte_prev8 and then put the byte_now.
  memmove(byte_prev8+1, byte_prev8,7); //byte_prev8 array shift  i.e byte_prev8[7] = byte_prev8[6];, [6] = [5], ... [1] = [0]
  byte_prev8[0] = byte_now; //

  ///Check T5A SyncBytes
  if((byte_prev8[7] == 0xFF) && (byte_prev8[6] == 0xFF) && (byte_prev8[5] == 0xFF) && (byte_prev8[4] == 0xFF) && (byte_prev8[3] == 0xFE)   )  // SyncBytes Detected
  {
      sync_after = 1; // mark SyncBytes detected.

      PacketIndex_T5A = 6;

      PACKET_NS_T5A[5] =  byte_prev8[2]; // PPD
      PACKET_NS_T5A[6] =  byte_prev8[1]; // PBS
  }

  if(sync_after == 0) return -1; // not detected SyncBytes.

  PacketIndex_T5A ++;

  //in this point  PacketIndex_T5A is 7

  PACKET_NS_T5A[PacketIndex_T5A] = byte_now;

  ///Check One Packet Completed . when (PacketIndex_T5A+1) is equal to PBS(PACKET_NS_T5A[6]) 
  if((PacketIndex_T5A+1) == PACKET_NS_T5A[6])
  {
      sync_after = 0 ; // init sync_after.

      return PACKET_NS_T5A[5]; // return PPD
  }

  return -1 ;
}