#include #include #include #include #include // Get the PRIu64 macro for timestamps #define __STDC_FORMAT_MACROS #include // Include icsneo/icsneoc.h to access library functions #include "icsneo/icsneoc.h" #define DEVICES_MAX 16 size_t numDevices = DEVICES_MAX; neodevice_t devices[DEVICES_MAX]; neonetid_t netid = ICSNEO_NETID_HSCAN; int64_t baudrate = 500000; int64_t fdbaudrate = 500000; const neodevice_t* selectedDevice = NULL; int main(int argc, char *argv[]) { if (argc != 5) { printf("Please check parameters!\n\n"); exit(1); } if(strcmp("hscan", argv[2]) == 0) { netid = ICSNEO_NETID_HSCAN; } else if (strcmp("hscan2", argv[2]) == 0) { netid = ICSNEO_NETID_HSCAN2; } else { printf("Please check network\n"); exit(1); } baudrate = atoi(argv[3]); if (baudrate < 20000 || baudrate > 1000000) { printf("Please check range of reqeusted baud rate.\n"); exit(1); } fdbaudrate = atoi(argv[4]); if (fdbaudrate < 20000 || fdbaudrate > 8000000) { printf("Please check range of reqeusted baud rate.\n"); exit(1); } icsneo_findAllDevices(devices, &numDevices); for(size_t i = 0; i < numDevices; i++) { if(strcmp(devices[i].serial,argv[1]) == 0) { if(icsneo_openDevice(&devices[i])) { printf("%s successfully opened!\n\n", devices[i].serial); } else { printf("%s failed to open!\n\n", devices[i].serial); exit(1); } if(icsneo_setBaudrate(&devices[i], netid, baudrate) && icsneo_settingsApply(&devices[i])) { printf("Successfully set %s baudrate for %s to %d!\n\n", argv[2], devices[i].serial, baudrate); } else { printf("FAILED to set %s baudrate for %s to %d!\n\n", argv[2], devices[i].serial, baudrate); exit(1); } if(icsneo_setFDBaudrate(&devices[i], netid, fdbaudrate) && icsneo_settingsApply(&devices[i])) { printf("Successfully set %s FD baudrate for %s to %d!\n\n", argv[2], devices[i].serial, fdbaudrate); } else { printf("FAILED to set %s FD baudrate for %s to %d!\n\n", argv[2], devices[i].serial, fdbaudrate); exit(1); } if(icsneo_closeDevice(&devices[i])) { printf("%s successfully closed!\n\n", devices[i].serial); } else { printf("%s failed to close!\n\n", devices[i].serial); exit(1); } exit(0); } } printf("Something went wrong!!\n"); exit(1); }