Skip to content

Commit 1406631

Browse files
Fix for python versions greater than 3.7...
Signed-off-by: David Rebbe <drebbe@intrepidcs.com>
1 parent 5457f2c commit 1406631

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
MAJOR_VERSION = 910
1212
MINOR_VERSION = 10
13-
POST_VERSION = 1
13+
POST_VERSION = 2
1414

1515
if POST_VERSION:
1616
VERSION_STRING = '%d.%d-%d' % (MAJOR_VERSION, MINOR_VERSION, POST_VERSION)

src/methods.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3740,11 +3740,10 @@ PyObject* meth_uart_write(PyObject* self, PyObject* args)
37403740
{
37413741
PyObject* obj = NULL;
37423742
EUartPort_t port = eUART0;
3743-
const char* data = NULL;
3744-
Py_ssize_t data_len = 0;
3743+
Py_buffer data = {};
37453744
uint8_t flags = 0;
37463745
bool check_size = true;
3747-
if (!PyArg_ParseTuple(args, arg_parse("OIy#|bp:", __FUNCTION__), &obj, &port, &data, &data_len, &flags, &check_size)) {
3746+
if (!PyArg_ParseTuple(args, arg_parse("OIy*|bp:", __FUNCTION__), &obj, &port, &data, &flags, &check_size)) {
37483747
return NULL;
37493748
}
37503749

@@ -3764,12 +3763,12 @@ PyObject* meth_uart_write(PyObject* self, PyObject* args)
37643763
size_t bytesActuallySent = 0;
37653764
ice::Function<int __stdcall (ICS_HANDLE, const EUartPort_t, const void*, const size_t, size_t*, uint8_t*)> icsneoUartWrite(lib, "icsneoUartWrite");
37663765
Py_BEGIN_ALLOW_THREADS
3767-
if (!icsneoUartWrite(handle, port, data, data_len, &bytesActuallySent, &flags)) {
3766+
if (!icsneoUartWrite(handle, port, data.buf, data.len, &bytesActuallySent, &flags)) {
37683767
Py_BLOCK_THREADS
37693768
return set_ics_exception(exception_runtime_error(), "icsneoUartWrite() Failed");
37703769
}
37713770
Py_END_ALLOW_THREADS
3772-
if (check_size && data_len != bytesActuallySent) {
3771+
if (check_size && data.len != bytesActuallySent) {
37733772
return set_ics_exception(exception_runtime_error(), "Bytes actually sent didn't match bytes to send length");
37743773
}
37753774
return Py_BuildValue("i", bytesActuallySent);
@@ -3917,9 +3916,8 @@ PyObject* meth_generic_api_send_command(PyObject* self, PyObject* args)
39173916
unsigned char apiIndex = 0;
39183917
unsigned char instanceIndex = 0;
39193918
unsigned char functionIndex = 0;
3920-
const char* data = NULL;
3921-
Py_ssize_t data_len = 0;
3922-
if (!PyArg_ParseTuple(args, arg_parse("Obbby#:", __FUNCTION__), &obj, &apiIndex, &instanceIndex, &functionIndex, data, &data_len)) {
3919+
Py_buffer data = {};
3920+
if (!PyArg_ParseTuple(args, arg_parse("Obbby*:", __FUNCTION__), &obj, &apiIndex, &instanceIndex, &functionIndex, &data)) {
39233921
return NULL;
39243922
}
39253923
// Get the device handle
@@ -3946,7 +3944,7 @@ PyObject* meth_generic_api_send_command(PyObject* self, PyObject* args)
39463944
ice::Function<int __stdcall (ICS_HANDLE, unsigned char, unsigned char, unsigned char, void*, unsigned int, unsigned char*)> icsneoGenericAPISendCommand(lib, "icsneoGenericAPISendCommand");
39473945
unsigned char functionError = 0;
39483946
Py_BEGIN_ALLOW_THREADS
3949-
if (!icsneoGenericAPISendCommand(handle, apiIndex, instanceIndex, functionIndex, (void*)data, data_len, &functionError)) {
3947+
if (!icsneoGenericAPISendCommand(handle, apiIndex, instanceIndex, functionIndex, (void*)data.buf, data.len, &functionError)) {
39503948
Py_BLOCK_THREADS
39513949
return set_ics_exception(exception_runtime_error(), "icsneoGenericAPISendCommand() Failed");
39523950
}

0 commit comments

Comments
 (0)