API: Added icsneoc2.

Signed-off-by: David Rebbe <drebbe@intrepidcs.com>
This commit is contained in:
David Rebbe
2025-02-04 13:48:43 -05:00
parent c5ba2d8d32
commit 6dd4456f9a
81 changed files with 6731 additions and 364 deletions
+54
View File
@@ -0,0 +1,54 @@
#include "icsneo/icsneo.h"
#include "icsneo/icsneocpp.h"
#include "icsneo/device/devicefinder.h"
#include <string>
#include <algorithm>
using namespace icsneo;
struct icsneoOpenOptions_t {
/** Open the device in online mode on open. */
bool goOnlineOnOpen = true;
/** Enable message polling on open. */
bool enablePollingOnOpen = true;
/** Synchronize the device RTC on open.
* Useful for devices that don't have an RTC battery like ValueCAN4 */
bool syncRTCOnOpen = true;
};
typedef struct icsneo_device_t {
// This is the actual device handle, when its not open it will be NULL.
std::shared_ptr<Device> device;
icsneoOpenOptions_t openOptions;
} *icsneo_device_ptr_t;
icsneo_result_t icsneo_find(icsneo_device_ptr_t* devices, uint32_t* devices_count, void* reserved) {
static std::deque<icsneo_device_t> found_icsneo_devices;
if (!devices || !devices_count) {
return icsneo_error_invalid_parameter;
}
// Find all devices and get the minimum size to process
auto found_devices = DeviceFinder::FindAll();
auto min_size = std::minmax(found_devices.size(), static_cast<size_t>(*devices_count)).first;
// lets resize the array to the minimum size
for (auto i = 0; i < min_size; i++) {
const auto* dev = devices[i];
dev = new icsneo_device_t {};
dev->device = found_devices[i];
}
return icsneo_error_success;
}
icsneo_result_t icsneo_open(icsneo_device_ptr_t* device) {
if (!device) {
return icsneo_error_invalid_parameter;
}
return icsneo_error_success;
}
+51
View File
@@ -0,0 +1,51 @@
#define VER_FILEVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@
#define VER_FILEVERSION_STR "v@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@@BUILD_METADATA_PLUS@ @BUILD_GIT_INFO@"
#define VER_PRODUCTVERSION VER_FILEVERSION
#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR
#ifndef DEBUG
#define VER_DEBUG 0
#else
#define VER_DEBUG VS_FF_DEBUG
#endif
#include <windows.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_PRODUCTVERSION
FILEFLAGSMASK (VS_FF_DEBUG)
FILEFLAGS (VER_DEBUG)
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "Intrepid Control Systems, Inc."
VALUE "FileDescription", "Intrepid Control Systems Open Device Communication C API"
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", "icsneo.dll"
VALUE "LegalCopyright", "Intrepid Control Systems, Inc. (C) 2018-2024"
VALUE "OriginalFilename", "icsneo.dll"
VALUE "ProductName", "libicsneo"
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
END
END
BLOCK "VarFileInfo"
BEGIN
/* The following line should only be modified for localized versions. */
/* It consists of any number of WORD,WORD pairs, with each pair */
/* describing a language,codepage combination supported by the file. */
/* */
/* For example, a file might have values "0x409,1252" indicating that it */
/* supports English language (0x409) in the Windows ANSI codepage (1252). */
VALUE "Translation", 0x409, 1252
END
END