/* Speeduino - Simple engine management for the Arduino Mega 2560 platform Copyright (C) Josh Stewart A full copy of the license may be found in the projects root directory can_comms was originally contributed by Darren Siepka */ /* can_command is called when a command is received over serial3 from the Can interface It parses the command and calls the relevant function sendcancommand is called when a comman d is to be sent via serial3 to the Can interface */ //#include "cancomms.h" //#include "globals.h" //#include "storage.h" void canCommand() { switch (Serial3.read()) { case 'A': // sends the bytes of realtime values sendValues(packetSize,3); //send values to serial3 break; case 'G': // this is the reply command sent by the Can interface uint8_t Gdata; while (Serial3.available() == 0) { } cancmdfail = Serial3.read(); if (cancmdfail == 0) { //command request failed and/or data/device was not available } while (Serial3.available() == 0) { } Gdata= Serial3.read(); break; case 'L': uint8_t Llength; while (Serial3.available() == 0) { } canlisten = Serial3.read(); if (canlisten == 0) { //command request failed and/or data/device was not available break; } while (Serial3.available() == 0) { } Llength= Serial3.read(); // next the number of bytes expected value for (uint8_t Lcount = 0; Lcount