stanleyhuangyc / Freematics

Official source code repository for Freematics
https://freematics.com
428 stars 347 forks source link

logger elm327 sketch bug #5

Closed hayden-t closed 9 years ago

hayden-t commented 9 years ago

https://github.com/stanleyhuangyc/Freematics/blob/master/firmware_v2/elm327emu/elm327emu.ino

Bug is that you are reading the char twice on incoming BT data, thus loosing data, and breaking the sketch. Below is how it could be instead.

@@ -46,7 +46,7 @@ void loop()
        cmdlen = 0;
      }
    } else if (cmdlen < sizeof(cmd)) {
-      cmd[cmdlen++] = SerialBT.read();
+      cmd[cmdlen++] = c;
    }
  }
}
stanleyhuangyc commented 9 years ago

That's really a shameful bug. :-) Thanks for figuring out.

hayden-t commented 9 years ago

no probs, happy to help.