Library to control Dodge LX (83.3k) CAN devices
Dependencies: DodgeRadioLib EthernetWrapperLib OBDIILib mbed
Revision 3:2ce0da6b91dc, committed 2012-01-09
- Comitter:
- rtgree01
- Date:
- Mon Jan 09 02:42:50 2012 +0000
- Parent:
- 2:e8b13ea2881b
- Child:
- 4:92f0f46edbce
- Commit message:
- last multicast version
Changed in this revision
--- a/EthernetWrapperLib/Eth.cpp Mon Jan 02 03:53:46 2012 +0000 +++ b/EthernetWrapperLib/Eth.cpp Mon Jan 09 02:42:50 2012 +0000 @@ -25,7 +25,6 @@ bufferSize = buff; receiver = sr; buffer = new char[bufferSize]; - busy = false; udp.setOnEvent(this, &UDPSock::onUDPSocketEvent); udp.bind(*local); @@ -33,10 +32,7 @@ void UDPSock::SendTo(Host *remote, int size, char *data) { - while (busy == true) {}; - busy = true; udp.sendto(data, size, remote); - busy = false; } void UDPSock::onUDPSocketEvent(UDPSocketEvent e) @@ -44,7 +40,6 @@ switch(e) { case UDPSOCKET_READABLE: //The only event for now - printf("got data\r\n"); Host host; while( int len = udp.recvfrom( buffer, bufferSize, &host ) ) {
--- a/EthernetWrapperLib/Eth.h Mon Jan 02 03:53:46 2012 +0000 +++ b/EthernetWrapperLib/Eth.h Mon Jan 09 02:42:50 2012 +0000 @@ -38,7 +38,7 @@ int bufferSize; char *buffer; SocketReceiver *receiver; - bool busy; + void onUDPSocketEvent(UDPSocketEvent e); };
--- a/RadioState.h Mon Jan 02 03:53:46 2012 +0000 +++ b/RadioState.h Mon Jan 09 02:42:50 2012 +0000 @@ -3,6 +3,12 @@ enum radioMode { AM, FM, CD, SAT, VES, MAX_MODE }; +union SiriusText_u +{ + char TextLine[8][64]; + char data[512]; +}; + struct RadioState { char marker1; @@ -26,7 +32,6 @@ int _siriusPreset; int _siriusChan; - char _siriusTextLine[8][64]; int _evicMode; int _evicPreset;
--- a/main.cpp Mon Jan 02 03:53:46 2012 +0000 +++ b/main.cpp Mon Jan 09 02:42:50 2012 +0000 @@ -19,7 +19,7 @@ { radio = new RadioEmulator(&interiorBus, wdt.TimedOut()); - obdii = new ecu_reader(&obd2Bus, CANSPEED_500); //Create object and set CAN speed +// obdii = new ecu_reader(&obd2Bus, CANSPEED_500); //Create object and set CAN speed wdt.kick(2); @@ -29,7 +29,7 @@ radio->readCANbus(); - obdii->UpdateData(); +// obdii->UpdateData(); wdt.kick(); }
--- a/radioEmulator.cpp Mon Jan 02 03:53:46 2012 +0000 +++ b/radioEmulator.cpp Mon Jan 09 02:42:50 2012 +0000 @@ -61,11 +61,11 @@ { if (wdTO) { - sprintf(status._siriusTextLine[i], "WATCH DOG TIMED OUT"); + sprintf(st.TextLine[i], "WATCH DOG TIMED OUT"); } else { - sprintf(status._siriusTextLine[i], "Fun line text # %d", i); + sprintf(st.TextLine[i], "Fun line text # %d", i); } } @@ -567,13 +567,13 @@ { for (int i = 0; i < 8; i++) { - memset(status._siriusTextLine[i], 0, 64); + memset(st.TextLine[i], 0, 64); for (int j = 0; j < 8; j++) { - strcat(status._siriusTextLine[i], siriusText[i][j]); + strcat(st.TextLine[i], siriusText[i][j]); } - printf("%d: %s\r\n", i, status._siriusTextLine[i]); + printf("%d: %s\r\n", i, st.TextLine[i]); } } } @@ -592,8 +592,10 @@ buffer[1] = can_MsgRx.id & 0x00FF; buffer[2] = can_MsgRx.len; memcpy(&buffer[3], can_MsgRx.data, 8); - -// HostSock->SendTo(monitorHost, 11, buffer); + + static Host monitorHost(IpAddr(239, 192, 1, 100), 41000, NULL); + HostSock->SendTo(&monitorHost, 11, buffer); + } if (needToParseCANMessage) @@ -606,7 +608,6 @@ void RadioEmulator::ReceivedData(int status, int size, char *data) { - printf("Received from host\r\n"); HandleHostComm(data, size); } @@ -727,7 +728,13 @@ status.count++; static Host statusHost(IpAddr(239, 192, 1, 100), 51000, NULL); //Join multicast group on port 50000 -// HostSock->SendTo(&statusHost, size, (char *)&status); + HostSock->SendTo(&statusHost, size, (char *)&status); + + if ((status.count % 10) == 0) + { + static Host siriusTextHost(IpAddr(239, 192, 1, 100), 61000, NULL); //Join multicast group on port 50000 + HostSock->SendTo(&siriusTextHost, 512, st.data); + } } void RadioEmulator::CheckHostTimeout(void)
--- a/radioEmulator.h Mon Jan 02 03:53:46 2012 +0000 +++ b/radioEmulator.h Mon Jan 09 02:42:50 2012 +0000 @@ -50,7 +50,10 @@ void SendStatusToHost(); Ticker statusTicker; - RadioState status; + + RadioState status; + SiriusText_u st; + int prevSWC; UDPSock *HostSock;