Library to control Dodge LX (83.3k) CAN devices
Dependencies: DodgeRadioLib EthernetWrapperLib OBDIILib mbed
radioEmulator.h@3:2ce0da6b91dc, 2012-01-09 (annotated)
- Committer:
- rtgree01
- Date:
- Mon Jan 09 02:42:50 2012 +0000
- Revision:
- 3:2ce0da6b91dc
- Parent:
- 2:e8b13ea2881b
- Child:
- 4:92f0f46edbce
last multicast version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rtgree01 |
0:4d16a55d0eec | 1 | #ifndef RADIOEMULATOR_H |
rtgree01 |
0:4d16a55d0eec | 2 | #define RADIOEMULATOR_H |
rtgree01 |
0:4d16a55d0eec | 3 | |
rtgree01 |
0:4d16a55d0eec | 4 | #include "mbed.h" |
rtgree01 |
2:e8b13ea2881b | 5 | #include "Eth.h" |
rtgree01 |
0:4d16a55d0eec | 6 | |
rtgree01 |
0:4d16a55d0eec | 7 | #include "RadioState.h" |
rtgree01 |
0:4d16a55d0eec | 8 | |
rtgree01 |
2:e8b13ea2881b | 9 | |
rtgree01 |
2:e8b13ea2881b | 10 | class RadioEmulator : public SocketReceiver |
rtgree01 |
0:4d16a55d0eec | 11 | { |
rtgree01 |
0:4d16a55d0eec | 12 | public: |
rtgree01 |
2:e8b13ea2881b | 13 | RadioEmulator(CAN *can, bool wdTO); |
rtgree01 |
0:4d16a55d0eec | 14 | ~RadioEmulator() {}; |
rtgree01 |
0:4d16a55d0eec | 15 | |
rtgree01 |
0:4d16a55d0eec | 16 | void readCANbus(void); |
rtgree01 |
2:e8b13ea2881b | 17 | |
rtgree01 |
2:e8b13ea2881b | 18 | virtual void ReceivedData(int status, int size, char *data); |
rtgree01 |
0:4d16a55d0eec | 19 | |
rtgree01 |
2:e8b13ea2881b | 20 | private: |
rtgree01 |
0:4d16a55d0eec | 21 | |
rtgree01 |
2:e8b13ea2881b | 22 | CAN *CANDevice; |
rtgree01 |
2:e8b13ea2881b | 23 | CANMessage can_MsgRx; |
rtgree01 |
2:e8b13ea2881b | 24 | DigitalOut *can_RS; |
rtgree01 |
2:e8b13ea2881b | 25 | InterruptIn *canIRQ; |
rtgree01 |
0:4d16a55d0eec | 26 | |
rtgree01 |
2:e8b13ea2881b | 27 | // void readInitFile(); |
rtgree01 |
2:e8b13ea2881b | 28 | // void writeInitFile(); |
rtgree01 |
2:e8b13ea2881b | 29 | void PowerUp(void); |
rtgree01 |
0:4d16a55d0eec | 30 | void StartEmulation(); |
rtgree01 |
2:e8b13ea2881b | 31 | |
rtgree01 |
2:e8b13ea2881b | 32 | enum {standalone, slave} opMode; |
rtgree01 |
2:e8b13ea2881b | 33 | |
rtgree01 |
0:4d16a55d0eec | 34 | void SendOnMsg(); |
rtgree01 |
0:4d16a55d0eec | 35 | void SendEVICMsg(); |
rtgree01 |
0:4d16a55d0eec | 36 | void SendRadioModeMsg(); |
rtgree01 |
0:4d16a55d0eec | 37 | void SendStereoSettingsMsg(); |
rtgree01 |
0:4d16a55d0eec | 38 | void SendHostMessages(); |
rtgree01 |
0:4d16a55d0eec | 39 | |
rtgree01 |
0:4d16a55d0eec | 40 | void ChangeSiriusStation(int station, bool turn_on); |
rtgree01 |
0:4d16a55d0eec | 41 | |
rtgree01 |
2:e8b13ea2881b | 42 | void ParseCANMessage(CANMessage can_MsgRx); |
rtgree01 |
2:e8b13ea2881b | 43 | void ReadSiriusText(char *data); |
rtgree01 |
2:e8b13ea2881b | 44 | char siriusText[8][8][8]; |
rtgree01 |
2:e8b13ea2881b | 45 | bool radioOn; |
rtgree01 |
2:e8b13ea2881b | 46 | |
rtgree01 |
0:4d16a55d0eec | 47 | void WriteCANMessages(); |
rtgree01 |
0:4d16a55d0eec | 48 | Ticker CANBusTicker; |
rtgree01 |
2:e8b13ea2881b | 49 | std::list<CANMessage> hostMessages; |
rtgree01 |
0:4d16a55d0eec | 50 | |
rtgree01 |
0:4d16a55d0eec | 51 | void SendStatusToHost(); |
rtgree01 |
0:4d16a55d0eec | 52 | Ticker statusTicker; |
rtgree01 |
3:2ce0da6b91dc | 53 | |
rtgree01 |
3:2ce0da6b91dc | 54 | RadioState status; |
rtgree01 |
3:2ce0da6b91dc | 55 | SiriusText_u st; |
rtgree01 |
3:2ce0da6b91dc | 56 | |
rtgree01 |
2:e8b13ea2881b | 57 | int prevSWC; |
rtgree01 |
2:e8b13ea2881b | 58 | |
rtgree01 |
2:e8b13ea2881b | 59 | UDPSock *HostSock; |
rtgree01 |
2:e8b13ea2881b | 60 | // Host *statusHost; |
rtgree01 |
2:e8b13ea2881b | 61 | // Host *monitorHost; |
rtgree01 |
2:e8b13ea2881b | 62 | |
rtgree01 |
0:4d16a55d0eec | 63 | void HandleHostComm(char *msg, int len); |
rtgree01 |
0:4d16a55d0eec | 64 | |
rtgree01 |
0:4d16a55d0eec | 65 | |
rtgree01 |
0:4d16a55d0eec | 66 | static char unlock[6]; |
rtgree01 |
0:4d16a55d0eec | 67 | static char lock[6]; |
rtgree01 |
0:4d16a55d0eec | 68 | static char trunk[6]; |
rtgree01 |
0:4d16a55d0eec | 69 | |
rtgree01 |
0:4d16a55d0eec | 70 | |
rtgree01 |
0:4d16a55d0eec | 71 | |
rtgree01 |
2:e8b13ea2881b | 72 | void CheckCANTimeout(void); |
rtgree01 |
2:e8b13ea2881b | 73 | void RestartCAN(void); |
rtgree01 |
2:e8b13ea2881b | 74 | Ticker CANTimeout; |
rtgree01 |
2:e8b13ea2881b | 75 | bool ReceivedCANMsg; |
rtgree01 |
2:e8b13ea2881b | 76 | bool needToParseCANMessage; |
rtgree01 |
2:e8b13ea2881b | 77 | int poweredDown; |
rtgree01 |
0:4d16a55d0eec | 78 | |
rtgree01 |
0:4d16a55d0eec | 79 | void CheckHostTimeout(void); |
rtgree01 |
0:4d16a55d0eec | 80 | Ticker HostTimeout; |
rtgree01 |
2:e8b13ea2881b | 81 | bool ReceivedHostMsg; |
rtgree01 |
0:4d16a55d0eec | 82 | |
rtgree01 |
0:4d16a55d0eec | 83 | |
rtgree01 |
0:4d16a55d0eec | 84 | void SendWOLPacket(void); |
rtgree01 |
0:4d16a55d0eec | 85 | unsigned char hostMACAddress[6]; |
rtgree01 |
0:4d16a55d0eec | 86 | |
rtgree01 |
0:4d16a55d0eec | 87 | }; |
rtgree01 |
0:4d16a55d0eec | 88 | |
rtgree01 |
0:4d16a55d0eec | 89 | #endif |