I messed up the merge, so pushing it over to another repo so I don't lose it. Will tidy up and remove later
Dependencies: BufferedSerial FatFileSystemCpp mbed
Revision 58:8cce8fcc765f, committed 2021-09-13
- Comitter:
- JamieB
- Date:
- Mon Sep 13 07:38:22 2021 +0000
- Parent:
- 57:ba6f516d93b9
- Child:
- 59:10ab123d3c7c
- Commit message:
- Reduced Ethernet latency and Increased thread priority
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Sep 03 08:43:37 2021 +0000 +++ b/main.cpp Mon Sep 13 07:38:22 2021 +0000 @@ -1,4 +1,4 @@ -#define APP_VERSION 0.16 +#define APP_VERSION 0.17 /* Settings file options @@ -135,6 +135,10 @@ Timer TimeSinceLastFrame; uint32_t TimeSinceLastFrameWrap; +//Debug Timer for Ethernet +Timer EthernetTimer; +uint32_t TimeSinceLastEthernetPacket; + // used to start PPS at the correct point Timeout PPSsyncTimer; @@ -175,6 +179,8 @@ struct D1MsgFormat_s fdPacket; volatile bool EthTxNow = false; +Mutex NewData; + void filterOff(void) { @@ -457,6 +463,7 @@ void UDP_Tx_Now() { EthTxNow = true; + NewData.unlock(); } void applyOffsets(float *value, int offset, bool invert, int max_wrap) @@ -479,6 +486,7 @@ void sendPosition(position *posPtr) { + NewData.lock(); static bool NoDataWarn = true; if (!posPtr) { if (NoDataWarn) { // only warn once per dropout @@ -842,8 +850,11 @@ VIPSSocket->set_broadcasting(true); VIPSTarget.set_address(0xFFFFFFFF, UserSettings.VipsUDPPort); } + EthernetTimer.reset(); + EthernetTimer.start(); while (true) { if (EthTxNow) { +// NewData.lock(); EthTxNow = false; if (!FreeDSocket && UserSettings.FreeDPort) { pc.puts("No FreeD UDP socket\r\n"); @@ -855,10 +866,13 @@ } if (FreeDSocket) { Result = FreeDSocket->sendTo(FreeDTarget,(char *)&fdPacket, sizeof(struct D1MsgFormat_s)); + //uint32_t ethtime = EthernetTimer.read_us(); + //EthernetTimer.reset(); if (Result != sizeof(struct D1MsgFormat_s)) { pc.puts("FreeD UDP Tx Failed!\r\n"); break; - } + } //else + //pc.printf("%d\r\n", ethtime); } if (VIPSSocket) { Result = VIPSSocket->sendTo(VIPSTarget,(char *)FlexibleVIPSOut, VIPSOutSize); @@ -869,7 +883,8 @@ } // pc.puts("UDP Tx\r\n"); } else - Thread::wait(5); +// NewData.unlock(); + Thread::wait(1); } eth.disconnect(); pc.puts("Attempting to restart network\r\n"); @@ -968,8 +983,7 @@ // FIZPort = new FIZDigiPowerActive(p9, p10); COM1.baud(115200); // radio port - Thread serialTask(ethernetTask, &UserSettings, osPriorityNormal, 256 * 4); - + Thread serialTask(ethernetTask, &UserSettings, osPriorityHigh, 256 * 4); led1 = 0; inputTimer.reset(); inputTimer.start();