xdspacket.cpp

来自「完整的基于Conxant平台的USB电视棒的WIN驱动程序。」· C++ 代码 · 共 55 行

CPP
55
字号
/*+++ *******************************************************************\ 
* 
*  Copyright and Disclaimer: 
*  
*     --------------------------------------------------------------- 
*     This software is provided "AS IS" without warranty of any kind, 
*     either expressed or implied, including but not limited to the 
*     implied warranties of noninfringement, merchantability and/or 
*     fitness for a particular purpose.
*     --------------------------------------------------------------- 
*   
*     Copyright (c) 2004 Conexant Systems, Inc. 
*     All rights reserved. 
*
\******************************************************************* ---*/ 

// XDSPacket.cpp

#include "XDSPacket.h"


XDSPacket::XDSPacket( BYTE byte1, BYTE byte2 ): 
    _control( byte1 ), _type( byte2 )
{}


void  
XDSPacket::addBytePair( BYTE byte1, BYTE byte2 )
{
    _info += byte1;
    _info += byte2;
}


bool  
XDSPacket::checkSum( BYTE checkSumByte )
{
    // Init sum with the Control/Type pair, and End/Checksum pair
    int sum = (_control & NBITS(7)) + (_type & NBITS(7)) + 
              XDS_END_ALL + (checkSumByte & NBITS(7));
    
    // Add in all the Informational charactors
    for( unsigned int i = 0; i < _info.size(); ++i )
        sum += _info[i] & NBITS(7);

    return (sum & NBITS(7)) == 0;
}


void  
XDSPacket::clearInfo()
{
    _info.resize( 0 );
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?