-
Notifications
You must be signed in to change notification settings - Fork 0
/
RealCar.cpp
52 lines (45 loc) · 955 Bytes
/
RealCar.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "RealCar.h"
bool RealCar::shouldRun(unsigned long time) {
if(CAN_MSGAVAIL == _can->checkReceive()) {
return true;
}
return false;
}
void RealCar::run(){
unsigned char len = 0;
unsigned char buf[29];
Serial.println("RealCar::run");
_can->readMsgBuf(&len, buf);
unsigned long canId = _can->getCanId();
switch(canId) {
case PID_SPEED:
_speed = _parseSpeedMessage(buf);
break;
case PID_RPM:
_rpm = _parseRPMMessage(buf);
break;
case PID_FUEL_LEVEL:
_fuelLevel = _parseFuelLevelMessage(buf);
break;
case PID_COOLANT_TEMP:
_temp = _parseTempMessage(buf);
break;
}
Thread::run();
}
int RealCar::_parseRPMMessage(unsigned char* rpm) {
// @TODO
return 0;
}
int RealCar::_parseFuelLevelMessage(unsigned char* fuelLevel) {
// @TODO
return 0;
}
int RealCar::_parseSpeedMessage(unsigned char* speed) {
// @TODO
return 0;
}
int RealCar::_parseTempMessage(unsigned char* temp) {
// @TODO
return 0;
}