我的目标是注册一个回调函数,并通过回调函数接收报警消息,但我没有得到任何数据。我怀疑我处理回调函数的方法是错误的。你知道吗
我能够从这个setDVRMsgCallback
中得到True
,这意味着调用API是成功的,但是我没有从msgCallback
中得到任何值
代码
class NET_DVR_ALARMER(Structure):
_fields_ = [
("byUserIDValid", c_byte),
("bySerialValid", c_byte),
("byVersionValid", c_byte),
("byDeviceNameValid", c_byte)
]
def msgCallback(lCommand, pAlarmer, pAlarmInfo, dwBufLen, pUser):
print("callback")
print(lCommand)
print(pAlarmer)
print(pAlarmInfo)
return True
def setDVRMsgCallback(sdk, callback):
sdk.NET_DVR_SetDVRMessageCallBack_V31.restype = c_bool
result = sdk.NET_DVR_SetDVRMessageCallBack_V31(callback, None)
print(result)
callback_t = CFUNCTYPE(c_bool, c_long, POINTER(NET_DVR_ALARMER), c_void_p, c_ulong, c_void_p)
callback = callback_t(msgCallback)
setDVRMsgCallback(sdk, callback)
API
BOOL NET_DVR_SetDVRMessageCallBack_V31(
MSGCallBack_V31 fMessageCallBack,
void *pUser
);
参数
fMessageCallBack
[in] Callback function
pUser
[in] User data
回调函数参数
lCommand
[out]Uploaded message type, and the types vary with alarm information. You can distinguish the alarm information according to the types,see details in the "Remarks" table.
pAlarmer
[out] Alarm device information, including device series No., IP address, user login ID handle.
pAlarmInfo
[out] Alarm information, judge the pAlarm structure via the lCommand value, see details in the "Remark" table.
dwBufLen
[out] Alarm information buffer size
pUser
[out] User data
你可以下载他们的SDK here
我已经参考了上面附带的SDK文档。在通过
NET_DVR_SetDVRMessageCallBack_V31
注册回调函数之后,似乎需要调用NET_DVR_SetupAlarmChan_V41
API。你知道吗我觉得你的密码不错。你知道吗
由于API的异步特性,您需要确保程序始终处于侦听/等待模式,以便从回调函数获得结果。你知道吗
相关问题 更多 >
编程相关推荐