自定義MoveCapture函數(shù),用于向串口發(fā)送信息控制云臺。代碼如下:
void CCaptureDlg::MoveCapture(UINT num)
{
VARIANT vt; //定義VARIANT結(jié)構(gòu)變量
SAFEARRAY* pSafe; //定義SAFEARRAY結(jié)構(gòu)指針
SAFEARRAYBOUND band; //定義SAFEARRAYBOUND結(jié)構(gòu)變量
band.cElements = m_Len;
band.lLbound = 0;
pSafe = SafeArrayCreate(VT_UI1,1,&band);
for(long i=0;i<m_Len;i++)
{
SafeArrayPutElement(pSafe,&i,(void*)&m_pData[num][i]);
}
vt.vt = VT_ARRAY |VT_UI1;
vt.parray = pSafe;
m_Com.SetOutput((COleVariant)vt); //向串口發(fā)送數(shù)據(jù)
}