Skip to content

Commit 359185c

Browse files
Added set_safe_boot_mode method (#179)
* Added set_safe_boot_mode method
1 parent 0940f44 commit 359185c

3 files changed

Lines changed: 155 additions & 89 deletions

File tree

include/methods.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ extern "C"
100100
PyObject* meth_get_all_chip_versions(PyObject* self, PyObject* args); // icsneoGetAllChipVersions
101101
PyObject* meth_flash_accessory_firmware(PyObject* self, PyObject* args);
102102
PyObject* meth_get_accessory_firmware_version(PyObject* self, PyObject* args);
103+
PyObject* meth_set_safe_boot_mode(PyObject* self, PyObject* args);
103104

104105
#ifdef _cplusplus
105106
}
@@ -1913,6 +1914,25 @@ extern "C"
19131914
"\tNone\n" \
19141915
"\n"
19151916

1917+
#define _DOC_SET_SAFE_BOOT_MODE \
1918+
MODULE_NAME ".set_safe_boot_mode(device, enable: bool) -> bool\n" \
1919+
"\n" \
1920+
"Sets safe boot mode. If not sure, don't use this method.\n" \
1921+
"FIRE3 will reboot to safe boot mode when called with enable = True.\n" \
1922+
"\n" \
1923+
"Args:\n" \
1924+
"\tdevice (:class:`" MODULE_NAME ".PyNeoDeviceEx`): :class:`" MODULE_NAME \
1925+
".PyNeoDeviceEx`\n\n" \
1926+
"\n" \
1927+
"\tenable (:class:`bool`): :class:`bool`: Tells the device to enter safe boot mode upon restart.\n\n" \
1928+
"\n" \
1929+
"Raises:\n" \
1930+
"\t:class:`" MODULE_NAME ".RuntimeError`\n" \
1931+
"\n" \
1932+
"Returns:\n" \
1933+
"\tNone\n" \
1934+
"\n"
1935+
19161936
static PyMethodDef IcsMethods[] = {
19171937
_EZ_ICS_STRUCT_METHOD("find_devices",
19181938
"icsneoFindNeoDevices",
@@ -2422,6 +2442,12 @@ static PyMethodDef IcsMethods[] = {
24222442
meth_get_accessory_firmware_version,
24232443
METH_VARARGS,
24242444
_DOC_GET_ACCESSORY_FIRMWARE_VERSION),
2445+
_EZ_ICS_STRUCT_METHOD("set_safe_boot_mode",
2446+
"icsneoSetSafeBootMode",
2447+
"SetSafeBootMode",
2448+
meth_set_safe_boot_mode,
2449+
METH_VARARGS,
2450+
_DOC_SET_SAFE_BOOT_MODE),
24252451

24262452
{ "override_library_name", (PyCFunction)meth_override_library_name, METH_VARARGS, _DOC_OVERRIDE_LIBRARY_NAME },
24272453
{ "get_library_path", (PyCFunction)meth_get_library_path, METH_NOARGS, "" },

include/object_spy_message.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ static int spy_message_object_setattr(PyObject* o, PyObject* name, PyObject* val
325325
obj->msg.Data[i] = (unsigned char)PyLong_AsLong(data);
326326
}
327327
}
328-
obj->msg.NumberBytesData = PyObject_Length(value);
328+
obj->msg.NumberBytesData = static_cast<uint8_t>(PyObject_Length(value));
329329
return 0;
330330
} else if (PyUnicode_CompareWithASCIIString(name, "AckBytes") == 0) {
331331
// Make sure we are a tuple and len() == 8
@@ -363,7 +363,7 @@ static int spy_message_object_setattr(PyObject* o, PyObject* name, PyObject* val
363363
} else {
364364
((spy_message_j1850_object*)obj)->msg.Header[i] = (unsigned char)PyLong_AsLong(data);
365365
}
366-
obj->msg.NumberBytesHeader = PyObject_Length(value);
366+
obj->msg.NumberBytesHeader = static_cast<uint8_t>(PyObject_Length(value));
367367
}
368368
return 0;
369369
} else if (PyUnicode_CompareWithASCIIString(name, "Protocol") == 0) {
@@ -387,7 +387,7 @@ static int spy_message_object_setattr(PyObject* o, PyObject* name, PyObject* val
387387
obj->msg.ExtraDataPtr = new unsigned char[length];
388388
// Some newer protocols are packing the length into NumberBytesHeader also so lets handle it here...
389389
if (obj->msg.Protocol == SPY_PROTOCOL_A2B || obj->msg.Protocol == SPY_PROTOCOL_ETHERNET) {
390-
obj->msg.NumberBytesHeader = length >> 8;
390+
obj->msg.NumberBytesHeader = static_cast<uint8_t>(length >> 8);
391391
}
392392
obj->msg.NumberBytesData = length & 0xFF;
393393
if (obj->msg.Protocol != SPY_PROTOCOL_ETHERNET)

0 commit comments

Comments
 (0)