AbedN
02/22/2025, 2:41 PMfloitsch
02/23/2025, 12:25 PMio.LITTLE-ENDIAN to read the float out again.AbedN
02/25/2025, 3:30 PMAbedN
02/25/2025, 3:31 PMfloitsch
02/25/2025, 3:37 PMfloitsch
02/25/2025, 3:44 PMtoit_msg_notify is. Most likely it's TOIT_ERR_NO_SUCH_RECEIVER.
2. you are passing in a buffer that is allocated on the stack (uint8_t temp[4]). Since you are leaving the function just after sending the data (return TOIT_OK) the buffer will get invalid. So use a malloc (or toit_malloc) instead. It's also a problem, as toit_msg_notify takes ownership of the buffer (see the comment of the function) and will eventually free the buffer.
3. the last parameter of the toit_msg_notify is free_on_failure (https://github.com/toitlang/toit/blob/1f4f86faa2c5be88f0b0df3f7aa401b71c4d7052/include/toit/toit.h#L221). This means that the toit call will delete the message if it couldn't send it. And that's exactly what's happening here. Since the sending didn't work, Toit tried to free the buffer, which is your stack-allocated object. And that's not a good idea.floitsch
02/25/2025, 3:45 PM