Skip to content

Commit 72173b5

Browse files
SPI & wBMS Messages Fix (#194)
* Update object_spy_message.h to fi Add missing isoSPI and wBMS Extended data Support * Fix formatting
1 parent 158914f commit 72173b5

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

include/object_spy_message.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,16 @@ static PyObject* spy_message_object_getattr(PyObject* o, PyObject* attr_name)
280280
unsigned char* ExtraDataPtr = (unsigned char*)obj->msg.ExtraDataPtr;
281281
bool extra_data_ptr_enabled = obj->msg.ExtraDataPtrEnabled != 0;
282282
// Ethernet protocol uses the ExtraDataPtrEnabled reversed internally
283-
if (obj->msg.Protocol == SPY_PROTOCOL_ETHERNET && obj->msg.ExtraDataPtr != NULL) {
283+
if ((obj->msg.Protocol == SPY_PROTOCOL_ETHERNET ||
284+
obj->msg.Protocol == SPY_PROTOCOL_SPI ||
285+
obj->msg.Protocol == SPY_PROTOCOL_WBMS)
286+
&& obj->msg.ExtraDataPtr != NULL) {
284287
extra_data_ptr_enabled = true;
285288
}
286289
int actual_size = 0;
287290
// Some newer protocols are packing the length into NumberBytesHeader also so lets handle it here...
288-
if (obj->msg.Protocol == SPY_PROTOCOL_A2B || obj->msg.Protocol == SPY_PROTOCOL_ETHERNET) {
291+
if (obj->msg.Protocol == SPY_PROTOCOL_A2B || obj->msg.Protocol == SPY_PROTOCOL_ETHERNET ||
292+
obj->msg.Protocol == SPY_PROTOCOL_SPI || obj->msg.Protocol == SPY_PROTOCOL_WBMS) {
289293
actual_size = (obj->msg.NumberBytesHeader << 8) | obj->msg.NumberBytesData;
290294
} else {
291295
actual_size = obj->msg.NumberBytesData;
@@ -386,7 +390,8 @@ static int spy_message_object_setattr(PyObject* o, PyObject* name, PyObject* val
386390
delete[] (unsigned char*)obj->msg.ExtraDataPtr;
387391
obj->msg.ExtraDataPtr = new unsigned char[length];
388392
// Some newer protocols are packing the length into NumberBytesHeader also so lets handle it here...
389-
if (obj->msg.Protocol == SPY_PROTOCOL_A2B || obj->msg.Protocol == SPY_PROTOCOL_ETHERNET) {
393+
if (obj->msg.Protocol == SPY_PROTOCOL_A2B || obj->msg.Protocol == SPY_PROTOCOL_ETHERNET ||
394+
obj->msg.Protocol == SPY_PROTOCOL_SPI || obj->msg.Protocol == SPY_PROTOCOL_WBMS) {
390395
obj->msg.NumberBytesHeader = static_cast<uint8_t>(length >> 8);
391396
}
392397
obj->msg.NumberBytesData = length & 0xFF;

0 commit comments

Comments
 (0)