FreeEMS
0.2.0-SNAPSHOT-285-g028e24c
|
Core communications functions. More...
#include "inc/freeEMS.h"
#include "inc/flashWrite.h"
#include "inc/interrupts.h"
#include "inc/utils.h"
#include "inc/tableLookup.h"
#include "inc/locationIDs.h"
#include "inc/blockDetailsLookup.h"
#include "inc/decoderInterface.h"
#include "inc/commsCore.h"
#include "inc/init.h"
#include <string.h>
#include "decoders/inc/BenchTest.h"
Go to the source code of this file.
Macros | |
#define | COMMSCORE_C |
Functions | |
unsigned short | populateBasicDatalog () |
Populate a basic datalog packet. | |
void | finaliseAndSend (unsigned short errorID) |
Finalise a packet and send it. | |
void | decodePacketAndRespond () |
Decode a packet and respond. |
Core communications functions.
This file contains most of the core comms functionality. Currently that is only for UART serial style communication. It is already too big and needs to be split up somewhat. This will happen fairly soon during the serial refactoring and protocol fine tuning.
TODO function to setup a packet and send it fn(populateBodyFunctionPointer(), header, other, fields, here, and, use, or, not, within){}
TODO factor many things into functions and move the receive delegator to its own file
Definition in file commsCore.c.
#define COMMSCORE_C |
Definition at line 43 of file commsCore.c.
unsigned short populateBasicDatalog | ( | void | ) |
Populate a basic datalog packet.
Copies various chunks of data to the transmission buffer and truncates to the configured length. If changing this, update the maxBasicDatalogLength.
Definition at line 63 of file commsCore.c.
References KeyUserDebug::clockIn8thsOfAMilli, KeyUserDebug::clockInMilliSeconds, Clocks, KeyUserDebug::coreStatusA, coreStatusA, KeyUserDebugs, Clock::realTimeClockMain, Clock::realTimeClockMillis, KeyUserDebug::tempClock, and TXBufferCurrentPositionHandler.
Referenced by decodePacketAndRespond(), and main().
void finaliseAndSend | ( | unsigned short | errorID | ) |
Finalise a packet and send it.
This functions job is to finalise the main loop part of the packet sending process. It configures the pos/neg ack header bit, adds the code if neg, runs a checksum over the packet data and tags it to the end before configuring the various ISRs that need to send the data out.
Definition at line 141 of file commsCore.c.
References checksum(), COM_CLEAR_CAN0_INTERFACE_ID, COM_CLEAR_SPARE2_INTERFACE_ID, COM_CLEAR_SPARE3_INTERFACE_ID, COM_CLEAR_SPARE4_INTERFACE_ID, COM_CLEAR_SPARE5_INTERFACE_ID, COM_CLEAR_SPARE6_INTERFACE_ID, COM_CLEAR_SPARE7_INTERFACE_ID, COM_SET_CAN0_INTERFACE_ID, COM_SET_SCI0_INTERFACE_ID, COM_SET_SPARE2_INTERFACE_ID, COM_SET_SPARE3_INTERFACE_ID, COM_SET_SPARE4_INTERFACE_ID, COM_SET_SPARE5_INTERFACE_ID, COM_SET_SPARE6_INTERFACE_ID, COM_SET_SPARE7_INTERFACE_ID, HEADER_IS_NACK, SCI0CR2, SCI0DRL, SCICR2_TX_ENABLE, SCICR2_TX_ISR_ENABLE, START_BYTE, TXBufferCurrentPositionHandler, TXBufferInUseFlags, and TXHeaderFlags.
Referenced by decodePacketAndRespond(), and main().
void decodePacketAndRespond | ( | void | ) |
Decode a packet and respond.
This is the core function that controls which functionality is run when a packet is received in full by the ISR code and control is passed back to the main loop code. The vast majority of communications action happens here.
TODO
TODO
TODO
Definition at line 207 of file commsCore.c.
References _start(), ARMCOP, asyncDatalogLastType, ATOMIC_END, ATOMIC_START, attemptToWriteToReadOnlyBlock, BENCH_TEST_NAME, BENCH_TEST_ON, benchTestAlreadyRunning, benchTestNotRunningToBump, benchTestNotRunningToStop, block_is_2dus_table, block_is_indexable, block_is_main_table, block_is_read_only, buildTimeAndDate, builtByName, bumpingByZeroMakesNoSense, burnBlockFromRamToFlash, checksum(), CLEAR_ALL_SOURCE_ID_FLAGS, clearCountersAndFlagsToZero, Clocks, COM_SET_SCI0_INTERFACE_ID, compare(), compilerVersion, COPCTL, coreStatusA, CoreVars, Counters, KeyUserDebug::currentEvent, decoderMaxCodeTime, decoderName, DerivedVars, doesNotMakeSenseToRetrievePartially, DerivedVar::Dwell, ectSwitchOnCodeTime, finaliseAndSend(), firmwareVersion, FLAG_AND_INC_FLAGGABLE, FLAG_SERIAL_CHECKSUM_MISMATCHES_OFFSET, FLAG_SERIAL_PACKETS_UNDER_LENGTH_OFFSET, KeyUserDebug::flaggableFlags, KeyUserDebug::flaggableFlags2, Flaggables, Flaggables2, blockDetails::flags, blockDetails::FlashAddress, blockDetails::FlashPage, HEADER_HAS_LENGTH, HEADER_HAS_SEQUENCE, init(), interfaceVersion, invalidEventsPerCycle, invalidMemoryActionForID, invalidNumberOfCycles, invalidPayloadID, invalidSizeOffsetCombination, KeyUserDebugs, lookupBlockDetails(), lookupTwoDTableUS(), MEMORY_WRITE_ERROR, noChannelsConfiguredToTest, noSuchAsyncDatalogType, noSuchUnitTestID, operatingSystem, outputEventDelayFinalPeriod, outputEventInputEventNumbers, outputEventPulseWidthsMath, packetSizeWrongForTestMode, packetTooShortForSpecifiedFields, payloadLengthHeaderMismatch, payloadLengthTypeMismatch, payloadNotEqualToSpecifiedValue, payloadShorterThanRequiredForTest, populateBasicDatalog(), PPAGE, PPAGE_MIN, blockDetails::RAMAddress, blockDetails::RAMPage, DerivedVar::RefPW, requestBuiltByName, requestCompilerVersion, requestDatalogPacket, requestDecoderName, requestEchoPacketReturn, requestedAddressDisallowed, requestedFlashPageInvalid, requestedLengthTooLarge, requestedRAMPageInvalid, requestFirmwareBuildDate, requestFirmwareVersion, requestHardSystemReset, requestInterfaceVersion, requestMaxPacketSize, requestOperatingSystem, requestReInitOfSystem, requestSoftSystemReset, requestSupportEmail, requestUnitTestOverSerial, resetReceiveState(), retrieveArbitraryMemory, retrieveBlockFromFlash, retrieveBlockFromRAM, retrieveListOfLocationIDs, retrieveLocationIDDetails, RPAGE, RPAGE_MIN, CoreVar::RPM, RX_BUFFER_SIZE, RXBufferCurrentPosition, RXCalculatedPayloadLength, RXHeaderFlags, RXHeaderPayloadID, RXHeaderPayloadLength, KeyUserDebug::serialAndCommsCodeErrors, setAsyncDatalogType, blockDetails::size, startBenchTestSequence, stringCopy(), supportEmail, TEST_MODE_BUMP_UP_CYCLES, TEST_MODE_DODGY_MISSING_TOOTH, TEST_MODE_ITERATIONS, TEST_MODE_STOP, testEmptyTest, testEventsPerCycle, testMode, testNumberOfCycles, testNumberOfMissing, testTicksPerEvent, testTwoDTableUSLookup, thisIsNotTheBenchTestDecoder, TIE, Clock::timeoutADCreadingClock, tooManyEventsPerCycleMissingTth, tooShortOfAnEventPeriod, tooShortOfAPulseWidthToTest, TX_MAX_PAYLOAD_SIZE, TXBufferCurrentPositionCAN0, TXBufferCurrentPositionHandler, TXBufferCurrentPositionSCI0, TXBufferInUseFlags, TXHeaderFlags, uncheckedTableManipulationNotAllowed, unimplementedTestMode, unrecognisedPayloadID, updateBlockInFlash, updateBlockInRAM, validateMainTable(), validateTwoDTable(), and writeBlock().
Referenced by main().