clear message queue on reset.
This commit is contained in:
parent
82c1f45f59
commit
36fccb6459
@ -19,6 +19,13 @@ static const char *const TAG = "truma_inetbox.LinBusProtocol";
|
|||||||
#define LIN_SID_HEARTBEAT 0xB9
|
#define LIN_SID_HEARTBEAT 0xB9
|
||||||
#define LIN_SID_HEARTBEAT_RESPONSE (LIN_SID_HEARTBEAT | LIN_SID_RESPONSE)
|
#define LIN_SID_HEARTBEAT_RESPONSE (LIN_SID_HEARTBEAT | LIN_SID_RESPONSE)
|
||||||
|
|
||||||
|
void LinBusProtocol::lin_reset_device(){
|
||||||
|
// clear any messages in send queue of LinBus Protocol handler.
|
||||||
|
while (!this->updates_to_send_.empty()) {
|
||||||
|
this->updates_to_send_.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool LinBusProtocol::answer_lin_order_(const u_int8_t pid) {
|
bool LinBusProtocol::answer_lin_order_(const u_int8_t pid) {
|
||||||
// Send requested answer
|
// Send requested answer
|
||||||
if (pid == DIAGNOSTIC_FRAME_SLAVE) {
|
if (pid == DIAGNOSTIC_FRAME_SLAVE) {
|
||||||
@ -150,11 +157,12 @@ void LinBusProtocol::lin_msg_diag_single_(const u_int8_t *message, u_int8_t leng
|
|||||||
response[0] = this->lin_node_address_;
|
response[0] = this->lin_node_address_;
|
||||||
response[1] = 1; /* bytes length*/
|
response[1] = 1; /* bytes length*/
|
||||||
response[2] = LIN_SID_ASSIGN_NAD_RESPONSE;
|
response[2] = LIN_SID_ASSIGN_NAD_RESPONSE;
|
||||||
this->prepare_update_msg_(response);
|
|
||||||
this->lin_node_address_ = message[7];
|
|
||||||
|
|
||||||
// assumption an assign new SID occurs as part of init process.
|
// assumption an assign new SID occurs as part of init process.
|
||||||
this->lin_reset_device();
|
this->lin_reset_device();
|
||||||
|
|
||||||
|
this->prepare_update_msg_(response);
|
||||||
|
this->lin_node_address_ = message[7];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (my_node_address) {
|
if (my_node_address) {
|
||||||
|
|||||||
@ -9,7 +9,7 @@ class LinBusProtocol : public LinBusListener {
|
|||||||
public:
|
public:
|
||||||
virtual const std::array<u_int8_t, 4> lin_identifier() = 0;
|
virtual const std::array<u_int8_t, 4> lin_identifier() = 0;
|
||||||
virtual void lin_heartbeat() = 0;
|
virtual void lin_heartbeat() = 0;
|
||||||
virtual void lin_reset_device() = 0;
|
virtual void lin_reset_device();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const std::array<u_int8_t, 8> lin_empty_response_ = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
const std::array<u_int8_t, 8> lin_empty_response_ = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||||
|
|||||||
@ -82,6 +82,7 @@ const std::array<uint8_t, 4> TrumaiNetBoxApp::lin_identifier() {
|
|||||||
void TrumaiNetBoxApp::lin_heartbeat() { this->device_registered_ = micros(); }
|
void TrumaiNetBoxApp::lin_heartbeat() { this->device_registered_ = micros(); }
|
||||||
|
|
||||||
void TrumaiNetBoxApp::lin_reset_device() {
|
void TrumaiNetBoxApp::lin_reset_device() {
|
||||||
|
LinBusProtocol::lin_reset_device();
|
||||||
this->device_registered_ = micros();
|
this->device_registered_ = micros();
|
||||||
this->init_recieved_ = 0;
|
this->init_recieved_ = 0;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user