File pyisotp.c¶
FileList > examples > python_api > pyisotp.c
Go to the source code of this file
#include <Python.h>#include "isotp.h"#include "can_driver.h"#include "mock_can.h"#include "mock_time.h"
Public Static Attributes¶
| Type | Name |
|---|---|
| PyMethodDef | PyIsoTpMethods = /* multi line expression */ |
| struct PyModuleDef | pyisotp_module = /* multi line expression */ |
Public Functions¶
| Type | Name |
|---|---|
| PyMODINIT_FUNC | PyInit_pyisotp (void) |
Public Static Functions¶
| Type | Name |
|---|---|
| PyObject * | py_get_last_protocol_result (PyObject * self, PyObject * args) Returns the last protocol result for the sender side. |
| PyObject * | py_get_last_receive_protocol_result (PyObject * self, PyObject * args) Returns the last protocol result for the receiver side. |
| PyObject * | py_inject_can (PyObject * self, PyObject * args) Injects a raw CAN frame into the ISO-TP link for testing purposes. |
| PyObject * | py_mock_disable_fc (PyObject * self, PyObject * args) Enables or disables FlowControl frames in the mock CAN driver. |
| PyObject * | py_mock_enable_drop (PyObject * self, PyObject * args) Enables or disables CAN frame dropping in the mock CAN driver. |
| PyObject * | py_set_fc_params (PyObject * self, PyObject * args) Sets the FlowControl parameters for the ISO-TP link. |
| PyObject * | py_set_timeouts (PyObject * self, PyObject * args) Sets the timeouts for the ISO-TP link. |
| PyObject * | py_time_advance (PyObject * self, PyObject * args) Advances the virtual time in the mock time implementation by a specified delta. |
| PyObject * | py_time_reset (PyObject * self, PyObject * args) Resets the virtual time in the mock time implementation to zero. |
| PyObject * | py_time_set (PyObject * self, PyObject * args) Sets the virtual time in the mock time implementation to a specific value. |
| void | pyisotp_capsule_destructor (PyObject * capsule) Releases an ISO-TP link capsule and its allocated buffers. |
| PyObject * | pyisotp_init (PyObject * self, PyObject * args) Initializes an ISO-TP link and returns a capsule containing the link pointer to Python. |
| PyObject * | pyisotp_poll (PyObject * self, PyObject * args) Polls an ISO-TP link for timeouts and state updates. |
| PyObject * | pyisotp_receive (PyObject * self, PyObject * args) Receives data from an ISO-TP link. |
| PyObject * | pyisotp_send (PyObject * self, PyObject * args) Sends data over an ISO-TP link. |
Macros¶
| Type | Name |
|---|---|
| define | PY_SSIZE_T_CLEAN |
Public Static Attributes Documentation¶
variable PyIsoTpMethods¶
PyMethodDef PyIsoTpMethods[];
variable pyisotp_module¶
struct PyModuleDef pyisotp_module;
Public Functions Documentation¶
function PyInit_pyisotp¶
PyMODINIT_FUNC PyInit_pyisotp (
void
)
Public Static Functions Documentation¶
function py_get_last_protocol_result¶
Returns the last protocol result for the sender side.
static PyObject * py_get_last_protocol_result (
PyObject * self,
PyObject * args
)
Parameters:
self- Pointer to the module object (unused in this context)args- Tuple of arguments passed from Python (expected to be empty for this function)
Returns:
PyObject* - Python object representing the result of the operation, typically an integer status code
function py_get_last_receive_protocol_result¶
Returns the last protocol result for the receiver side.
static PyObject * py_get_last_receive_protocol_result (
PyObject * self,
PyObject * args
)
Parameters:
self- Pointer to the module object (unused in this context)args- Tuple of arguments passed from Python (expected to be empty for this function)
Returns:
PyObject* - Python object representing the result of the operation, typically an integer status code
function py_inject_can¶
Injects a raw CAN frame into the ISO-TP link for testing purposes.
static PyObject * py_inject_can (
PyObject * self,
PyObject * args
)
Parameters:
self- Pointer to the module object (unused in this context)args- Tuple of arguments passed from Python, expected to contain:- py_link (PyObject*): Capsule containing the IsoTpLink pointer
- data (bytes): Raw CAN frame data to inject (must be 2..8 bytes)
Returns:
PyObject* - Python object representing the result of the operation, typically None
function py_mock_disable_fc¶
Enables or disables FlowControl frames in the mock CAN driver.
static PyObject * py_mock_disable_fc (
PyObject * self,
PyObject * args
)
Parameters:
self- Pointer to the module object (unused in this context)args- Tuple of arguments passed from Python, expected to contain:- enable (int): Flag to enable or disable FlowControl frames
Returns:
PyObject* - Python object representing the result of the operation, typically None
function py_mock_enable_drop¶
Enables or disables CAN frame dropping in the mock CAN driver.
static PyObject * py_mock_enable_drop (
PyObject * self,
PyObject * args
)
Parameters:
self- Pointer to the module object (unused in this context)args- Tuple of arguments passed from Python, expected to contain:- enable (int): Flag to enable or disable CAN frame dropping
Returns:
PyObject* - Python object representing the result of the operation, typically None
function py_set_fc_params¶
Sets the FlowControl parameters for the ISO-TP link.
static PyObject * py_set_fc_params (
PyObject * self,
PyObject * args
)
Parameters:
self- Pointer to the module object (unused in this context)args- Tuple of arguments passed from Python, expected to contain:-
py_link (PyObject*): Capsule containing the IsoTpLink pointer
-
block_size (uint32_t): Block size for FlowControl (0 means unlimited)
st_min_ms (uint32_t): STmin in milliseconds
Returns:
PyObject* - Python object representing the result of the operation, typically None
function py_set_timeouts¶
Sets the timeouts for the ISO-TP link.
static PyObject * py_set_timeouts (
PyObject * self,
PyObject * args
)
Parameters:
self- Pointer to the module object (unused in this context)args- Tuple of arguments passed from Python, expected to contain:-
py_link (PyObject*): Capsule containing the IsoTpLink pointer
-
n_bs_ms (uint32_t): N_Bs timeout in milliseconds
n_cr_ms (uint32_t): N_Cr timeout in milliseconds
Returns:
PyObject* - Python object representing the result of the operation, typically None
function py_time_advance¶
Advances the virtual time in the mock time implementation by a specified delta.
static PyObject * py_time_advance (
PyObject * self,
PyObject * args
)
Parameters:
self- Pointer to the module object (unused in this context)args- Tuple of arguments passed from Python, expected to contain:- delta (uint32_t): The number of milliseconds to advance the virtual time
Returns:
PyObject* - Python object representing the result of the operation, typically None
function py_time_reset¶
Resets the virtual time in the mock time implementation to zero.
static PyObject * py_time_reset (
PyObject * self,
PyObject * args
)
Parameters:
self- Pointer to the module object (unused in this context)args- Tuple of arguments passed from Python (expected to be empty for this function)
Returns:
PyObject* - Python object representing the result of the operation, typically None
function py_time_set¶
Sets the virtual time in the mock time implementation to a specific value.
static PyObject * py_time_set (
PyObject * self,
PyObject * args
)
Parameters:
self- Pointer to the module object (unused in this context)args- Tuple of arguments passed from Python, expected to contain:- value (uint32_t): The value to set the virtual time to, in milliseconds
Returns:
PyObject* - Python object representing the result of the operation, typically None
function pyisotp_capsule_destructor¶
Releases an ISO-TP link capsule and its allocated buffers.
static void pyisotp_capsule_destructor (
PyObject * capsule
)
function pyisotp_init¶
Initializes an ISO-TP link and returns a capsule containing the link pointer to Python.
static PyObject * pyisotp_init (
PyObject * self,
PyObject * args
)
Parameters:
self- Pointer to the module object (unused in this context)args- Tuple of arguments passed from Python, expected to contain:- sendid (uint32_t): CAN ID to send on
Returns:
PyObject* - Python object representing the result of the operation, typically a capsule containing the IsoTpLink pointer or an error indicator
function pyisotp_poll¶
Polls an ISO-TP link for timeouts and state updates.
static PyObject * pyisotp_poll (
PyObject * self,
PyObject * args
)
Parameters:
self- Pointer to the module object (unused in this context)args- Tuple of arguments passed from Python, expected to contain:- py_link (PyObject*): Capsule containing the IsoTpLink pointer
Returns:
PyObject* - Python object representing the result of the operation, typically None
function pyisotp_receive¶
Receives data from an ISO-TP link.
static PyObject * pyisotp_receive (
PyObject * self,
PyObject * args
)
Parameters:
self- Pointer to the module object (unused in this context)args- Tuple of arguments passed from Python, expected to contain:- py_link (PyObject*): Capsule containing the IsoTpLink pointer
- bufsize (Py_ssize_t): Size of the buffer to receive data into
Returns:
PyObject* - Python object representing the result of the operation, typically bytes containing received data or None if no data
function pyisotp_send¶
Sends data over an ISO-TP link.
static PyObject * pyisotp_send (
PyObject * self,
PyObject * args
)
Parameters:
self- Pointer to the module object (unused in this context)args- Tuple of arguments passed from Python, expected to contain:- py_link (PyObject*): Capsule containing the IsoTpLink pointer
- data (bytes): Data to send
Returns:
PyObject* - Python object representing the result of the operation, typically an integer status code
Macro Definition Documentation¶
define PY_SSIZE_T_CLEAN¶
#define PY_SSIZE_T_CLEAN
The documentation for this class was generated from the following file examples/python_api/pyisotp.c