Thomas Milburn
/
FBRDash-tom
can't push chnages :(
Fork of FBRDash by
src/Comms.cpp@2:825f572902c6, 2012-06-25 (annotated)
- Committer:
- intrinseca
- Date:
- Mon Jun 25 21:20:22 2012 +0000
- Revision:
- 2:825f572902c6
- Parent:
- 1:b3907b8d9f65
- Child:
- 5:177520d43c87
Add comments
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
intrinseca | 1:b3907b8d9f65 | 1 | #include "PCComms.h" |
intrinseca | 1:b3907b8d9f65 | 2 | #include "mbed.h" |
intrinseca | 1:b3907b8d9f65 | 3 | #include "State.h" |
intrinseca | 1:b3907b8d9f65 | 4 | |
intrinseca | 2:825f572902c6 | 5 | //Process incoming data from Comms interfaces |
intrinseca | 2:825f572902c6 | 6 | |
intrinseca | 2:825f572902c6 | 7 | //Initialise members |
intrinseca | 1:b3907b8d9f65 | 8 | Comms::Comms(State* _values) |
intrinseca | 1:b3907b8d9f65 | 9 | { |
intrinseca | 1:b3907b8d9f65 | 10 | values = _values; |
intrinseca | 1:b3907b8d9f65 | 11 | } |
intrinseca | 1:b3907b8d9f65 | 12 | |
intrinseca | 2:825f572902c6 | 13 | //Process an incoming data packet |
intrinseca | 1:b3907b8d9f65 | 14 | void Comms::process_packet(unsigned char id, int length, unsigned char data[]) |
intrinseca | 1:b3907b8d9f65 | 15 | { |
intrinseca | 1:b3907b8d9f65 | 16 | switch(id) |
intrinseca | 1:b3907b8d9f65 | 17 | { |
intrinseca | 1:b3907b8d9f65 | 18 | case 100: |
intrinseca | 1:b3907b8d9f65 | 19 | values->rpm = data[0] + (data[1] << 8); |
intrinseca | 1:b3907b8d9f65 | 20 | values->throttle_pos = data[2]; |
intrinseca | 1:b3907b8d9f65 | 21 | values->manifold_pres = data[3]; |
intrinseca | 1:b3907b8d9f65 | 22 | values->air_temp = data[4]; |
intrinseca | 1:b3907b8d9f65 | 23 | values->coolant_temp = data[5]; |
intrinseca | 1:b3907b8d9f65 | 24 | values->lambda = data[6]; |
intrinseca | 1:b3907b8d9f65 | 25 | break; |
intrinseca | 1:b3907b8d9f65 | 26 | case 200: |
intrinseca | 1:b3907b8d9f65 | 27 | values->speed = data[0]; |
intrinseca | 1:b3907b8d9f65 | 28 | values->accel_x = data[1]; |
intrinseca | 1:b3907b8d9f65 | 29 | values->accel_y = data[2]; |
intrinseca | 1:b3907b8d9f65 | 30 | values->gear = data[3]; |
intrinseca | 1:b3907b8d9f65 | 31 | values->oil_temp = data[4]; |
intrinseca | 1:b3907b8d9f65 | 32 | values->oil_pres = data[5]; |
intrinseca | 1:b3907b8d9f65 | 33 | values->warnings = data[6]; |
intrinseca | 1:b3907b8d9f65 | 34 | break; |
intrinseca | 1:b3907b8d9f65 | 35 | } |
intrinseca | 1:b3907b8d9f65 | 36 | } |