From 75adce4924b3df9523c1668c78d81f5754764b04 Mon Sep 17 00:00:00 2001 From: aaknitt Date: Thu, 31 Oct 2019 13:53:55 -0500 Subject: [PATCH] Update lin.cpp moved/added serial.flush() to Lin::recv to allow sync byte and ID byte to send properly before txPin is flipped to an INPUT. --- lin.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lin.cpp b/lin.cpp index ce5123a..657b978 100644 --- a/lin.cpp +++ b/lin.cpp @@ -135,11 +135,12 @@ uint8_t Lin::recv(uint8_t addr, uint8_t* message, uint8_t nBytes,uint8_t proto) uint8_t bytesRcvd=0; unsigned int timeoutCount=0; serialBreak(); // Generate the low signal that exceeds 1 char. - serial.flush(); serial.write(0x55); // Sync byte + serial.flush(); uint8_t idByte = (addr&0x3f) | addrParity(addr); //p("ID byte %d", idByte); serial.write(idByte); // ID byte + serial.flush(); pinMode(txPin, INPUT); digitalWrite(txPin, LOW); // don't pull up do { // I hear myself