Esempio n. 1
0
void ArNetPacket::insertHeader()
{
  int length = myLength;
  myLength = 0;
  uByteToBuf(0xF);         // 1
  uByteToBuf(0xC);         // 2

  if (myAddedFooter)
    uByte2ToBuf(length);   // 3 & 4
  else
    uByte2ToBuf(length+2); // 3 & 4

  uByte2ToBuf(myCommand);  // 5 & 6

  if (myAddedFooter)
    myLength = length - 2;
  else
    myLength = length;

} // end method insertHeader
Esempio n. 2
0
AREXPORT void ArRobotPacket::finalizePacket(void)
{
  int len = myLength;
  int chkSum;

  myLength = 0;
  uByteToBuf(mySync1);
  uByteToBuf(mySync2);
  uByteToBuf(len - getHeaderLength() + 3);
  myLength = len;

  chkSum = calcCheckSum();
  byteToBuf((chkSum >> 8) & 0xff );
  byteToBuf(chkSum & 0xff );
  /* Put this in if you want to see the packets being outputted 
     printf("Output(%3d) ", getID());
     printHex();
  */
  // or put this in if you just want to see the type
  //printf("Output %d\n", getID());
}
AREXPORT void ArLMS2xxPacket::finalizePacket(void)
{
  int len = myLength;
  int chkSum;

  // put in the start of the packet
  myLength = 0;
  // toss in the header 
  uByteToBuf(0x02);
  // now the laser we want to talk to
  uByteToBuf(mySendingAddress);
  // dump in the length
  uByte2ToBuf(len - myHeaderLength);
  myLength = len;

  // that lovely CRC
  chkSum = calcCRC();
  byteToBuf(chkSum & 0xff );
  byteToBuf((chkSum >> 8) & 0xff );

  //printf("Sending ");
  //log();
}
Esempio n. 4
0
AREXPORT void ArLMS1XXPacket::uByte2ToBuf(ArTypes::UByte2 val)
{
  uByteToBuf(val & 0xff);
  uByteToBuf((val > 8) & 0xff);
}