From e1e1f62850b278f820f70c06395db2c6764035a5 Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 26 Jul 2024 08:59:01 -0400 Subject: [PATCH 01/14] CANFlash function Signed-off-by: Marcel --- include/methods.h | 9 +++ src/methods.cpp | 139 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 142 insertions(+), 6 deletions(-) diff --git a/include/methods.h b/include/methods.h index 0a4b179ea..b718f5f1c 100644 --- a/include/methods.h +++ b/include/methods.h @@ -25,6 +25,7 @@ extern "C" PyObject* meth_get_error_messages(PyObject* self, PyObject* args); #ifdef _USE_INTERNAL_HEADER_ PyObject* meth_flash_devices(PyObject* self, PyObject* args); + PyObject* meth_CAN_flash_devices(PyObject* self, PyObject* args); #endif // _USE_INTERNAL_HEADER_ PyObject* meth_set_reflash_callback(PyObject* self, PyObject* args); PyObject* meth_get_device_settings(PyObject* self, PyObject* args); @@ -2016,6 +2017,14 @@ static PyMethodDef IcsMethods[] = { meth_flash_devices, METH_VARARGS, "int _stdcall FlashDevice2()"), +#endif +#ifdef _USE_INTERNAL_HEADER_ + _EZ_ICS_STRUCT_METHOD("CAN_flash_devices", + "CANFlashDevice", + "CANFlashDevice", + meth_CAN_flash_devices, + METH_VARARGS, + "int _stdcall CANFlashDevice()"), #endif _EZ_ICS_STRUCT_METHOD("set_reflash_callback", "icsneoSetReflashDisplayCallbacks", diff --git a/src/methods.cpp b/src/methods.cpp index 47baddd79..af21f78d1 100644 --- a/src/methods.cpp +++ b/src/methods.cpp @@ -11,10 +11,19 @@ #endif #include #include "object_spy_message.h" +//#include "object_neo_device.h" #include "setup_module_auto_defines.h" #include - +//typedef struct +//{ +// PyObject_HEAD NeoDevice dev; +// PyObject* name; +// bool auto_cleanup; +// ICS_HANDLE handle; +// PyObject* dict; +//} neo_device_object; +//extern PyTypeObject neo_device_object_type; extern PyTypeObject spy_message_object_type; // __func__, __FUNCTION__ and __PRETTY_FUNCTION__ are not preprocessor macros. // but MSVC doesn't follow c standard and treats __FUNCTION__ as a string literal macro... @@ -354,6 +363,11 @@ bool PyNeoDeviceEx_GetHandle(PyObject* object, void** handle) return false; } *handle = NULL; + + //if (object == Py_None) { + // *handle = 0; + // return true; + //} if (!PyNeoDeviceEx_CheckExact(object)) { return set_ics_exception(exception_runtime_error(), "Object is not of type PyNeoDeviceEx"); } @@ -1542,7 +1556,110 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) return set_ics_exception(exception_runtime_error(), "This is a bug!"); } #endif // _USE_INTERNAL_HEADER_ +#ifdef _USE_INTERNAL_HEADER_ +PyObject* meth_CAN_flash_devices(PyObject* self, PyObject* args) +{ + PyObject* obj = NULL; + PyObject* objCAN = NULL; + PyObject* callback = NULL; + PyObject* dict; + char* path = NULL; + if (!PyArg_ParseTuple(args, arg_parse("OOO|O:", __FUNCTION__), &obj, &objCAN, &dict, &callback)) { + return NULL; + } + if (obj && !PyNeoDeviceEx_CheckExact(obj)) { + return set_ics_exception(exception_runtime_error(), + "First argument must be of PyNeoDeviceEx type"); + } + if (objCAN && !PyNeoDeviceEx_CheckExact(objCAN)) { + return set_ics_exception(exception_runtime_error(), + "Seccond argument must be of PyNeoDeviceEx type"); + } + //neo_device_object* neo_device = (neo_device_object*)obj; + //neo_device_object* neo_device1 = (neo_device_object*)objCAN; + + //NeoDeviceEx neo_device_ex = {}; + //neo_device_ex.neoDevice = PyNeoDevice_GetNeoDevice(obj)->dev; + //NeoDeviceEx CANneo_device_ex = {}; + //neo_device_ex.neoDevice = PyNeoDevice_GetNeoDevice(objCAN)->dev; + Py_buffer buffer = {}; + NeoDeviceEx* nde = NULL; + if (!PyNeoDeviceEx_GetNeoDeviceEx(obj, &buffer, &nde)) { + PyBuffer_Release(&buffer); + return NULL; + } + if (!PyNeoDeviceEx_GetNeoDeviceEx(objCAN, &buffer, &nde)) { + PyBuffer_Release(&buffer); + return NULL; + } + if (PyCallable_Check(callback) || PyObject_HasAttrString(callback, "message_callback")) { + msg_callback = callback; + } else { + msg_callback = NULL; + } + if (dict && !PyDict_CheckExact(dict)) { + return set_ics_exception(exception_runtime_error(), "Seccond argument must be of dictionary type"); + } + void* handle = NULL; +// if (PyNeoDevice_CheckExact(objCAN)) +// handle = PyNeoDevice_GetHandle(objCAN); + if (!PyNeoDeviceEx_GetHandle(objCAN, &handle)) { + return NULL; + } + // Populate rc array from the python dictionary + SReflashChip_t rc[16] = { 0 }; + unsigned long reflash_count = 0; + Py_ssize_t pos = 0; + PyObject *key, *value; + std::string filePath; + while (PyDict_Next(dict, &pos, &key, &value)) { + unsigned long id = PyLong_AsUnsignedLong(key); + char* path = PyUniStr_AsStrOrUTF8(value); + if (!path) { + return NULL; + } + // Make sure the file exists + FILE* file; + if (!(file = fopen(path, "r"))) { + return set_ics_exception(exception_runtime_error(), "IEF file path is not valid"); + } else { + fclose(file); + } + rc[reflash_count].chipId = id; + strcpy(rc[reflash_count].path, path); + reflash_count++; + filePath = path; + printf("File path: %s\n", path); + } + try { + ice::Library* lib = dll_get_library(); + if (!lib) { + char buffer[512]; + return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); + } + ice::Function + CANFlashDevice(lib, "CANFlashDevice"); + Py_BEGIN_ALLOW_THREADS; + if (!CANFlashDevice(0x3835C256, nde, rc, reflash_count, handle, 0, 0, &message_callback)) { + Py_BLOCK_THREADS; + return set_ics_exception(exception_runtime_error(), "CANFlashDevice() Failed"); + } + Py_END_ALLOW_THREADS; + Py_RETURN_NONE; + } catch (ice::Exception& ex) { + return set_ics_exception(exception_runtime_error(), (char*)ex.what()); + } + return set_ics_exception(exception_runtime_error(), "This is a bug!"); +} +#endif // _USE_INTERNAL_HEADER_ PyObject* msg_reflash_callback = NULL; static void message_reflash_callback(const wchar_t* message, unsigned long progress) { @@ -2650,24 +2767,33 @@ PyObject* meth_set_context(PyObject* self, PyObject* args) if (!PyArg_ParseTuple(args, arg_parse("O:", __FUNCTION__), &obj)) { return NULL; } + void* handle = NULL; + //if (obj = Py_None) { + // if (PyNeoDevice_CheckExact(obj)) + // handle = PyNeoDevice_GetHandle(obj); + //} + //else + //{ if (!PyNeoDeviceEx_CheckExact(obj) && !PyLong_CheckExact(obj)) { return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); - } - - void* handle = NULL; + "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx or an integer"); + } + printf("did we get here-1"); if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { return NULL; - } + } + printf("did we get here0"); try { ice::Library* lib = dll_get_library(); if (!lib) { char buffer[512]; return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } + printf("did we get here1"); ice::Function icsneoSetContext(lib, "icsneoSetContext"); Py_BEGIN_ALLOW_THREADS; if (!icsneoSetContext(handle)) { + printf("did we fail here after !icsneoSetContext(handle)"); Py_BLOCK_THREADS; return set_ics_exception(exception_runtime_error(), "icsneoSetContext() Failed"); } @@ -2676,6 +2802,7 @@ PyObject* meth_set_context(PyObject* self, PyObject* args) } catch (ice::Exception& ex) { return set_ics_exception(exception_runtime_error(), (char*)ex.what()); } + printf("did we get here10"); return set_ics_exception(exception_runtime_error(), "This is a bug!"); } From 70a129c45a7805cea11f8e1518b5d671802b6d0d Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 5 Aug 2024 13:46:09 -0400 Subject: [PATCH 02/14] set_context now accepts, NULL, (), NONE, False Signed-off-by: Marcel --- .vscode/launch.json | 2 +- src/methods.cpp | 26 +++++++------------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index d01294534..45e154da7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -48,7 +48,7 @@ "name": "Debugger Attach", "type": "cppvsdbg", "request": "attach", - "pid": "${command:pickProcess}", + //"pid": "${command:pickProcess}", }, /* { diff --git a/src/methods.cpp b/src/methods.cpp index af21f78d1..8baf5f12e 100644 --- a/src/methods.cpp +++ b/src/methods.cpp @@ -363,11 +363,10 @@ bool PyNeoDeviceEx_GetHandle(PyObject* object, void** handle) return false; } *handle = NULL; - - //if (object == Py_None) { - // *handle = 0; - // return true; - //} + if (object == NULL || object == Py_None || object == Py_False || (PyLong_CheckExact(object) && PyLong_AsLong(object) == 0)) { + *handle = NULL; + return true; + } if (!PyNeoDeviceEx_CheckExact(object)) { return set_ics_exception(exception_runtime_error(), "Object is not of type PyNeoDeviceEx"); } @@ -2764,36 +2763,26 @@ PyObject* meth_request_enter_sleep_mode(PyObject* self, PyObject* args) PyObject* meth_set_context(PyObject* self, PyObject* args) { PyObject* obj = NULL; - if (!PyArg_ParseTuple(args, arg_parse("O:", __FUNCTION__), &obj)) { + if (!PyArg_ParseTuple(args, arg_parse("|O:", __FUNCTION__), &obj)) { return NULL; } void* handle = NULL; - //if (obj = Py_None) { - // if (PyNeoDevice_CheckExact(obj)) - // handle = PyNeoDevice_GetHandle(obj); - //} - //else - //{ - if (!PyNeoDeviceEx_CheckExact(obj) && !PyLong_CheckExact(obj)) { + if (!PyNeoDeviceEx_CheckExact(obj) && obj != Py_None && obj == Py_False && obj == 0) { return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx or an integer"); + "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx, integer, False, 0, or NULL"); } - printf("did we get here-1"); if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { return NULL; } - printf("did we get here0"); try { ice::Library* lib = dll_get_library(); if (!lib) { char buffer[512]; return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } - printf("did we get here1"); ice::Function icsneoSetContext(lib, "icsneoSetContext"); Py_BEGIN_ALLOW_THREADS; if (!icsneoSetContext(handle)) { - printf("did we fail here after !icsneoSetContext(handle)"); Py_BLOCK_THREADS; return set_ics_exception(exception_runtime_error(), "icsneoSetContext() Failed"); } @@ -2802,7 +2791,6 @@ PyObject* meth_set_context(PyObject* self, PyObject* args) } catch (ice::Exception& ex) { return set_ics_exception(exception_runtime_error(), (char*)ex.what()); } - printf("did we get here10"); return set_ics_exception(exception_runtime_error(), "This is a bug!"); } From 9accde295667b9ad13fa9646b0b1f7dc4389eafb Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 5 Aug 2024 13:56:22 -0400 Subject: [PATCH 03/14] Set_context not accepts (), NULL, 0, False to release the handle Signed-off-by: Marcel --- src/methods.cpp | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/src/methods.cpp b/src/methods.cpp index af21f78d1..a7d5bf6dc 100644 --- a/src/methods.cpp +++ b/src/methods.cpp @@ -15,15 +15,7 @@ #include "setup_module_auto_defines.h" #include -//typedef struct -//{ -// PyObject_HEAD NeoDevice dev; -// PyObject* name; -// bool auto_cleanup; -// ICS_HANDLE handle; -// PyObject* dict; -//} neo_device_object; -//extern PyTypeObject neo_device_object_type; + extern PyTypeObject spy_message_object_type; // __func__, __FUNCTION__ and __PRETTY_FUNCTION__ are not preprocessor macros. // but MSVC doesn't follow c standard and treats __FUNCTION__ as a string literal macro... @@ -363,11 +355,10 @@ bool PyNeoDeviceEx_GetHandle(PyObject* object, void** handle) return false; } *handle = NULL; - - //if (object == Py_None) { - // *handle = 0; - // return true; - //} + if (object == NULL || object == Py_None || object == Py_False || (PyLong_CheckExact(object) && PyLong_AsLong(object) == 0)) { + *handle = NULL; + return true; + } if (!PyNeoDeviceEx_CheckExact(object)) { return set_ics_exception(exception_runtime_error(), "Object is not of type PyNeoDeviceEx"); } @@ -2768,28 +2759,19 @@ PyObject* meth_set_context(PyObject* self, PyObject* args) return NULL; } void* handle = NULL; - //if (obj = Py_None) { - // if (PyNeoDevice_CheckExact(obj)) - // handle = PyNeoDevice_GetHandle(obj); - //} - //else - //{ - if (!PyNeoDeviceEx_CheckExact(obj) && !PyLong_CheckExact(obj)) { + if (!PyNeoDeviceEx_CheckExact(obj) && obj != Py_None && obj == Py_False && obj == 0) { return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx or an integer"); + "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx, integer, False, 0, or NULL"); } - printf("did we get here-1"); if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { return NULL; } - printf("did we get here0"); try { ice::Library* lib = dll_get_library(); if (!lib) { char buffer[512]; return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } - printf("did we get here1"); ice::Function icsneoSetContext(lib, "icsneoSetContext"); Py_BEGIN_ALLOW_THREADS; if (!icsneoSetContext(handle)) { @@ -2802,7 +2784,6 @@ PyObject* meth_set_context(PyObject* self, PyObject* args) } catch (ice::Exception& ex) { return set_ics_exception(exception_runtime_error(), (char*)ex.what()); } - printf("did we get here10"); return set_ics_exception(exception_runtime_error(), "This is a bug!"); } From 635dbfa26258740165a3b917a05dca6ac301e74a Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 13 Aug 2024 10:13:53 -0400 Subject: [PATCH 04/14] FlashDevice2 supports NetworkID Signed-off-by: Marcel --- src/methods.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/methods.cpp b/src/methods.cpp index 8baf5f12e..7b7b4d743 100644 --- a/src/methods.cpp +++ b/src/methods.cpp @@ -15,15 +15,7 @@ #include "setup_module_auto_defines.h" #include -//typedef struct -//{ -// PyObject_HEAD NeoDevice dev; -// PyObject* name; -// bool auto_cleanup; -// ICS_HANDLE handle; -// PyObject* dict; -//} neo_device_object; -//extern PyTypeObject neo_device_object_type; + extern PyTypeObject spy_message_object_type; // __func__, __FUNCTION__ and __PRETTY_FUNCTION__ are not preprocessor macros. // but MSVC doesn't follow c standard and treats __FUNCTION__ as a string literal macro... @@ -1481,7 +1473,8 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) PyObject* obj = NULL; PyObject* callback = NULL; PyObject* dict; - if (!PyArg_ParseTuple(args, arg_parse("OO|O:", __FUNCTION__), &obj, &dict, &callback)) { + int network_id = -1; + if (!PyArg_ParseTuple(args, arg_parse("OO|Oi:", __FUNCTION__), &obj, &dict, &callback, &network_id)) { return NULL; } if (obj && !PyNeoDeviceEx_CheckExact(obj)) { @@ -1518,6 +1511,13 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) strcpy(rc[reflash_count].path, path); reflash_count++; } + //handle network_id if provided, otherwise 0 + OptionsFindNeoEx opts = { 0 }; + opts.CANOptions.iNetworkID = static_cast(network_id); + POptionsFindNeoEx popts = NULL; + if (network_id != -1) + popts = &opts; + try { ice::Library* lib = dll_get_library(); if (!lib) { @@ -1541,7 +1541,7 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) void (*MessageCallback)(const char* message, bool success))> FlashDevice2(lib, "FlashDevice2"); Py_BEGIN_ALLOW_THREADS; - if (!FlashDevice2(0x3835C256, &nde->neoDevice, rc, reflash_count, 0, 0, 0, &message_callback)) { + if (!FlashDevice2(0x3835C256, &nde->neoDevice, rc, reflash_count, network_id, 0, 0, &message_callback)) { Py_BLOCK_THREADS; PyBuffer_Release(&buffer); return set_ics_exception(exception_runtime_error(), "FlashDevice2() Failed"); @@ -1658,7 +1658,7 @@ PyObject* meth_CAN_flash_devices(PyObject* self, PyObject* args) } return set_ics_exception(exception_runtime_error(), "This is a bug!"); } -#endif // _USE_INTERNAL_HEADER_ +#endif // _USE_INTERNAL_HEADER_ PyObject* msg_reflash_callback = NULL; static void message_reflash_callback(const wchar_t* message, unsigned long progress) { @@ -2763,11 +2763,11 @@ PyObject* meth_request_enter_sleep_mode(PyObject* self, PyObject* args) PyObject* meth_set_context(PyObject* self, PyObject* args) { PyObject* obj = NULL; - if (!PyArg_ParseTuple(args, arg_parse("|O:", __FUNCTION__), &obj)) { + if (!PyArg_ParseTuple(args, arg_parse("O:", __FUNCTION__), &obj)) { return NULL; } void* handle = NULL; - if (!PyNeoDeviceEx_CheckExact(obj) && obj != Py_None && obj == Py_False && obj == 0) { + if (!PyNeoDeviceEx_CheckExact(obj) && obj != Py_None && obj == Py_False && obj == 0) { return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx, integer, False, 0, or NULL"); } From ec34746fe09abba4d2669993a9de3b1ef66c114c Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 13 Aug 2024 10:34:37 -0400 Subject: [PATCH 05/14] Removing CANFlash merged with FlashDevice2 Signed-off-by: Marcel --- include/methods.h | 9 ---- src/methods.cpp | 104 ---------------------------------------------- 2 files changed, 113 deletions(-) diff --git a/include/methods.h b/include/methods.h index b718f5f1c..0a4b179ea 100644 --- a/include/methods.h +++ b/include/methods.h @@ -25,7 +25,6 @@ extern "C" PyObject* meth_get_error_messages(PyObject* self, PyObject* args); #ifdef _USE_INTERNAL_HEADER_ PyObject* meth_flash_devices(PyObject* self, PyObject* args); - PyObject* meth_CAN_flash_devices(PyObject* self, PyObject* args); #endif // _USE_INTERNAL_HEADER_ PyObject* meth_set_reflash_callback(PyObject* self, PyObject* args); PyObject* meth_get_device_settings(PyObject* self, PyObject* args); @@ -2017,14 +2016,6 @@ static PyMethodDef IcsMethods[] = { meth_flash_devices, METH_VARARGS, "int _stdcall FlashDevice2()"), -#endif -#ifdef _USE_INTERNAL_HEADER_ - _EZ_ICS_STRUCT_METHOD("CAN_flash_devices", - "CANFlashDevice", - "CANFlashDevice", - meth_CAN_flash_devices, - METH_VARARGS, - "int _stdcall CANFlashDevice()"), #endif _EZ_ICS_STRUCT_METHOD("set_reflash_callback", "icsneoSetReflashDisplayCallbacks", diff --git a/src/methods.cpp b/src/methods.cpp index 7b7b4d743..929beb6b0 100644 --- a/src/methods.cpp +++ b/src/methods.cpp @@ -1555,110 +1555,6 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) return set_ics_exception(exception_runtime_error(), "This is a bug!"); } #endif // _USE_INTERNAL_HEADER_ -#ifdef _USE_INTERNAL_HEADER_ -PyObject* meth_CAN_flash_devices(PyObject* self, PyObject* args) -{ - PyObject* obj = NULL; - PyObject* objCAN = NULL; - PyObject* callback = NULL; - PyObject* dict; - char* path = NULL; - if (!PyArg_ParseTuple(args, arg_parse("OOO|O:", __FUNCTION__), &obj, &objCAN, &dict, &callback)) { - return NULL; - } - if (obj && !PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "First argument must be of PyNeoDeviceEx type"); - } - if (objCAN && !PyNeoDeviceEx_CheckExact(objCAN)) { - return set_ics_exception(exception_runtime_error(), - "Seccond argument must be of PyNeoDeviceEx type"); - } - //neo_device_object* neo_device = (neo_device_object*)obj; - //neo_device_object* neo_device1 = (neo_device_object*)objCAN; - - //NeoDeviceEx neo_device_ex = {}; - //neo_device_ex.neoDevice = PyNeoDevice_GetNeoDevice(obj)->dev; - //NeoDeviceEx CANneo_device_ex = {}; - //neo_device_ex.neoDevice = PyNeoDevice_GetNeoDevice(objCAN)->dev; - - Py_buffer buffer = {}; - NeoDeviceEx* nde = NULL; - if (!PyNeoDeviceEx_GetNeoDeviceEx(obj, &buffer, &nde)) { - PyBuffer_Release(&buffer); - return NULL; - } - if (!PyNeoDeviceEx_GetNeoDeviceEx(objCAN, &buffer, &nde)) { - PyBuffer_Release(&buffer); - return NULL; - } - if (PyCallable_Check(callback) || PyObject_HasAttrString(callback, "message_callback")) { - msg_callback = callback; - } else { - msg_callback = NULL; - } - if (dict && !PyDict_CheckExact(dict)) { - return set_ics_exception(exception_runtime_error(), "Seccond argument must be of dictionary type"); - } - void* handle = NULL; -// if (PyNeoDevice_CheckExact(objCAN)) -// handle = PyNeoDevice_GetHandle(objCAN); - if (!PyNeoDeviceEx_GetHandle(objCAN, &handle)) { - return NULL; - } - // Populate rc array from the python dictionary - SReflashChip_t rc[16] = { 0 }; - unsigned long reflash_count = 0; - Py_ssize_t pos = 0; - PyObject *key, *value; - std::string filePath; - while (PyDict_Next(dict, &pos, &key, &value)) { - unsigned long id = PyLong_AsUnsignedLong(key); - char* path = PyUniStr_AsStrOrUTF8(value); - if (!path) { - return NULL; - } - // Make sure the file exists - FILE* file; - if (!(file = fopen(path, "r"))) { - return set_ics_exception(exception_runtime_error(), "IEF file path is not valid"); - } else { - fclose(file); - } - rc[reflash_count].chipId = id; - strcpy(rc[reflash_count].path, path); - reflash_count++; - filePath = path; - printf("File path: %s\n", path); - } - try { - ice::Library* lib = dll_get_library(); - if (!lib) { - char buffer[512]; - return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); - } - ice::Function - CANFlashDevice(lib, "CANFlashDevice"); - Py_BEGIN_ALLOW_THREADS; - if (!CANFlashDevice(0x3835C256, nde, rc, reflash_count, handle, 0, 0, &message_callback)) { - Py_BLOCK_THREADS; - return set_ics_exception(exception_runtime_error(), "CANFlashDevice() Failed"); - } - Py_END_ALLOW_THREADS; - Py_RETURN_NONE; - } catch (ice::Exception& ex) { - return set_ics_exception(exception_runtime_error(), (char*)ex.what()); - } - return set_ics_exception(exception_runtime_error(), "This is a bug!"); -} -#endif // _USE_INTERNAL_HEADER_ PyObject* msg_reflash_callback = NULL; static void message_reflash_callback(const wchar_t* message, unsigned long progress) { From e8f7b5e18b141723f645abf85cce441c6d5c40e5 Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 20 Sep 2024 13:52:02 -0400 Subject: [PATCH 06/14] Removed code and added network and ran clang-format Signed-off-by: Marcel --- .vscode/launch.json | 2 +- src/methods.cpp | 436 ++++++++++++++++++-------------------------- 2 files changed, 181 insertions(+), 257 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 45e154da7..d01294534 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -48,7 +48,7 @@ "name": "Debugger Attach", "type": "cppvsdbg", "request": "attach", - //"pid": "${command:pickProcess}", + "pid": "${command:pickProcess}", }, /* { diff --git a/src/methods.cpp b/src/methods.cpp index 929beb6b0..f5ee34eca 100644 --- a/src/methods.cpp +++ b/src/methods.cpp @@ -11,7 +11,6 @@ #endif #include #include "object_spy_message.h" -//#include "object_neo_device.h" #include "setup_module_auto_defines.h" #include @@ -279,10 +278,9 @@ bool PyNeoDeviceEx_CheckExact(PyObject* object) return strncmp(type_obj->tp_name, CLASS_NAME, sizeof(CLASS_NAME) / sizeof(CLASS_NAME[0])) == 0; // This will fail on cleanup because we can't import ics anymore... - //return _isPythonModuleObject_IsInstance(object, "ics.py_neo_device_ex", "PyNeoDeviceEx") == 1; + // return _isPythonModuleObject_IsInstance(object, "ics.py_neo_device_ex", "PyNeoDeviceEx") == 1; } - // Get the NeoDeviceEx from PyNeoDeviceEx. Caller is responsible for managing the // Py_buffer and nde is UB once Py_buffer goes out of scope. // Note: Calls to PyNeoDeviceEx_GetNeoDeviceEx() must be paired with calls @@ -292,8 +290,8 @@ bool PyNeoDeviceEx_CheckExact(PyObject* object) // Example: // Py_buffer buffer = {}; // NeoDeviceEx* nde = NULL; -// if (PyNeoDeviceEx_GetNeoDeviceEx(obj, &buffer, &nde)) { -// // use nde here +// if (PyNeoDeviceEx_GetNeoDeviceEx(obj, &buffer, &nde)) { +// // use nde here // } // PyBuffer_Release(&buffer); bool PyNeoDeviceEx_GetNeoDeviceEx(PyObject* object, Py_buffer* buffer, NeoDeviceEx** nde) @@ -355,7 +353,8 @@ bool PyNeoDeviceEx_GetHandle(PyObject* object, void** handle) return false; } *handle = NULL; - if (object == NULL || object == Py_None || object == Py_False || (PyLong_CheckExact(object) && PyLong_AsLong(object) == 0)) { + if (object == NULL || object == Py_None || object == Py_False || + (PyLong_CheckExact(object) && PyLong_AsLong(object) == 0)) { *handle = NULL; return true; } @@ -377,7 +376,6 @@ bool PyNeoDeviceEx_GetHandle(PyObject* object, void** handle) return true; } - // Set the _handle attribute of PyNeoDeviceEx. // Returns false on error and exception is set. Returns true on success. bool PyNeoDeviceEx_SetHandle(PyObject* object, void* handle) @@ -388,7 +386,7 @@ bool PyNeoDeviceEx_SetHandle(PyObject* object, void* handle) } if (!PyNeoDeviceEx_CheckExact(object)) { set_ics_exception(exception_runtime_error(), "Object is not of type PyNeoDeviceEx"); - return false; + return false; } PyObject* _handle = PyObject_GetAttrString(object, "_handle"); if (!_handle) { @@ -451,7 +449,6 @@ bool PyNeoDeviceEx_SetName(PyObject* object, PyObject* name) return PyObject_SetAttrString(object, "_name", name) == 0; } - PyObject* meth_find_devices(PyObject* self, PyObject* args, PyObject* keywords) { PyObject* device_types = NULL; @@ -528,11 +525,8 @@ PyObject* meth_find_devices(PyObject* self, PyObject* args, PyObject* keywords) if (!PyNeoDeviceEx_SetNeoDeviceEx(obj, &devices[i])) { return NULL; } - if (!PyNeoDeviceEx_SetName(obj, - PyUnicode_FromString( - neodevice_to_string(devices[i].neoDevice.DeviceType) - )) - ) { + if (!PyNeoDeviceEx_SetName(obj, + PyUnicode_FromString(neodevice_to_string(devices[i].neoDevice.DeviceType)))) { return NULL; } PyTuple_SetItem(tuple, i, obj); @@ -668,11 +662,8 @@ PyObject* meth_open_device(PyObject* self, PyObject* args, PyObject* keywords) if (!PyNeoDeviceEx_SetNeoDeviceEx(device, &devices[i])) { return NULL; } - if (!PyNeoDeviceEx_SetName(device, - PyUnicode_FromString( - neodevice_to_string(devices[i].neoDevice.DeviceType) - )) - ) { + if (!PyNeoDeviceEx_SetName( + device, PyUnicode_FromString(neodevice_to_string(devices[i].neoDevice.DeviceType)))) { return NULL; } break; @@ -749,12 +740,10 @@ PyObject* meth_close_device(PyObject* self, PyObject* args) return NULL; } if (obj == NULL) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type PyNeoDeviceEx, got NULL"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type PyNeoDeviceEx, got NULL"); } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type PyNeoDeviceEx"); } try { ice::Library* lib = dll_get_library(); @@ -835,8 +824,7 @@ PyObject* meth_get_rtc(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -896,8 +884,7 @@ PyObject* meth_set_rtc(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -957,8 +944,7 @@ PyObject* meth_coremini_load(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -1000,8 +986,8 @@ PyObject* meth_coremini_load(PyObject* self, PyObject* args) for (int i = 0; i < tuple_size; ++i) { PyObject* value = PyTuple_GET_ITEM(arg_data, i); if (!PyLong_CheckExact(value)) { - return set_ics_exception( - exception_runtime_error(), "Failed to convert tuple data. Tuple data must be integer type"); + return set_ics_exception(exception_runtime_error(), + "Failed to convert tuple data. Tuple data must be integer type"); } data[i] = (unsigned char)PyLong_AsLong(PyTuple_GET_ITEM(arg_data, i)); } @@ -1039,8 +1025,7 @@ PyObject* meth_coremini_start(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -1073,8 +1058,7 @@ PyObject* meth_coremini_stop(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -1108,8 +1092,7 @@ PyObject* meth_coremini_clear(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -1143,8 +1126,7 @@ PyObject* meth_coremini_get_status(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -1181,8 +1163,7 @@ PyObject* meth_transmit_messages(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -1260,8 +1241,7 @@ PyObject* meth_get_messages(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -1277,8 +1257,7 @@ PyObject* meth_get_messages(PyObject* self, PyObject* args) } ice::Function icsneoWaitForRxMessagesWithTimeOut( lib, "icsneoWaitForRxMessagesWithTimeOut"); - ice::Function icsneoGetMessages(lib, - "icsneoGetMessages"); + ice::Function icsneoGetMessages(lib, "icsneoGetMessages"); int count = 20000; int errors = 0; union SpyMessage @@ -1314,8 +1293,7 @@ PyObject* meth_get_messages(PyObject* self, PyObject* args) if (!obj) { // This should only happen if we run out of memory (malloc failure)? PyErr_Print(); - return set_ics_exception( - exception_runtime_error(), "Failed to allocate " SPY_MESSAGE_OBJECT_NAME); + return set_ics_exception(exception_runtime_error(), "Failed to allocate " SPY_MESSAGE_OBJECT_NAME); } if (use_j1850) { spy_message_j1850_object* msg = (spy_message_j1850_object*)obj; @@ -1349,8 +1327,7 @@ PyObject* meth_get_script_status(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -1393,8 +1370,7 @@ PyObject* meth_get_error_messages(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -1412,8 +1388,7 @@ PyObject* meth_get_error_messages(PyObject* self, PyObject* args) ice::Function icsneoGetErrorMessages(lib, "icsneoGetErrorMessages"); Py_BEGIN_ALLOW_THREADS; if (!icsneoGetErrorMessages(handle, errors, &error_count)) { - Py_BLOCK_THREADS return set_ics_exception(exception_runtime_error(), - "icsneoGetErrorMessages() Failed"); + Py_BLOCK_THREADS return set_ics_exception(exception_runtime_error(), "icsneoGetErrorMessages() Failed"); } Py_END_ALLOW_THREADS; ice::Function icsneoGetErrorInfo( @@ -1478,8 +1453,7 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) return NULL; } if (obj && !PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "First argument must be of PyNeoDeviceEx type"); + return set_ics_exception(exception_runtime_error(), "First argument must be of PyNeoDeviceEx type"); } if (PyCallable_Check(callback) || PyObject_HasAttrString(callback, "message_callback")) { msg_callback = callback; @@ -1509,15 +1483,20 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) } rc[reflash_count].chipId = id; strcpy(rc[reflash_count].path, path); + printf(path); reflash_count++; } - //handle network_id if provided, otherwise 0 + // handle network_id if provided, otherwise 0 OptionsFindNeoEx opts = { 0 }; opts.CANOptions.iNetworkID = static_cast(network_id); POptionsFindNeoEx popts = NULL; if (network_id != -1) popts = &opts; + unsigned long iOptions = 0; // Initialize with default value of 0 + if (network_id != -1) { + iOptions = opts.CANOptions.iNetworkID; // Set to network_id if it's not -1 + } try { ice::Library* lib = dll_get_library(); if (!lib) { @@ -1541,7 +1520,8 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) void (*MessageCallback)(const char* message, bool success))> FlashDevice2(lib, "FlashDevice2"); Py_BEGIN_ALLOW_THREADS; - if (!FlashDevice2(0x3835C256, &nde->neoDevice, rc, reflash_count, network_id, 0, 0, &message_callback)) { + if (!FlashDevice2( + 0x3835C256, &nde->neoDevice, rc, reflash_count, network_id, iOptions, 0, &message_callback)) { Py_BLOCK_THREADS; PyBuffer_Release(&buffer); return set_ics_exception(exception_runtime_error(), "FlashDevice2() Failed"); @@ -1555,6 +1535,7 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) return set_ics_exception(exception_runtime_error(), "This is a bug!"); } #endif // _USE_INTERNAL_HEADER_ + PyObject* msg_reflash_callback = NULL; static void message_reflash_callback(const wchar_t* message, unsigned long progress) { @@ -1633,8 +1614,7 @@ PyObject* meth_get_device_settings(PyObject* self, PyObject* args) if (!PyNeoDeviceEx_CheckExact(obj)) { PyBuffer_Release(&settings_buffer); Py_DECREF(settings); - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -1665,9 +1645,10 @@ PyObject* meth_get_device_settings(PyObject* self, PyObject* args) } // int _stdcall icsneoGetDeviceSettings(void* hObject, SDeviceSettings* pSettings, int iNumBytes, // EPlasmaIonVnetChannel_t vnetSlot) - ice::Function - icsneoGetDeviceSettings(lib, "icsneoGetDeviceSettings"); - if (!icsneoGetDeviceSettings(handle, (SDeviceSettings*)settings_buffer.buf, static_cast(settings_buffer.len), vnet_slot)) { + ice::Function icsneoGetDeviceSettings( + lib, "icsneoGetDeviceSettings"); + if (!icsneoGetDeviceSettings( + handle, (SDeviceSettings*)settings_buffer.buf, static_cast(settings_buffer.len), vnet_slot)) { Py_BLOCK_THREADS; PyBuffer_Release(&settings_buffer); Py_DECREF(settings); @@ -1693,8 +1674,7 @@ PyObject* meth_set_device_settings(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -1715,8 +1695,11 @@ PyObject* meth_set_device_settings(PyObject* self, PyObject* args) Py_buffer settings_buffer = {}; PyObject_GetBuffer(settings, &settings_buffer, PyBUF_CONTIG); Py_BEGIN_ALLOW_THREADS; - if (!icsneoSetDeviceSettings( - handle, (SDeviceSettings*)settings_buffer.buf, static_cast(settings_buffer.len), save_to_eeprom, vnet_slot)) { + if (!icsneoSetDeviceSettings(handle, + (SDeviceSettings*)settings_buffer.buf, + static_cast(settings_buffer.len), + save_to_eeprom, + vnet_slot)) { Py_BLOCK_THREADS; PyBuffer_Release(&settings_buffer); return set_ics_exception(exception_runtime_error(), "icsneoSetDeviceSettings() Failed"); @@ -1737,8 +1720,7 @@ PyObject* meth_load_default_settings(PyObject* self, PyObject* args) // icsneoLo return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -1755,9 +1737,9 @@ PyObject* meth_load_default_settings(PyObject* self, PyObject* args) // icsneoLo } ice::Function icsneoLoadDefaultSettings(lib, "icsneoLoadDefaultSettings"); void* handle = NULL; - if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { - return NULL; - } + if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { + return NULL; + } Py_BEGIN_ALLOW_THREADS; if (!icsneoLoadDefaultSettings(handle)) { Py_BLOCK_THREADS; @@ -1782,8 +1764,7 @@ PyObject* meth_read_sdcard(PyObject* self, return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } // We only read 512 bytes internally, x4 for future compatibility? unsigned char data[2048] = { 0 }; @@ -1796,9 +1777,9 @@ PyObject* meth_read_sdcard(PyObject* self, ice::Function icsneoReadSDCard( lib, "icsneoReadSDCard"); void* handle = NULL; - if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { - return NULL; - } + if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { + return NULL; + } Py_BEGIN_ALLOW_THREADS; if (!icsneoReadSDCard(handle, index, data, &size)) { Py_BLOCK_THREADS; @@ -1832,8 +1813,7 @@ PyObject* meth_write_sdcard( return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } if (!PyByteArray_CheckExact(ba_obj)) { return set_ics_exception(exception_runtime_error(), "Argument must be a bytearray"); @@ -1848,12 +1828,11 @@ PyObject* meth_write_sdcard( char buffer[512]; return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } - ice::Function icsneoWriteSDCard(lib, - "icsneoWriteSDCard"); + ice::Function icsneoWriteSDCard(lib, "icsneoWriteSDCard"); void* handle = NULL; - if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { - return NULL; - } + if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { + return NULL; + } Py_BEGIN_ALLOW_THREADS; if (!icsneoWriteSDCard(handle, index, (unsigned char*)PyByteArray_AsString(ba_obj))) { Py_BLOCK_THREADS; @@ -1927,8 +1906,7 @@ PyObject* meth_coremini_start_fblock(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -1962,8 +1940,7 @@ PyObject* meth_coremini_stop_fblock(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -1997,8 +1974,7 @@ PyObject* meth_coremini_get_fblock_status(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2034,8 +2010,7 @@ PyObject* meth_coremini_read_app_signal(PyObject* self, PyObject* args) // Scrip return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2072,8 +2047,7 @@ PyObject* meth_coremini_write_app_signal(PyObject* self, PyObject* args) // Scri return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2109,8 +2083,7 @@ PyObject* meth_coremini_read_tx_message(PyObject* self, PyObject* args) // Scrip return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2122,8 +2095,8 @@ PyObject* meth_coremini_read_tx_message(PyObject* self, PyObject* args) // Scrip char buffer[512]; return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } - ice::Function icsneoScriptReadTxMessage( - lib, "icsneoScriptReadTxMessage"); + ice::Function icsneoScriptReadTxMessage(lib, + "icsneoScriptReadTxMessage"); PyObject* msg = NULL; if (j1850) { msg = PyObject_CallObject((PyObject*)&spy_message_j1850_object_type, NULL); @@ -2169,8 +2142,7 @@ PyObject* meth_coremini_read_rx_message(PyObject* self, PyObject* args) // Scrip return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2248,8 +2220,7 @@ PyObject* meth_coremini_write_tx_message(PyObject* self, PyObject* args) // icsn return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2304,8 +2275,7 @@ PyObject* meth_coremini_write_rx_message(PyObject* self, PyObject* args) // icsn return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2365,8 +2335,7 @@ PyObject* meth_get_performance_parameters(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2425,7 +2394,8 @@ PyObject* meth_validate_hobject(PyObject* self, PyObject* args) } if (!PyLong_CheckExact(obj) && !PyNeoDeviceEx_CheckExact(obj)) { return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx" " or Integer"); + "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx" + " or Integer"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2458,8 +2428,7 @@ PyObject* meth_get_last_api_error(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2529,8 +2498,7 @@ PyObject* meth_get_serial_number(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2564,8 +2532,7 @@ PyObject* meth_get_hw_firmware_info(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2577,8 +2544,7 @@ PyObject* meth_get_hw_firmware_info(PyObject* self, PyObject* args) char buffer[512]; return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } - ice::Function icsneoGetHWFirmwareInfo(lib, - "icsneoGetHWFirmwareInfo"); + ice::Function icsneoGetHWFirmwareInfo(lib, "icsneoGetHWFirmwareInfo"); PyObject* info = _getPythonModuleObject("ics.structures.st_api_firmware_info", "st_api_firmware_info"); if (!info) { return NULL; @@ -2628,8 +2594,7 @@ PyObject* meth_request_enter_sleep_mode(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2663,13 +2628,13 @@ PyObject* meth_set_context(PyObject* self, PyObject* args) return NULL; } void* handle = NULL; - if (!PyNeoDeviceEx_CheckExact(obj) && obj != Py_None && obj == Py_False && obj == 0) { + if (!PyNeoDeviceEx_CheckExact(obj) && obj != Py_None && obj == Py_False && obj == 0) { return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx, integer, False, 0, or NULL"); - } + "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx, integer, False, 0, or NULL"); + } if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { return NULL; - } + } try { ice::Library* lib = dll_get_library(); if (!lib) { @@ -2679,6 +2644,7 @@ PyObject* meth_set_context(PyObject* self, PyObject* args) ice::Function icsneoSetContext(lib, "icsneoSetContext"); Py_BEGIN_ALLOW_THREADS; if (!icsneoSetContext(handle)) { + printf("did we fail here after !icsneoSetContext(handle)"); Py_BLOCK_THREADS; return set_ics_exception(exception_runtime_error(), "icsneoSetContext() Failed"); } @@ -2697,8 +2663,7 @@ PyObject* meth_force_firmware_update(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj) && !PyLong_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2731,8 +2696,7 @@ PyObject* meth_firmware_update_required(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj) && !PyLong_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2765,8 +2729,7 @@ PyObject* meth_get_dll_firmware_info(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2778,8 +2741,8 @@ PyObject* meth_get_dll_firmware_info(PyObject* self, PyObject* args) char buffer[512]; return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } - ice::Function icsneoGetDLLFirmwareInfo( - lib, "icsneoGetDLLFirmwareInfo"); + ice::Function icsneoGetDLLFirmwareInfo(lib, + "icsneoGetDLLFirmwareInfo"); PyObject* info = _getPythonModuleObject("ics.structures.st_api_firmware_info", "st_api_firmware_info"); if (!info) { return NULL; @@ -2807,8 +2770,7 @@ PyObject* meth_get_backup_power_enabled(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2820,8 +2782,8 @@ PyObject* meth_get_backup_power_enabled(PyObject* self, PyObject* args) char buffer[512]; return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } - ice::Function icsneoGetBackupPowerEnabled( - lib, "icsneoGetBackupPowerEnabled"); + ice::Function icsneoGetBackupPowerEnabled(lib, + "icsneoGetBackupPowerEnabled"); Py_BEGIN_ALLOW_THREADS; if (!icsneoGetBackupPowerEnabled(handle, enabled)) { Py_BLOCK_THREADS; @@ -2843,8 +2805,7 @@ PyObject* meth_set_backup_power_enabled(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2856,8 +2817,8 @@ PyObject* meth_set_backup_power_enabled(PyObject* self, PyObject* args) char buffer[512]; return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } - ice::Function icsneoSetBackupPowerEnabled( - lib, "icsneoSetBackupPowerEnabled"); + ice::Function icsneoSetBackupPowerEnabled(lib, + "icsneoSetBackupPowerEnabled"); Py_BEGIN_ALLOW_THREADS; if (!icsneoSetBackupPowerEnabled(handle, enabled)) { Py_BLOCK_THREADS; @@ -2879,8 +2840,7 @@ PyObject* meth_get_backup_power_ready(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2892,8 +2852,7 @@ PyObject* meth_get_backup_power_ready(PyObject* self, PyObject* args) char buffer[512]; return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } - ice::Function icsneoGetBackupPowerReady(lib, - "icsneoGetBackupPowerReady"); + ice::Function icsneoGetBackupPowerReady(lib, "icsneoGetBackupPowerReady"); Py_BEGIN_ALLOW_THREADS; if (!icsneoGetBackupPowerReady(handle, enabled)) { Py_BLOCK_THREADS; @@ -2918,8 +2877,7 @@ PyObject* meth_load_readbin(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -2961,8 +2919,8 @@ PyObject* meth_load_readbin(PyObject* self, PyObject* args) for (int i = 0; i < tuple_size; ++i) { PyObject* value = PyTuple_GET_ITEM(arg_data, i); if (!PyLong_CheckExact(value)) { - return set_ics_exception( - exception_runtime_error(), "Failed to convert tuple data. Tuple data must be integer type"); + return set_ics_exception(exception_runtime_error(), + "Failed to convert tuple data. Tuple data must be integer type"); } data[i] = (unsigned char)PyLong_AsLong(PyTuple_GET_ITEM(arg_data, i)); } @@ -3004,8 +2962,7 @@ PyObject* meth_iso15765_transmit_message(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } if (_isPythonModuleObject_IsInstance( obj_tx_msg, "ics.structures.st_cm_iso157652_tx_message", "st_cm_iso157652_tx_message") != 1) { @@ -3052,8 +3009,7 @@ PyObject* meth_iso15765_receive_message(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } if (_isPythonModuleObject_IsInstance( obj_rx_msg, "ics.structures.st_cm_iso157652_rx_message", "st_cm_iso157652_rx_message") != 1) { @@ -3101,8 +3057,7 @@ PyObject* meth_iso15765_enable_networks(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3136,8 +3091,7 @@ PyObject* meth_iso15765_disable_networks(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3171,8 +3125,7 @@ PyObject* meth_get_active_vnet_channel(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3184,8 +3137,8 @@ PyObject* meth_get_active_vnet_channel(PyObject* self, PyObject* args) char buffer[512]; return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } - ice::Function icsneoGetActiveVNETChannel( - lib, "icsneoGetActiveVNETChannel"); + ice::Function icsneoGetActiveVNETChannel(lib, + "icsneoGetActiveVNETChannel"); Py_BEGIN_ALLOW_THREADS; if (!icsneoGetActiveVNETChannel(handle, &channel)) { Py_BLOCK_THREADS; @@ -3207,8 +3160,7 @@ PyObject* meth_set_active_vnet_channel(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3220,8 +3172,8 @@ PyObject* meth_set_active_vnet_channel(PyObject* self, PyObject* args) char buffer[512]; return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } - ice::Function icsneoSetActiveVNETChannel( - lib, "icsneoSetActiveVNETChannel"); + ice::Function icsneoSetActiveVNETChannel(lib, + "icsneoSetActiveVNETChannel"); Py_BEGIN_ALLOW_THREADS; if (!icsneoSetActiveVNETChannel(handle, channel)) { Py_BLOCK_THREADS; @@ -3244,8 +3196,7 @@ PyObject* meth_set_bit_rate(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3280,8 +3231,7 @@ PyObject* meth_set_fd_bit_rate(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3317,8 +3267,7 @@ PyObject* meth_set_bit_rate_ex(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3352,8 +3301,7 @@ PyObject* meth_get_timestamp_for_msg(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } if (!PySpyMessage_CheckExact(obj_msg) && !PySpyMessageJ1850_CheckExact(obj_msg)) { return set_ics_exception(exception_runtime_error(), @@ -3394,8 +3342,7 @@ PyObject* meth_get_device_status(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3415,8 +3362,8 @@ PyObject* meth_get_device_status(PyObject* self, PyObject* args) PyObject_GetBuffer(device_status, &device_status_buffer, PyBUF_CONTIG); size_t device_status_size = device_status_buffer.len; - ice::Function icsneoGetDeviceStatus( - lib, "icsneoGetDeviceStatus"); + ice::Function icsneoGetDeviceStatus(lib, + "icsneoGetDeviceStatus"); double timestamp = 0; Py_BEGIN_ALLOW_THREADS; if (!icsneoGetDeviceStatus(handle, (icsDeviceStatus*)device_status_buffer.buf, &device_status_size)) { @@ -3448,8 +3395,7 @@ PyObject* meth_enable_network_com(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3494,8 +3440,7 @@ PyObject* meth_enable_bus_voltage_monitor(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3531,8 +3476,7 @@ PyObject* meth_get_bus_voltage(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3546,8 +3490,8 @@ PyObject* meth_get_bus_voltage(PyObject* self, PyObject* args) return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } // int _stdcall icsneoGetBusVoltage(void* hObject, unsigned long* pVBusVoltage, unsigned int reserved - ice::Function icsneoGetBusVoltage( - lib, "icsneoGetBusVoltage"); + ice::Function icsneoGetBusVoltage(lib, + "icsneoGetBusVoltage"); Py_BEGIN_ALLOW_THREADS; if (!icsneoGetBusVoltage(handle, &mV, reserved)) { Py_BLOCK_THREADS; @@ -3580,8 +3524,7 @@ PyObject* meth_read_jupiter_firmware(PyObject* self, PyObject* args) // TODO: Documentation doesn't say what return value is. if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3630,8 +3573,7 @@ PyObject* meth_write_jupiter_firmware(PyObject* self, PyObject* args) return set_ics_exception(exception_runtime_error(), "Argument must be of Bytes type "); } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3684,13 +3626,12 @@ PyObject* meth_flash_accessory_firmware(PyObject* self, PyObject* args) if (!PyArg_ParseTuple(args, arg_parse("OO|b:", __FUNCTION__), &obj, &parms, &check_success)) { return NULL; } - /*if (!PyArg_ParseTuple(args, arg_parse("OiO|b:", __FUNCTION__), &obj, &accessory_indx, &bytes_obj, &check_success)) { - return NULL; + /*if (!PyArg_ParseTuple(args, arg_parse("OiO|b:", __FUNCTION__), &obj, &accessory_indx, &bytes_obj, &check_success)) + { return NULL; }*/ if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3705,8 +3646,10 @@ PyObject* meth_flash_accessory_firmware(PyObject* self, PyObject* args) return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } int function_error = (int)AccessoryOperationError; - // int __stdcall icsneoFlashAccessoryFirmware(void* hObject, FlashAccessoryFirmwareParams* param, int* errorCode) - //int __stdcall icsneoFlashPhyFirmware(void* hObject, unsigned char phyIndx, unsigned char* fileData, size_t fileDataSize, int* errorCode) + // int __stdcall icsneoFlashAccessoryFirmware(void* hObject, FlashAccessoryFirmwareParams* param, int* + // errorCode) + // int __stdcall icsneoFlashPhyFirmware(void* hObject, unsigned char phyIndx, unsigned char* fileData, size_t + // fileDataSize, int* errorCode) ice::Function icsneoFlashAccessoryFirmware( lib, "icsneoFlashAccessoryFirmware"); @@ -3759,7 +3702,7 @@ PyObject* meth_flash_accessory_firmware(PyObject* self, PyObject* args) case AccessoryIndexError: ss << "AccessoryIndexError"; break; - case AccessoryParamApiVersionError : + case AccessoryParamApiVersionError: ss << "AccessoryParamApiVersionError "; break; case AccessoryParamSizeMismatchError: @@ -3792,8 +3735,7 @@ PyObject* meth_get_accessory_firmware_version(PyObject* self, PyObject* args) } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3806,7 +3748,8 @@ PyObject* meth_get_accessory_firmware_version(PyObject* self, PyObject* args) char buffer[512]; return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } - // int __stdcall icsneoGetAccessoryFirmwareVersion(void* hObject, unsigned char index, unsigned int* fwVers, int* errorCode) + // int __stdcall icsneoGetAccessoryFirmwareVersion(void* hObject, unsigned char index, unsigned int* fwVers, + // int* errorCode) ice::Function icsneoGetAccessoryFirmwareVersion( lib, "icsneoGetAccessoryFirmwareVersion"); @@ -3814,7 +3757,8 @@ PyObject* meth_get_accessory_firmware_version(PyObject* self, PyObject* args) int function_error = 0; Py_BEGIN_ALLOW_THREADS; if (!icsneoGetAccessoryFirmwareVersion(handle, accessory_indx, &accessory_version, &function_error)) { - Py_BLOCK_THREADS return set_ics_exception(exception_runtime_error(), "icsneoGetAccessoryFirmwareVersion() Failed"); + Py_BLOCK_THREADS return set_ics_exception(exception_runtime_error(), + "icsneoGetAccessoryFirmwareVersion() Failed"); } Py_END_ALLOW_THREADS; // check the return value to make sure we are good @@ -3858,7 +3802,7 @@ PyObject* meth_get_accessory_firmware_version(PyObject* self, PyObject* args) case AccessoryIndexError: ss << "AccessoryIndexError"; break; - case AccessoryParamApiVersionError : + case AccessoryParamApiVersionError: ss << "AccessoryParamApiVersionError "; break; case AccessoryParamSizeMismatchError: @@ -3889,8 +3833,7 @@ PyObject* meth_set_safe_boot_mode(PyObject* self, PyObject* args) } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3904,8 +3847,7 @@ PyObject* meth_set_safe_boot_mode(PyObject* self, PyObject* args) return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } // int _stdcall icsneoSetSafeBootMode(void* hObject, const uint8_t enable) - ice::Function icsneoSetSafeBootMode( - lib, "icsneoSetSafeBootMode"); + ice::Function icsneoSetSafeBootMode(lib, "icsneoSetSafeBootMode"); unsigned int accessory_version = 0; int function_error = 0; @@ -3953,7 +3895,7 @@ PyObject* meth_get_library_path(PyObject* self) } bool okay = false; auto path = lib->getPath(&okay); - //auto isLoaded = lib->isLoaded(); + // auto isLoaded = lib->isLoaded(); return Py_BuildValue("s", path.c_str()); } catch (ice::Exception& ex) { return set_ics_exception(exception_runtime_error(), (char*)ex.what()); @@ -3968,8 +3910,7 @@ PyObject* meth_get_disk_details(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3981,8 +3922,7 @@ PyObject* meth_get_disk_details(PyObject* self, PyObject* args) char buffer[512]; return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } - ice::Function icsneoRequestDiskDetails(lib, - "icsneoRequestDiskDetails"); + ice::Function icsneoRequestDiskDetails(lib, "icsneoRequestDiskDetails"); PyObject* details = _getPythonModuleObject("ics.structures.s_disk_details", "s_disk_details"); if (!details) { @@ -4015,8 +3955,7 @@ PyObject* meth_disk_format(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4054,8 +3993,7 @@ PyObject* meth_disk_format_cancel(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4089,8 +4027,7 @@ PyObject* meth_get_disk_format_progress(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4136,8 +4073,7 @@ PyObject* meth_enable_doip_line(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4172,8 +4108,7 @@ PyObject* meth_is_device_feature_supported(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4208,8 +4143,7 @@ PyObject* meth_get_pcb_serial_number(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4223,8 +4157,7 @@ PyObject* meth_get_pcb_serial_number(PyObject* self, PyObject* args) } char pcbsn[32] = { 0 }; size_t length = sizeof pcbsn / sizeof pcbsn[0]; - ice::Function icsneoGetPCBSerialNumber(lib, - "icsneoGetPCBSerialNumber"); + ice::Function icsneoGetPCBSerialNumber(lib, "icsneoGetPCBSerialNumber"); Py_BEGIN_ALLOW_THREADS; if (!icsneoGetPCBSerialNumber(handle, pcbsn, &length)) { Py_BLOCK_THREADS; @@ -4248,8 +4181,7 @@ PyObject* meth_set_led_property(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4303,8 +4235,7 @@ PyObject* meth_start_dhcp_server(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4361,8 +4292,7 @@ PyObject* meth_stop_dhcp_server(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4397,8 +4327,7 @@ PyObject* meth_wbms_manager_write_lock(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4433,8 +4362,7 @@ PyObject* meth_wbms_manager_reset(PyObject* self, PyObject* args) return NULL; } if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4446,8 +4374,8 @@ PyObject* meth_wbms_manager_reset(PyObject* self, PyObject* args) char buffer[512]; return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } - ice::Function icsneowBMSManagerReset( - lib, "icsneowBMSManagerReset"); + ice::Function icsneowBMSManagerReset(lib, + "icsneowBMSManagerReset"); Py_BEGIN_ALLOW_THREADS; if (!icsneowBMSManagerReset(handle, manager)) { Py_BLOCK_THREADS; @@ -4474,8 +4402,7 @@ PyObject* meth_uart_write(PyObject* self, PyObject* args) // Get the device handle if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4520,8 +4447,7 @@ PyObject* meth_uart_read(PyObject* self, PyObject* args) } // Get the device handle if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4575,8 +4501,7 @@ PyObject* meth_uart_set_baudrate(PyObject* self, PyObject* args) } // Get the device handle if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4614,8 +4539,7 @@ PyObject* meth_uart_get_baudrate(PyObject* self, PyObject* args) } // Get the device handle if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4658,8 +4582,7 @@ PyObject* meth_generic_api_send_command(PyObject* self, PyObject* args) } // Get the device handle if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4685,8 +4608,13 @@ PyObject* meth_generic_api_send_command(PyObject* self, PyObject* args) icsneoGenericAPISendCommand(lib, "icsneoGenericAPISendCommand"); unsigned char functionError = 0; Py_BEGIN_ALLOW_THREADS; - if (!icsneoGenericAPISendCommand( - handle, apiIndex, instanceIndex, functionIndex, (void*)data.buf, static_cast(data.len), &functionError)) { + if (!icsneoGenericAPISendCommand(handle, + apiIndex, + instanceIndex, + functionIndex, + (void*)data.buf, + static_cast(data.len), + &functionError)) { Py_BLOCK_THREADS; return set_ics_exception(exception_runtime_error(), "icsneoGenericAPISendCommand() Failed"); } @@ -4710,8 +4638,7 @@ PyObject* meth_generic_api_read_data(PyObject* self, PyObject* args) } // Get the device handle if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4737,8 +4664,7 @@ PyObject* meth_generic_api_read_data(PyObject* self, PyObject* args) unsigned char* bData, unsigned int* length) */ - ice::Function + ice::Function icsneoGenericAPIReadData(lib, "icsneoGenericAPIReadData"); unsigned char functionIndex = 0; Py_BEGIN_ALLOW_THREADS; @@ -4775,8 +4701,7 @@ PyObject* meth_generic_api_get_status(PyObject* self, PyObject* args) } // Get the device handle if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4836,8 +4761,7 @@ PyObject* meth_get_gptp_status(PyObject* self, PyObject* args) if (!PyNeoDeviceEx_CheckExact(obj)) { PyBuffer_Release(&status_buffer); Py_DECREF(status); - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4891,8 +4815,7 @@ PyObject* meth_get_all_chip_versions(PyObject* self, PyObject* args) if (!PyNeoDeviceEx_CheckExact(obj)) { PyBuffer_Release(&py_struct_buffer); Py_DECREF(py_struct); - return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -4909,9 +4832,10 @@ PyObject* meth_get_all_chip_versions(PyObject* self, PyObject* args) // Get the struct Py_BEGIN_ALLOW_THREADS; // int _stdcall icsneoGetAllChipVersions(void* hObject, stChipVersions* pInfo, int ipInfoSize) - ice::Function icsneoGetAllChipVersions( - lib, "icsneoGetAllChipVersions"); - if (!icsneoGetAllChipVersions(handle, (stChipVersions*)py_struct_buffer.buf, static_cast(py_struct_buffer.len))) { + ice::Function icsneoGetAllChipVersions(lib, + "icsneoGetAllChipVersions"); + if (!icsneoGetAllChipVersions( + handle, (stChipVersions*)py_struct_buffer.buf, static_cast(py_struct_buffer.len))) { Py_BLOCK_THREADS; PyBuffer_Release(&py_struct_buffer); Py_DECREF(py_struct); From 13f8aa1049387b91b19744ce5a45b069a5eb9317 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 24 Sep 2024 15:05:16 -0400 Subject: [PATCH 07/14] Minor chnages Signed-off-by: Marcel --- src/methods.cpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/methods.cpp b/src/methods.cpp index f5ee34eca..96279b454 100644 --- a/src/methods.cpp +++ b/src/methods.cpp @@ -343,7 +343,16 @@ void __destroy_PyNeoDeviceEx_Handle(PyObject* handle) } */ } - +bool PyNeoDeviceEx_IsHandleNull(PyObject* object, void** handle) +{ + if (object == NULL || object == Py_None || object == Py_False || (PyLong_CheckExact(object) && PyLong_AsLong(object) == 0)) { + *handle = NULL; + return true; + } + else { + return false; + } +} // Return the _handle attribute of PyNeoDeviceEx. Sets handle to NULL on failure or not valid. // Returns false on error and exception is set. Returns true on success. bool PyNeoDeviceEx_GetHandle(PyObject* object, void** handle) @@ -353,11 +362,6 @@ bool PyNeoDeviceEx_GetHandle(PyObject* object, void** handle) return false; } *handle = NULL; - if (object == NULL || object == Py_None || object == Py_False || - (PyLong_CheckExact(object) && PyLong_AsLong(object) == 0)) { - *handle = NULL; - return true; - } if (!PyNeoDeviceEx_CheckExact(object)) { return set_ics_exception(exception_runtime_error(), "Object is not of type PyNeoDeviceEx"); } @@ -1448,8 +1452,9 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) PyObject* obj = NULL; PyObject* callback = NULL; PyObject* dict; + OptionsFindNeoEx opts = { 0 }; int network_id = -1; - if (!PyArg_ParseTuple(args, arg_parse("OO|Oi:", __FUNCTION__), &obj, &dict, &callback, &network_id)) { + if (!PyArg_ParseTuple(args, arg_parse("OO|OiO:", __FUNCTION__), &obj, &dict, &callback, &network_id, &opts)) { return NULL; } if (obj && !PyNeoDeviceEx_CheckExact(obj)) { @@ -1487,7 +1492,6 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) reflash_count++; } // handle network_id if provided, otherwise 0 - OptionsFindNeoEx opts = { 0 }; opts.CANOptions.iNetworkID = static_cast(network_id); POptionsFindNeoEx popts = NULL; if (network_id != -1) @@ -2632,8 +2636,15 @@ PyObject* meth_set_context(PyObject* self, PyObject* args) return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx, integer, False, 0, or NULL"); } - if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { - return NULL; + if (PyNeoDeviceEx_IsHandleNull(obj, &handle)) + { + handle = NULL; + } + else + { + if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { + return set_ics_exception(exception_runtime_error(), "Failed to retrieve handle."); + } } try { ice::Library* lib = dll_get_library(); From ffa2b0bc714416dddfef8fd86a7a24317b81dc58 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 9 Oct 2024 14:08:08 -0400 Subject: [PATCH 08/14] Signed-off-by: Marcel --- src/methods.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/methods.cpp b/src/methods.cpp index 96279b454..67511c413 100644 --- a/src/methods.cpp +++ b/src/methods.cpp @@ -3637,10 +3637,6 @@ PyObject* meth_flash_accessory_firmware(PyObject* self, PyObject* args) if (!PyArg_ParseTuple(args, arg_parse("OO|b:", __FUNCTION__), &obj, &parms, &check_success)) { return NULL; } - /*if (!PyArg_ParseTuple(args, arg_parse("OiO|b:", __FUNCTION__), &obj, &accessory_indx, &bytes_obj, &check_success)) - { return NULL; - }*/ - if (!PyNeoDeviceEx_CheckExact(obj)) { return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } From b54e7af1787335542dc9fa8ba6bad1977475046d Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 23 Oct 2024 14:54:37 -0400 Subject: [PATCH 09/14] updated based on feedback Signed-off-by: Marcel --- src/methods.cpp | 51 ++++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/src/methods.cpp b/src/methods.cpp index 8fd8781b9..0b50826b0 100644 --- a/src/methods.cpp +++ b/src/methods.cpp @@ -162,6 +162,8 @@ char* neodevice_to_string(unsigned long type) return "CM Probe"; case NEODEVICE_EEVB: return "EEVB"; + case NEODEVICE_VCANRF: + return "ValueCAN.rf"; case NEODEVICE_FIRE2: return "neoVI FIRE 2"; case NEODEVICE_FLEX: @@ -341,16 +343,7 @@ void __destroy_PyNeoDeviceEx_Handle(PyObject* handle) } */ } -bool PyNeoDeviceEx_IsHandleNull(PyObject* object, void** handle) -{ - if (object == NULL || object == Py_None || object == Py_False || (PyLong_CheckExact(object) && PyLong_AsLong(object) == 0)) { - *handle = NULL; - return true; - } - else { - return false; - } -} + // Return the _handle attribute of PyNeoDeviceEx. Sets handle to NULL on failure or not valid. // Returns false on error and exception is set. Returns true on success. bool PyNeoDeviceEx_GetHandle(PyObject* object, void** handle) @@ -377,7 +370,6 @@ bool PyNeoDeviceEx_GetHandle(PyObject* object, void** handle) *handle = ptr; return true; } - // Set the _handle attribute of PyNeoDeviceEx. // Returns false on error and exception is set. Returns true on success. bool PyNeoDeviceEx_SetHandle(PyObject* object, void* handle) @@ -416,7 +408,6 @@ bool PyNeoDeviceEx_SetHandle(PyObject* object, void* handle) // Get the _name attribute of PyNeoDeviceEx. // Returns false on error and exception is set. Returns true on success. - bool PyNeoDeviceEx_GetName(PyObject* object, PyObject* name) { if (!object) { @@ -1451,9 +1442,8 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) PyObject* obj = NULL; PyObject* callback = NULL; PyObject* dict; - OptionsFindNeoEx opts = { 0 }; int network_id = -1; - if (!PyArg_ParseTuple(args, arg_parse("OO|OiO:", __FUNCTION__), &obj, &dict, &callback, &network_id, &opts)) { + if (!PyArg_ParseTuple(args, arg_parse("OO|Oi:", __FUNCTION__), &obj, &dict, &callback, &network_id)) { return NULL; } if (obj && !PyNeoDeviceEx_CheckExact(obj)) { @@ -1491,6 +1481,7 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) reflash_count++; } // handle network_id if provided, otherwise 0 + OptionsFindNeoEx opts = { 0 }; opts.CANOptions.iNetworkID = static_cast(network_id); POptionsFindNeoEx popts = NULL; if (network_id != -1) @@ -2631,20 +2622,18 @@ PyObject* meth_set_context(PyObject* self, PyObject* args) return NULL; } void* handle = NULL; - if (!PyNeoDeviceEx_CheckExact(obj) && obj != Py_None && obj == Py_False && obj == 0) { + if (!PyNeoDeviceEx_CheckExact(obj) && obj == Py_False) { return set_ics_exception(exception_runtime_error(), - "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx, integer, False, 0, or NULL"); - } - if (PyNeoDeviceEx_IsHandleNull(obj, &handle)) - { - handle = NULL; - } - else - { - if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { - return set_ics_exception(exception_runtime_error(), "Failed to retrieve handle."); - } + "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx, or False"); } + if (obj == Py_False){ + handle = NULL; + } else { + if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { + return set_ics_exception(exception_runtime_error(), + "Failed to retrieve handle."); + } + } try { ice::Library* lib = dll_get_library(); if (!lib) { @@ -2654,7 +2643,6 @@ PyObject* meth_set_context(PyObject* self, PyObject* args) ice::Function icsneoSetContext(lib, "icsneoSetContext"); Py_BEGIN_ALLOW_THREADS; if (!icsneoSetContext(handle)) { - printf("did we fail here after !icsneoSetContext(handle)"); Py_BLOCK_THREADS; return set_ics_exception(exception_runtime_error(), "icsneoSetContext() Failed"); } @@ -3636,6 +3624,10 @@ PyObject* meth_flash_accessory_firmware(PyObject* self, PyObject* args) if (!PyArg_ParseTuple(args, arg_parse("OO|b:", __FUNCTION__), &obj, &parms, &check_success)) { return NULL; } + /*if (!PyArg_ParseTuple(args, arg_parse("OiO|b:", __FUNCTION__), &obj, &accessory_indx, &bytes_obj, &check_success)) + { return NULL; + }*/ + if (!PyNeoDeviceEx_CheckExact(obj)) { return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } @@ -3729,7 +3721,6 @@ PyObject* meth_flash_accessory_firmware(PyObject* self, PyObject* args) } catch (ice::Exception& ex) { return set_ics_exception(exception_runtime_error(), (char*)ex.what()); } -#endif // ENABLE_ACCESSORY_API } PyObject* meth_get_accessory_firmware_version(PyObject* self, PyObject* args) @@ -3741,9 +3732,6 @@ PyObject* meth_get_accessory_firmware_version(PyObject* self, PyObject* args) return NULL; } -#ifndef ENABLE_ACCESSORY_API - return set_ics_exception(exception_runtime_error(), "Accessory API not enabled"); -#else if (!PyNeoDeviceEx_CheckExact(obj)) { return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } @@ -3832,7 +3820,6 @@ PyObject* meth_get_accessory_firmware_version(PyObject* self, PyObject* args) } catch (ice::Exception& ex) { return set_ics_exception(exception_runtime_error(), (char*)ex.what()); } -#endif // ENABLE_ACCESSORY_API } PyObject* meth_set_safe_boot_mode(PyObject* self, PyObject* args) From 16676d789b0ab8e80bdffe1dbca9bf7385e6edd1 Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 24 Oct 2024 15:47:37 -0400 Subject: [PATCH 10/14] minor change Signed-off-by: Marcel --- src/methods.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/methods.cpp b/src/methods.cpp index 0b50826b0..2f208c77c 100644 --- a/src/methods.cpp +++ b/src/methods.cpp @@ -370,7 +370,6 @@ bool PyNeoDeviceEx_GetHandle(PyObject* object, void** handle) *handle = ptr; return true; } -// Set the _handle attribute of PyNeoDeviceEx. // Returns false on error and exception is set. Returns true on success. bool PyNeoDeviceEx_SetHandle(PyObject* object, void* handle) { @@ -2622,11 +2621,13 @@ PyObject* meth_set_context(PyObject* self, PyObject* args) return NULL; } void* handle = NULL; - if (!PyNeoDeviceEx_CheckExact(obj) && obj == Py_False) { + if (!PyNeoDeviceEx_CheckExact(obj) && obj != Py_None && obj != Py_False && !(PyLong_Check(obj) && PyLong_AsLong(obj) == 0)) { + printf("Object type: %s\n", Py_TYPE(obj)->tp_name); return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx, or False"); } - if (obj == Py_False){ + printf("Object type: %s\n", Py_TYPE(obj)->tp_name); + if (obj == Py_None || obj == Py_False || (PyLong_Check(obj) && PyLong_AsLong(obj) == 0)){ handle = NULL; } else { if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { From e00205534ab9eb18f137748ee7ab7e8db4297ee5 Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 24 Oct 2024 18:14:04 -0400 Subject: [PATCH 11/14] removed printf used for debug Signed-off-by: Marcel --- src/methods.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/methods.cpp b/src/methods.cpp index 2f208c77c..18b122869 100644 --- a/src/methods.cpp +++ b/src/methods.cpp @@ -2622,11 +2622,9 @@ PyObject* meth_set_context(PyObject* self, PyObject* args) } void* handle = NULL; if (!PyNeoDeviceEx_CheckExact(obj) && obj != Py_None && obj != Py_False && !(PyLong_Check(obj) && PyLong_AsLong(obj) == 0)) { - printf("Object type: %s\n", Py_TYPE(obj)->tp_name); return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx, or False"); } - printf("Object type: %s\n", Py_TYPE(obj)->tp_name); if (obj == Py_None || obj == Py_False || (PyLong_Check(obj) && PyLong_AsLong(obj) == 0)){ handle = NULL; } else { From aa6d098b5d7ec861725f6da264d6728881bc2b90 Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 28 Oct 2024 10:23:46 -0400 Subject: [PATCH 12/14] added ioptions as a argument if provided Signed-off-by: Marcel --- src/methods.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/methods.cpp b/src/methods.cpp index 18b122869..4c76ddd39 100644 --- a/src/methods.cpp +++ b/src/methods.cpp @@ -1442,7 +1442,8 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) PyObject* callback = NULL; PyObject* dict; int network_id = -1; - if (!PyArg_ParseTuple(args, arg_parse("OO|Oi:", __FUNCTION__), &obj, &dict, &callback, &network_id)) { + unsigned long iOptions = 0; + if (!PyArg_ParseTuple(args, arg_parse("OO|Oii:", __FUNCTION__), &obj, &dict, &callback, &network_id, &iOptions)) { return NULL; } if (obj && !PyNeoDeviceEx_CheckExact(obj)) { @@ -1485,10 +1486,9 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) POptionsFindNeoEx popts = NULL; if (network_id != -1) popts = &opts; - unsigned long iOptions = 0; // Initialize with default value of 0 - - if (network_id != -1) { - iOptions = opts.CANOptions.iNetworkID; // Set to network_id if it's not -1 + // If iOptions was provided, use it. Otherwise, fall back to network_id. + if (iOptions == 0 && network_id != -1) { + iOptions = opts.CANOptions.iNetworkID; } try { ice::Library* lib = dll_get_library(); @@ -2625,6 +2625,9 @@ PyObject* meth_set_context(PyObject* self, PyObject* args) return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx, or False"); } + // Set 'handle' to NULL if 'obj' is None, False, or a zero-valued integer. + // Otherwise, attempt to retrieve the handle using 'PyNeoDeviceEx_GetHandle'. + // If handle retrieval fails, raise a runtime error exception. if (obj == Py_None || obj == Py_False || (PyLong_Check(obj) && PyLong_AsLong(obj) == 0)){ handle = NULL; } else { From 46fc08f3a7ec464b467b6ded8e7eb93da4e1e599 Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 13 Jan 2025 10:00:04 -0500 Subject: [PATCH 13/14] Small changes Signed-off-by: Marcel --- src/methods.cpp | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/methods.cpp b/src/methods.cpp index 4c76ddd39..48d21d213 100644 --- a/src/methods.cpp +++ b/src/methods.cpp @@ -162,8 +162,6 @@ char* neodevice_to_string(unsigned long type) return "CM Probe"; case NEODEVICE_EEVB: return "EEVB"; - case NEODEVICE_VCANRF: - return "ValueCAN.rf"; case NEODEVICE_FIRE2: return "neoVI FIRE 2"; case NEODEVICE_FLEX: @@ -1442,8 +1440,8 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) PyObject* callback = NULL; PyObject* dict; int network_id = -1; - unsigned long iOptions = 0; - if (!PyArg_ParseTuple(args, arg_parse("OO|Oii:", __FUNCTION__), &obj, &dict, &callback, &network_id, &iOptions)) { + unsigned long kOptions = 0; + if (!PyArg_ParseTuple(args, arg_parse("OO|Oii:", __FUNCTION__), &obj, &dict, &callback, &network_id, &kOptions)) { return NULL; } if (obj && !PyNeoDeviceEx_CheckExact(obj)) { @@ -1477,7 +1475,6 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) } rc[reflash_count].chipId = id; strcpy(rc[reflash_count].path, path); - printf(path); reflash_count++; } // handle network_id if provided, otherwise 0 @@ -1486,9 +1483,9 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) POptionsFindNeoEx popts = NULL; if (network_id != -1) popts = &opts; - // If iOptions was provided, use it. Otherwise, fall back to network_id. - if (iOptions == 0 && network_id != -1) { - iOptions = opts.CANOptions.iNetworkID; + // If kOptions was provided, use it. Otherwise, fall back to network_id. + if (kOptions == 0 && network_id != -1) { + kOptions = opts.CANOptions.iNetworkID; } try { ice::Library* lib = dll_get_library(); @@ -1514,7 +1511,7 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) FlashDevice2(lib, "FlashDevice2"); Py_BEGIN_ALLOW_THREADS; if (!FlashDevice2( - 0x3835C256, &nde->neoDevice, rc, reflash_count, network_id, iOptions, 0, &message_callback)) { + 0x3835C256, &nde->neoDevice, rc, reflash_count, network_id, kOptions, 0, &message_callback)) { Py_BLOCK_THREADS; PyBuffer_Release(&buffer); return set_ics_exception(exception_runtime_error(), "FlashDevice2() Failed"); @@ -3626,12 +3623,13 @@ PyObject* meth_flash_accessory_firmware(PyObject* self, PyObject* args) if (!PyArg_ParseTuple(args, arg_parse("OO|b:", __FUNCTION__), &obj, &parms, &check_success)) { return NULL; } - /*if (!PyArg_ParseTuple(args, arg_parse("OiO|b:", __FUNCTION__), &obj, &accessory_indx, &bytes_obj, &check_success)) - { return NULL; - }*/ +#ifndef ENABLE_ACCESSORY_API + return set_ics_exception(exception_runtime_error(), "Accessory API not enabled"); +#else if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), + "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3646,10 +3644,8 @@ PyObject* meth_flash_accessory_firmware(PyObject* self, PyObject* args) return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } int function_error = (int)AccessoryOperationError; - // int __stdcall icsneoFlashAccessoryFirmware(void* hObject, FlashAccessoryFirmwareParams* param, int* - // errorCode) - // int __stdcall icsneoFlashPhyFirmware(void* hObject, unsigned char phyIndx, unsigned char* fileData, size_t - // fileDataSize, int* errorCode) + // int __stdcall icsneoFlashAccessoryFirmware(void* hObject, FlashAccessoryFirmwareParams* param, int* errorCode) + //int __stdcall icsneoFlashPhyFirmware(void* hObject, unsigned char phyIndx, unsigned char* fileData, size_t fileDataSize, int* errorCode) ice::Function icsneoFlashAccessoryFirmware( lib, "icsneoFlashAccessoryFirmware"); @@ -3702,7 +3698,7 @@ PyObject* meth_flash_accessory_firmware(PyObject* self, PyObject* args) case AccessoryIndexError: ss << "AccessoryIndexError"; break; - case AccessoryParamApiVersionError: + case AccessoryParamApiVersionError : ss << "AccessoryParamApiVersionError "; break; case AccessoryParamSizeMismatchError: @@ -3723,6 +3719,7 @@ PyObject* meth_flash_accessory_firmware(PyObject* self, PyObject* args) } catch (ice::Exception& ex) { return set_ics_exception(exception_runtime_error(), (char*)ex.what()); } +#endif // ENABLE_ACCESSORY_API } PyObject* meth_get_accessory_firmware_version(PyObject* self, PyObject* args) @@ -3734,8 +3731,12 @@ PyObject* meth_get_accessory_firmware_version(PyObject* self, PyObject* args) return NULL; } +#ifndef ENABLE_ACCESSORY_API + return set_ics_exception(exception_runtime_error(), "Accessory API not enabled"); +#else if (!PyNeoDeviceEx_CheckExact(obj)) { - return set_ics_exception(exception_runtime_error(), "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); + return set_ics_exception(exception_runtime_error(), + "Argument must be of type " MODULE_NAME ".PyNeoDeviceEx"); } void* handle = NULL; if (!PyNeoDeviceEx_GetHandle(obj, &handle)) { @@ -3748,8 +3749,7 @@ PyObject* meth_get_accessory_firmware_version(PyObject* self, PyObject* args) char buffer[512]; return set_ics_exception(exception_runtime_error(), dll_get_error(buffer)); } - // int __stdcall icsneoGetAccessoryFirmwareVersion(void* hObject, unsigned char index, unsigned int* fwVers, - // int* errorCode) + // int __stdcall icsneoGetAccessoryFirmwareVersion(void* hObject, unsigned char index, unsigned int* fwVers, int* errorCode) ice::Function icsneoGetAccessoryFirmwareVersion( lib, "icsneoGetAccessoryFirmwareVersion"); @@ -3757,8 +3757,7 @@ PyObject* meth_get_accessory_firmware_version(PyObject* self, PyObject* args) int function_error = 0; Py_BEGIN_ALLOW_THREADS; if (!icsneoGetAccessoryFirmwareVersion(handle, accessory_indx, &accessory_version, &function_error)) { - Py_BLOCK_THREADS return set_ics_exception(exception_runtime_error(), - "icsneoGetAccessoryFirmwareVersion() Failed"); + Py_BLOCK_THREADS return set_ics_exception(exception_runtime_error(), "icsneoGetAccessoryFirmwareVersion() Failed"); } Py_END_ALLOW_THREADS; // check the return value to make sure we are good @@ -3802,7 +3801,7 @@ PyObject* meth_get_accessory_firmware_version(PyObject* self, PyObject* args) case AccessoryIndexError: ss << "AccessoryIndexError"; break; - case AccessoryParamApiVersionError: + case AccessoryParamApiVersionError : ss << "AccessoryParamApiVersionError "; break; case AccessoryParamSizeMismatchError: @@ -3822,6 +3821,7 @@ PyObject* meth_get_accessory_firmware_version(PyObject* self, PyObject* args) } catch (ice::Exception& ex) { return set_ics_exception(exception_runtime_error(), (char*)ex.what()); } +#endif // ENABLE_ACCESSORY_API } PyObject* meth_set_safe_boot_mode(PyObject* self, PyObject* args) From e3dd07315507f0c1f1dffb1dce3ba84a6c2015f3 Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 13 Jan 2025 11:15:02 -0500 Subject: [PATCH 14/14] oops Signed-off-by: Marcel --- src/methods.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/methods.cpp b/src/methods.cpp index 48d21d213..f75458528 100644 --- a/src/methods.cpp +++ b/src/methods.cpp @@ -1440,8 +1440,8 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) PyObject* callback = NULL; PyObject* dict; int network_id = -1; - unsigned long kOptions = 0; - if (!PyArg_ParseTuple(args, arg_parse("OO|Oii:", __FUNCTION__), &obj, &dict, &callback, &network_id, &kOptions)) { + unsigned long iOptions = 0; + if (!PyArg_ParseTuple(args, arg_parse("OO|Oik:", __FUNCTION__), &obj, &dict, &callback, &network_id, &iOptions)) { return NULL; } if (obj && !PyNeoDeviceEx_CheckExact(obj)) { @@ -1483,9 +1483,9 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) POptionsFindNeoEx popts = NULL; if (network_id != -1) popts = &opts; - // If kOptions was provided, use it. Otherwise, fall back to network_id. - if (kOptions == 0 && network_id != -1) { - kOptions = opts.CANOptions.iNetworkID; + // If iOptions was provided, use it. Otherwise, fall back to network_id. + if (iOptions == 0 && network_id != -1) { + iOptions = opts.CANOptions.iNetworkID; } try { ice::Library* lib = dll_get_library(); @@ -1511,7 +1511,7 @@ PyObject* meth_flash_devices(PyObject* self, PyObject* args) FlashDevice2(lib, "FlashDevice2"); Py_BEGIN_ALLOW_THREADS; if (!FlashDevice2( - 0x3835C256, &nde->neoDevice, rc, reflash_count, network_id, kOptions, 0, &message_callback)) { + 0x3835C256, &nde->neoDevice, rc, reflash_count, network_id, iOptions, 0, &message_callback)) { Py_BLOCK_THREADS; PyBuffer_Release(&buffer); return set_ics_exception(exception_runtime_error(), "FlashDevice2() Failed");