libvkdaq
VKINGING 数据采集库 API 文档
 
载入中...
搜索中...
未找到

函数

int32_t VkDaqSetDeviceNotifyCallback (device_notify_callback_t callback)
 设备上线或掉线通知
 

详细描述

函数说明

◆ VkDaqSetDeviceNotifyCallback()

int32_t VkDaqSetDeviceNotifyCallback ( device_notify_callback_t  callback)

设备上线或掉线通知

数据类型 参数 说明
device_notify_callback_t callback 输入函数指针,格式:
void(*device_notify_callback_t)(const char* notifyDevice, int32_t notifyType);
输入函数说明 :
notifyDevice:通知的设备名.
notifyType:设备通知的类型: 0:设备上线. 1:设备掉线

返回
成功时, 返回值 >= 0
失败时, 返回为负值的错误编号.获取详细信息,请调用 VkDaqGetLastErrorInfo

C语言参考

#include <stdio.h>
#include "libvkdaq.h"
// Correct callback function definition
void __cdecl MyDeviceNotifyCallback(const char* deviceName, int32_t notifyType) {
if (notifyType == VkDaq_Val_DeviceNotifyType_Added) {
printf("[Device online] %s\n", deviceName);
}
else if (notifyType == VkDaq_Val_DeviceNotifyType_Removed) {
printf("[Device offline] %s\n", deviceName);
}
}
int main(int argc, char* argv[]) {
// Registering Callbacks
int32_t result = VkDaqSetDeviceNotifyCallback(MyDeviceNotifyCallback);
if (result != 0) {
printf("Failed to set callback! error code: %d\n", result);
return -1;
}
while (1) {
// Keep the program running
}
return 0;
}
int32_t VkDaqSetDeviceNotifyCallback(device_notify_callback_t callback)
设备上线或掉线通知