| libvkdaq VKINGING DAQ Library API Reference |

Loading...
Searching...
No Matches
Functions
Callback
libvkdaq Function interface

## Functions
int32_t | VkDaqSetDeviceNotifyCallback (device_notify_callback_t callback)
| Device online or offline notification.

## Detailed Description

## Function Documentation

## ◆ VkDaqSetDeviceNotifyCallback()

int32_t VkDaqSetDeviceNotifyCallback | ( | device_notify_callback_t | callback | ) |

Device online or offline notification.

data type | parameter | describe
--- | --- | ---
`device_notify_callback_t` | `callback` | Input function pointer, format:： void(*device_notify_callback_t)(const char* notifyDevice, int32_t notifyType); Input function description : notifyDevice：Notification device name. notifyType：Types of device notifications： 0：Device online. 1：Device online

Returns
  On success, return value >= 0.
  On failure, returns a negative error number.For detail, please Call VkDaqGetLastErrorInfo

C language reference
#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;
}
VkDaqSetDeviceNotifyCallback
int32_t VkDaqSetDeviceNotifyCallback(device_notify_callback_t callback)
Device online or offline notification.