nts-1-customizations
nts-1-customizations copied to clipboard
nts1_iface.c: add aligned atrtribute to s_rx_event_decode_buf
Issue: The following sketch does not work.
In the message handler rx_value()
, val->value
causes system crash.
I suspected this is a memory alignment problem, and added __attribute__((aligned))
to s_rx_event_decode_buf
in nts1_iface.c
. Then it seems to work correctly.
#include <nts-1.h>
NTS1 nts1;
void rx_value(const nts1_rx_value_t *val) {
Serial.print("req_id = ");
Serial.println(val->req_id);
Serial.print("value = ");
Serial.println(val->value); // this line doesn't work!
}
void setup() {
Serial.begin(9600);
Serial.println("Start!");
nts1.init();
nts1.setValueEventHandler((nts1_value_event_handler) rx_value);
nts1.reqOscCount();
}
void loop() {
nts1.idle();
}