自定义MoveCapture函数,用于向串口发送信息控制云台。代码如下:
void CCaptureDlg::MoveCapture(UINT num)
{
VARIANT vt; //定义VARIANT结构变量
SAFEARRAY* pSafe; //定义SAFEARRAY结构指针
SAFEARRAYBOUND band; //定义SAFEARRAYBOUND结构变量
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); //向串口发送数据
}