新图文基本通信协议
if ( m_nComType == COMMDATA_TYPE_RS232 ) { bybuf[nLen++] = 0x68; bybuf[nLen++] =0x32; bybuf[nLen++]= 0xff; bybuf[nLen++]= 0x46;//亮度查询 bybuf[nLen++]= 0x01; bybuf[nLen++]= 0x01; wdCheckNum = CheckNum( bybuf , nLen ); ushort2buf( bybuf + nLen , wdCheckNum ); nLen += 2; } else if( m_nComType == COMMDATA_TYPE_NetWork )
{
bybuf[ nLen++] =0xff;
bybuf[ nLen++] = 0xff;
bybuf[ nLen++ ] = 0xff;
bybuf[ nLen ++] = 0xff;
int nPos = nLen;
bybuf[ nLen++] = 0;//长度
bybuf[ nLen++ ] = 0;//长度;
bybuf[ nLen++ ] = 0;//这里应该也是长度
bybuf[ nLen++ ] = 0;//这里应该也是长度
int nLenBegin = nLen;
bybuf[nLen++] = 0x68;
bybuf[nLen++] =0x32;
bybuf[nLen++]=0xff;//控制卡ID
bybuf[nLen++]= 0x46;//亮度查询
bybuf[nLen++]= 0x01;
bybuf[nLen++]= 0x01;
wdCheckNum = CheckNum( bybuf +nLenBegin , nLen - nLenBegin );
ushort2buf( bybuf + nLen , wdCheckNum );
nLen += 2;
ushort2buf( bybuf + nPos , nLen - nLenBegin );
}
else if(m_nComType == COMMDATA_TYPE_LMSERVER)
{
int nLen = 0;
byBuf[ nLen++ ] =0x00;//长度,低字节在前;len(2bytes)+DeviceID(6bytes)+原協議包. len包括“DeviceID(6bytes)+原協議包”的長度,低位在前,
byBuf[ nLen++] = 0x00;//长度;高字节在后
memset( &byBuf[ nLen ] , 0x01, 6 ); //服务器ID,我随便填的
nLen +=6;
int nLenPos = nLen;
//byBuf[ nLen ++] = 0xa5;//开始码
byBuf[ nLen ++] = 0x68;//包类型
byBuf[ nLen ++] = 0x32;//卡类型
byBuf[ nLen ++] = atoi( pPSign->GetID() );//卡ID
byBuf[ nLen ++] = 0x46;//命令码(CMD)
byBuf[ nLen ++] = 0x01;//返回标记
byBuf[ nLen ++] = 0x00;//设置亮度信息
int i = m_Arraylight->GetAt( 1 );
memset( &byBuf[nLen] , m_Arraylight->GetAt( 1 ) , 24 );
nLen +=24;
unsigned short unCheck = 0;
for ( int i = nLenPos ; i < nLen ; i ++ )
unCheck += byBuf[i];
byBuf[ nLen++ ] = (BYTE)unCheck;
byBuf[ nLen++ ] = unCheck>>8;
byBuf[ 0 ] = (BYTE)( nLen -2 );
byBuf[ 1 ] =(BYTE)( ( nLen -2 )>>8);
return nLen;
}
)