File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ STATIC const mp_obj_property_t canio_message_id_obj = {
117
117
//| data: bytes
118
118
//| """The content of the message, or dummy content in the case of an rtr.
119
119
//|
120
- //| Assigning to data also sets the length."""
120
+ //| Assigning to data also sets the length and clears the rtr flag ."""
121
121
//|
122
122
STATIC mp_obj_t canio_message_data_get (const mp_obj_t self_in ) {
123
123
canio_message_obj_t * self = self_in ;
@@ -202,7 +202,7 @@ STATIC const mp_obj_property_t canio_message_extended_obj = {
202
202
203
203
204
204
//| rtr: bool
205
- //| """True if the message represents a remote transmission request (RTR)"""
205
+ //| """True if the message represents a remote transmission request (RTR). Setting rtr to true zeros out data """
206
206
//|
207
207
STATIC mp_obj_t canio_message_rtr_get (const mp_obj_t self_in ) {
208
208
canio_message_obj_t * self = self_in ;
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ const void *common_hal_canio_message_get_data(const canio_message_obj_t *self)
59
59
60
60
const void common_hal_canio_message_set_data (canio_message_obj_t * self , const void * data , size_t size )
61
61
{
62
+ self -> rtr = false;
62
63
self -> size = size ;
63
64
memcpy (self -> data , data , size );
64
65
}
@@ -84,6 +85,9 @@ bool common_hal_canio_message_get_rtr(const canio_message_obj_t *self)
84
85
void common_hal_canio_message_set_rtr (canio_message_obj_t * self , bool rtr )
85
86
{
86
87
self -> rtr = rtr ;
88
+ if (rtr ) {
89
+ memset (self -> data , 0 , self -> size );
90
+ }
87
91
}
88
92
89
93
bool common_hal_canio_message_get_extended (const canio_message_obj_t * self )
You can’t perform that action at this time.
0 commit comments