Advertisement
RuiViana

CheckSum7

Jan 13th, 2016
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. // @00RD0000000157*
  2. // 0123456789012345
  3. char Mat[64];
  4. char Result[64];
  5. String Dados;
  6. int QteBytes;
  7. byte FCS = 0;
  8. //--------------------------------------
  9. void setup()
  10. {
  11. Serial.begin(9600);
  12. }
  13. //--------------------------------------
  14. void loop()
  15. {
  16. if (Serial.available())
  17. {
  18. Dados = Serial.readString();
  19. Serial.print ("Recebido ");
  20. Serial.println(Dados);
  21. QteBytes = Dados.length();
  22. Dados.toCharArray(Result,(QteBytes-2));
  23. for (int i = 0; i <=(QteBytes-2); i++)
  24. {
  25. FCS = FCS^Result[i];
  26. }
  27. Serial.print ("FCS calculado ");
  28. Serial.println(FCS,HEX);
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement