Пример #1
0
static void writeEscapedByteWithCrc(BerFramingOutput *pThis, byte b)
{
   BerOutput *pBase = &pThis->base.base;

   pThis->crc = crc_addByte(pThis->crc, b);

   writeEscapedByte(pBase, b);
}
Пример #2
0
void sendFrame(
 uint16_t        length  ,
 unsigned char   type    ,
 unsigned char   subType ,
 unsigned char * information,
 GioEndpoint *gioEndpoint){
 unsigned char byteInArse;
 byteInArse=START_FLAG;
 #ifdef BRLTTY
  logMessage(LOG_DEBUG,"Sending start flag.");
 #endif
 serialWrite(gioEndpoint, byteInArse);
 #ifdef BRLTTY
  logMessage(LOG_DEBUG,"Start flag sent.");
 #endif

 unsigned char xorChecksum=0;
 byteInArse=(length&0xFF00ul)>>8;
 xorChecksum^=byteInArse;
 writeEscapedByte(byteInArse,gioEndpoint);

 byteInArse=length&0x00FFul;
 xorChecksum^=byteInArse;
 writeEscapedByte(byteInArse,gioEndpoint);

 xorChecksum^=type;
 writeEscapedByte(type,gioEndpoint);

 xorChecksum^=subType;
 writeEscapedByte(subType,gioEndpoint);

 unsigned char indexInInformationBuffer=0;
 while(indexInInformationBuffer<length){
  xorChecksum^=information[indexInInformationBuffer];
  writeEscapedByte(information[indexInInformationBuffer++],gioEndpoint);
 }
 writeEscapedByte(xorChecksum,gioEndpoint);
 byteInArse=END_FLAG;
 serialWrite(gioEndpoint, byteInArse);
 #ifdef ARDUINO
 Serial.flush();
 #endif
 #ifdef BRLTTY
  logMessage(LOG_DEBUG,"Packet sent.");
 #endif
}