-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathobject_spy_message.cpp
More file actions
476 lines (465 loc) · 25 KB
/
Copy pathobject_spy_message.cpp
File metadata and controls
476 lines (465 loc) · 25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
#include "object_spy_message.h"
static int spy_message_object_alloc(spy_message_object* self, PyObject* args, PyObject* kwds)
{
(void)args;
(void)kwds;
memset(&self->msg, 0, sizeof(self->msg));
self->noExtraDataPtrCleanup = false;
return 0;
}
static void spy_message_object_dealloc(spy_message_object* self)
{
if ((!self->noExtraDataPtrCleanup && self->msg.ExtraDataPtrEnabled && self->msg.ExtraDataPtr != NULL) ||
(!self->noExtraDataPtrCleanup && self->msg.Protocol == SPY_PROTOCOL_ETHERNET &&
self->msg.ExtraDataPtr != NULL)) {
// Clean up the ExtraDataPtr if we can
// Ethernet protocol uses the ExtraDataPtrEnabled reversed internally so do a double check here
delete[] (unsigned char*)self->msg.ExtraDataPtr;
self->msg.ExtraDataPtr = NULL;
self->msg.ExtraDataPtrEnabled = 0;
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject* spy_message_object_getattr(PyObject* o, PyObject* attr_name)
{
#if PY_MAJOR_VERSION >= 3
if (!PyUnicode_Check(attr_name)) {
#else
if (!PyString_Check(attr_name)) {
#endif
PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", attr_name->ob_type->tp_name);
return NULL;
} else {
Py_INCREF(attr_name);
}
if (PyUnicode_CompareWithASCIIString(attr_name, "Data") == 0) {
Py_DECREF(attr_name);
spy_message_object* obj = (spy_message_object*)o;
PyObject* temp = Py_BuildValue("(i,i,i,i,i,i,i,i)",
obj->msg.Data[0],
obj->msg.Data[1],
obj->msg.Data[2],
obj->msg.Data[3],
obj->msg.Data[4],
obj->msg.Data[5],
obj->msg.Data[6],
obj->msg.Data[7]);
PyObject* data = PyTuple_GetSlice(temp, 0, obj->msg.NumberBytesData);
Py_DECREF(temp);
return data;
} else if (PyUnicode_CompareWithASCIIString(attr_name, "AckBytes") == 0) {
Py_DECREF(attr_name);
spy_message_object* obj = (spy_message_object*)o;
return Py_BuildValue("(i,i,i,i,i,i,i,i)",
obj->msg.AckBytes[0],
obj->msg.AckBytes[1],
obj->msg.AckBytes[2],
obj->msg.AckBytes[3],
obj->msg.AckBytes[4],
obj->msg.AckBytes[5],
obj->msg.AckBytes[6],
obj->msg.AckBytes[7]);
} else if (PyUnicode_CompareWithASCIIString(attr_name, "Header") == 0) {
Py_DECREF(attr_name);
spy_message_j1850_object* obj = (spy_message_j1850_object*)o;
PyObject* temp =
Py_BuildValue("(i,i,i,i)", obj->msg.Header[0], obj->msg.Header[1], obj->msg.Header[2], obj->msg.Header[3]);
PyObject* data = PyTuple_GetSlice(temp, 0, obj->msg.NumberBytesHeader);
Py_DECREF(temp);
return data;
} else if (PyUnicode_CompareWithASCIIString(attr_name, "ExtraDataPtr") == 0) {
Py_DECREF(attr_name);
spy_message_j1850_object* obj = (spy_message_j1850_object*)o;
unsigned char* ExtraDataPtr = (unsigned char*)obj->msg.ExtraDataPtr;
bool extra_data_ptr_enabled = obj->msg.ExtraDataPtrEnabled != 0;
// Ethernet protocol uses the ExtraDataPtrEnabled reversed internally
if ((obj->msg.Protocol == SPY_PROTOCOL_ETHERNET ||
obj->msg.Protocol == SPY_PROTOCOL_SPI ||
obj->msg.Protocol == SPY_PROTOCOL_WBMS)
&& obj->msg.ExtraDataPtr != NULL) {
extra_data_ptr_enabled = true;
}
int actual_size = 0;
// Some newer protocols are packing the length into NumberBytesHeader also so lets handle it here...
if (obj->msg.Protocol == SPY_PROTOCOL_A2B || obj->msg.Protocol == SPY_PROTOCOL_ETHERNET ||
obj->msg.Protocol == SPY_PROTOCOL_SPI || obj->msg.Protocol == SPY_PROTOCOL_WBMS) {
actual_size = (obj->msg.NumberBytesHeader << 8) | obj->msg.NumberBytesData;
} else {
actual_size = obj->msg.NumberBytesData;
}
if (extra_data_ptr_enabled && actual_size && obj->msg.ExtraDataPtr) {
PyObject* tuple = PyTuple_New(actual_size);
for (int i = 0; i < actual_size; ++i) {
PyTuple_SET_ITEM(tuple, i, PyLong_FromLong(ExtraDataPtr[i]));
}
return tuple;
} else {
return Py_None;
}
} else {
return PyObject_GenericGetAttr(o, attr_name);
}
}
static int spy_message_object_setattr(PyObject* o, PyObject* name, PyObject* value)
{
spy_message_object* obj = (spy_message_object*)o;
if (PyUnicode_CompareWithASCIIString(name, "Data") == 0) {
// Make sure we are a tuple and len() == 8
if (!PyTuple_Check(value)) {
PyErr_Format(PyExc_AttributeError,
"'%.50s' object attribute '%.400s' needs to be a tuple",
MODULE_NAME "." SPY_MESSAGE_OBJECT_NAME,
name);
return -1;
}
// Get tuple items and place them in array, set as 0 if error.
for (int i = 0; i < 8 && i < PyObject_Length(value); ++i) {
PyObject* data = PyTuple_GetItem(value, i);
if (!data && !PyLong_Check(data)) {
obj->msg.Data[i] = 0;
} else {
obj->msg.Data[i] = (unsigned char)PyLong_AsLong(data);
}
}
obj->msg.NumberBytesData = static_cast<uint8_t>(PyObject_Length(value));
return 0;
} else if (PyUnicode_CompareWithASCIIString(name, "AckBytes") == 0) {
// Make sure we are a tuple and len() == 8
if (!PyTuple_Check(value)) {
PyErr_Format(PyExc_AttributeError,
"'%.50s' object attribute '%.400s' needs to be a tuple",
MODULE_NAME "." SPY_MESSAGE_OBJECT_NAME,
name);
return -1;
}
// Get tuple items and place them in array, set as 0 if error.
for (int i = 0; i < 8 && i < PyObject_Length(value); ++i) {
PyObject* data = PyTuple_GetItem(value, i);
if (!data && !PyLong_Check(data)) {
obj->msg.AckBytes[i] = 0;
} else {
obj->msg.AckBytes[i] = static_cast<uint8_t>(PyLong_AsLong(data));
}
}
return 0;
} else if (PyUnicode_CompareWithASCIIString(name, "Header") == 0) {
// Make sure we are a tuple and len() == 8
if (!PyTuple_Check(value)) {
PyErr_Format(PyExc_AttributeError,
"'%.50s' object attribute '%.400s' needs to be a tuple",
MODULE_NAME "." SPY_MESSAGE_OBJECT_NAME,
name);
return -1;
}
// Get tuple items and place them in array, set as 0 if error.
for (int i = 0; i < 8 && i < PyObject_Length(value); ++i) {
PyObject* data = PyTuple_GetItem(value, i);
if (!data && !PyLong_Check(data)) {
((spy_message_j1850_object*)obj)->msg.Header[i] = 0;
} else {
((spy_message_j1850_object*)obj)->msg.Header[i] = (unsigned char)PyLong_AsLong(data);
}
}
obj->msg.NumberBytesHeader = static_cast<uint8_t>(PyObject_Length(value));
return 0;
} else if (PyUnicode_CompareWithASCIIString(name, "Protocol") == 0) {
// Ethernet behavior is backward to CAN and will crash if enabled.
if (PyLong_AsLong(value) == SPY_PROTOCOL_ETHERNET)
obj->msg.ExtraDataPtrEnabled = 0;
return PyObject_GenericSetAttr(o, name, value);
} else if (PyUnicode_CompareWithASCIIString(name, "ExtraDataPtr") == 0) {
// Make sure we are a tuple and len() == 8
if (!PyTuple_Check(value)) {
PyErr_Format(PyExc_AttributeError,
"'%.50s' object attribute '%.400s' needs to be a tuple",
MODULE_NAME "." SPY_MESSAGE_OBJECT_NAME,
name);
return -1;
}
// Get tuple items and place them in array, set as 0 if error.
size_t length = static_cast<uint16_t>(PyObject_Length(value));
if (obj->msg.ExtraDataPtr != NULL)
delete[] (unsigned char*)obj->msg.ExtraDataPtr;
obj->msg.ExtraDataPtr = new unsigned char[length];
// Some newer protocols are packing the length into NumberBytesHeader also so lets handle it here...
if (obj->msg.Protocol == SPY_PROTOCOL_A2B || obj->msg.Protocol == SPY_PROTOCOL_ETHERNET ||
obj->msg.Protocol == SPY_PROTOCOL_SPI || obj->msg.Protocol == SPY_PROTOCOL_WBMS) {
obj->msg.NumberBytesHeader = static_cast<uint8_t>(length >> 8);
}
obj->msg.NumberBytesData = length & 0xFF;
if (obj->msg.Protocol != SPY_PROTOCOL_ETHERNET)
obj->msg.ExtraDataPtrEnabled = 1;
unsigned char* ExtraDataPtr = (unsigned char*)(obj->msg.ExtraDataPtr);
for (size_t i = 0; i < length; ++i) {
PyObject* data = PyTuple_GetItem(value, static_cast<Py_ssize_t>(i));
if (!data && !PyLong_Check(data)) {
ExtraDataPtr[i] = (unsigned char)0;
} else {
ExtraDataPtr[i] = (unsigned char)PyLong_AsLong(data);
}
}
return 0;
} else if (PyUnicode_CompareWithASCIIString(name, "ExtraDataPtrEnabled") == 0) {
// Make sure we clean up here so we don't memory leak
if ((!obj->noExtraDataPtrCleanup && PyLong_AsLong(value) != 1 && obj->msg.ExtraDataPtrEnabled == 1) ||
(!obj->noExtraDataPtrCleanup && PyLong_AsLong(value) != 1 && obj->msg.Protocol == SPY_PROTOCOL_ETHERNET)) {
if (obj->msg.ExtraDataPtr != NULL)
delete[] (unsigned char*)obj->msg.ExtraDataPtr;
} else if (PyLong_AsLong(value) != 0 && obj->msg.Protocol == SPY_PROTOCOL_ETHERNET) {
// Ethernet always needs to be set to 0
return 0;
}
return PyObject_GenericSetAttr(o, name, value);
} else {
return PyObject_GenericSetAttr(o, name, value);
}
}
static PyMemberDef spy_message_object_members[] = {
{ "StatusBitField", T_UINT, offsetof(spy_message_object, msg.StatusBitField), 0, "StatusBitField" },
{ "StatusBitField2", T_UINT, offsetof(spy_message_object, msg.StatusBitField2), 0, "StatusBitField2" },
{ "TimeHardware",
T_UINT,
offsetof(spy_message_object, msg.TimeHardware),
0,
"Hardware time stamp. The TimeStamp is reset on device open" },
{ "TimeHardware2",
T_UINT,
offsetof(spy_message_object, msg.TimeHardware2),
0,
"Hardware time stamp. The TimeStamp is reset on device open" },
{ "TimeSystem",
T_UINT,
offsetof(spy_message_object, msg.TimeSystem),
0,
"TimeSystem is loaded with the value received from the timeGetTime call in the WIN32 multimedia API." },
{ "TimeSystem2",
T_UINT,
offsetof(spy_message_object, msg.TimeSystem2),
0,
"TimeSystem is loaded with the value received from the timeGetTime call in the WIN32 multimedia API." },
{ "TimeStampHardwareID",
T_UBYTE,
offsetof(spy_message_object, msg.TimeStampHardwareID),
0,
"This is an identifier of what type of hardware timestamp is used. Since neoVI's timestamp is always the same, "
"this doesn't change." },
{ "TimeStampSystemID",
T_UBYTE,
offsetof(spy_message_object, msg.TimeStampSystemID),
0,
"This is an identifier of what type of system timestamp is used. Since WIN32 neoVI's timestamp is always the "
"same, "
"from the timeGetTime API, this doesn't change." },
{ "NetworkID",
T_UBYTE,
offsetof(spy_message_object, msg.NetworkID),
0,
"This value is used to identify which network this message was received on." },
{ "NodeID", T_UBYTE, offsetof(spy_message_object, msg.NodeID), 0, "Not Used" },
{ "Protocol",
T_UBYTE,
offsetof(spy_message_object, msg.Protocol),
0,
"Valid values are SPY_PROTOCOL_CAN, SPY_PROTOCOL_J1850VPW, and SPY_PROTOCOL_ISO9141." },
{ "MessagePieceID", T_UBYTE, offsetof(spy_message_object, msg.MessagePieceID), 0, "Not Used" },
{ "ExtraDataPtrEnabled", T_UBYTE, offsetof(spy_message_object, msg.ExtraDataPtrEnabled), 0, "" },
{ "NumberBytesHeader",
T_UBYTE,
offsetof(spy_message_object, msg.NumberBytesHeader),
0,
" Used for J1850/ISO messages. It indicates how many bytes are stored in the Header(1 to 4) array." },
{ "NumberBytesData",
T_UBYTE,
offsetof(spy_message_object, msg.NumberBytesData),
0,
"Holds the number of bytes in the Data(1 to 8) array or the number of bytes in a CAN remote frame (The DLC)." },
{ "NetworkID2",
T_UBYTE,
offsetof(spy_message_object, msg.NetworkID2),
0,
"This value is used to identify which network this message was received on." },
{ "DescriptionID", T_SHORT, offsetof(spy_message_object, msg.DescriptionID), 0, "Not Used" },
{ "ArbIDOrHeader", T_UINT, offsetof(spy_message_object, msg.ArbIDOrHeader), 0, "" },
{ "Data", T_OBJECT_EX, 0, 0, "" },
{ "StatusBitField3", T_UINT, offsetof(spy_message_object, msg.StatusBitField3), 0, "StatusBitField3" },
{ "StatusBitField4", T_UINT, offsetof(spy_message_object, msg.StatusBitField4), 0, "StatusBitField4" },
{ "AckBytes", T_OBJECT_EX, 0, 0, "" },
{ "ExtraDataPtr", T_OBJECT_EX, offsetof(spy_message_object, msg.ExtraDataPtr), 0, "" },
{ "MiscData", T_UBYTE, offsetof(spy_message_object, msg.MiscData), 0, "" },
{ "noExtraDataPtrCleanup",
T_BOOL,
offsetof(spy_message_object, noExtraDataPtrCleanup),
0,
"Tells Python to not clean up ExtraDataPtrMemory, If this is enabled. Ignore, if unsure." },
{ NULL, 0, 0, 0, NULL },
};
static PyMemberDef spy_message_j1850_object_members[] = {
{ "StatusBitField", T_UINT, offsetof(spy_message_j1850_object, msg.StatusBitField), 0, "StatusBitField" },
{ "StatusBitField2", T_UINT, offsetof(spy_message_j1850_object, msg.StatusBitField2), 0, "StatusBitField2" },
{ "TimeHardware",
T_UINT,
offsetof(spy_message_j1850_object, msg.TimeHardware),
0,
"Hardware time stamp. The TimeStamp is reset on device open" },
{ "TimeHardware2",
T_UINT,
offsetof(spy_message_j1850_object, msg.TimeHardware2),
0,
"Hardware time stamp. The TimeStamp is reset on device open" },
{ "TimeSystem",
T_UINT,
offsetof(spy_message_j1850_object, msg.TimeSystem),
0,
"TimeSystem is loaded with the value received from the timeGetTime call in the WIN32 multimedia API." },
{ "TimeSystem2",
T_UINT,
offsetof(spy_message_j1850_object, msg.TimeSystem2),
0,
"TimeSystem is loaded with the value received from the timeGetTime call in the WIN32 multimedia API." },
{ "TimeStampHardwareID",
T_UBYTE,
offsetof(spy_message_j1850_object, msg.TimeStampHardwareID),
0,
"This is an identifier of what type of hardware timestamp is used. Since neoVI's timestamp is always the same, "
"this doesn't change." },
{ "TimeStampSystemID",
T_UBYTE,
offsetof(spy_message_j1850_object, msg.TimeStampSystemID),
0,
"This is an identifier of what type of system timestamp is used. Since WIN32 neoVI's timestamp is always the "
"same, "
"from the timeGetTime API, this doesn't change." },
{ "NetworkID",
T_UBYTE,
offsetof(spy_message_j1850_object, msg.NetworkID),
0,
"This value is used to identify which network this message was received on." },
{ "NodeID", T_UBYTE, offsetof(spy_message_j1850_object, msg.NodeID), 0, "Not Used" },
{ "Protocol",
T_UBYTE,
offsetof(spy_message_j1850_object, msg.Protocol),
0,
"Valid values are SPY_PROTOCOL_CAN, SPY_PROTOCOL_J1850VPW, and SPY_PROTOCOL_ISO9141." },
{ "MessagePieceID", T_UBYTE, offsetof(spy_message_j1850_object, msg.MessagePieceID), 0, "Not Used" },
{ "ExtraDataPtrEnabled", T_UBYTE, offsetof(spy_message_j1850_object, msg.ExtraDataPtrEnabled), 0, "" },
{ "NumberBytesHeader",
T_UBYTE,
offsetof(spy_message_j1850_object, msg.NumberBytesHeader),
0,
" Used for J1850/ISO messages. It indicates how many bytes are stored in the Header(1 to 4) array." },
{ "NumberBytesData",
T_UBYTE,
offsetof(spy_message_j1850_object, msg.NumberBytesData),
0,
"Holds the number of bytes in the Data(1 to 8) array or the number of bytes in a CAN remote frame (The DLC)." },
{ "NetworkID2",
T_UBYTE,
offsetof(spy_message_object, msg.NetworkID2),
0,
"This value is used to identify which network this message was received on." },
{ "DescriptionID", T_SHORT, offsetof(spy_message_j1850_object, msg.DescriptionID), 0, "Not Used" },
{ "Header", T_OBJECT_EX, 0, 0, "" },
{ "Data", T_OBJECT_EX, 0, 0, "" },
{ "StatusBitField3", T_UINT, offsetof(spy_message_j1850_object, msg.StatusBitField3), 0, "StatusBitField3" },
{ "StatusBitField4", T_UINT, offsetof(spy_message_j1850_object, msg.StatusBitField4), 0, "StatusBitField4" },
{ "AckBytes", T_OBJECT_EX, 0, 0, "" },
{ "ExtraDataPtr", T_OBJECT_EX, offsetof(spy_message_j1850_object, msg.ExtraDataPtr), 0, "" },
{ "MiscData", T_UBYTE, offsetof(spy_message_j1850_object, msg.MiscData), 0, "" },
{ "noExtraDataPtrCleanup",
T_BOOL,
offsetof(spy_message_object, noExtraDataPtrCleanup),
0,
"Tells Python to not clean up ExtraDataPtrMemory, If this is enabled. Ignore, if unsure." },
{ NULL, 0, 0, 0, NULL },
};
PyTypeObject spy_message_object_type = {
PyVarObject_HEAD_INIT(NULL, 0) MODULE_NAME "." SPY_MESSAGE_OBJECT_NAME, /* tp_name */
sizeof(spy_message_object), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)spy_message_object_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
spy_message_object_getattr, /* tp_getattro */
spy_message_object_setattr, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
SPY_MESSAGE_OBJECT_NAME " object", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
spy_message_object_members, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)spy_message_object_alloc, /* tp_init */
};
PyTypeObject spy_message_j1850_object_type = {
PyVarObject_HEAD_INIT(NULL, 0) MODULE_NAME "." SPY_MESSAGE_J1850_OBJECT_NAME, /* tp_name */
sizeof(spy_message_j1850_object), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)spy_message_object_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
spy_message_object_getattr, /* tp_getattro */
spy_message_object_setattr, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
SPY_MESSAGE_J1850_OBJECT_NAME " object", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
spy_message_j1850_object_members, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)spy_message_object_alloc, /* tp_init */
};
bool setup_spy_message_object(PyObject* module)
{
// spy_message_object_type.ob_type = &PyType_Type;
spy_message_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready(&spy_message_object_type) < 0) {
return false;
}
Py_INCREF(&spy_message_object_type);
PyModule_AddObject(module, SPY_MESSAGE_OBJECT_NAME, (PyObject*)&spy_message_object_type);
spy_message_j1850_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready(&spy_message_j1850_object_type) < 0) {
return false;
}
Py_INCREF(&spy_message_j1850_object_type);
PyModule_AddObject(module, SPY_MESSAGE_J1850_OBJECT_NAME, (PyObject*)&spy_message_j1850_object_type);
return true;
}