speeduino/speeduino/logger.h

41 lines
1.2 KiB
C
Raw Normal View History

/** \file logger.h
* @brief File for generating log files and meta data
* @author Josh Stewart
*
* This file contains functions for creating a log file for use with by TunerStudio directly or to be written to an SD card
*
*/
#ifndef LOGGER_H
#define LOGGER_H
#include "globals.h" // Needed for FPU_MAX_SIZE
2020-11-19 02:38:00 -08:00
#ifndef UNIT_TEST // Scope guard for unit testing
2023-09-17 23:02:45 -07:00
#define LOG_ENTRY_SIZE 127 /**< The size of the live data packet. This MUST match ochBlockSize setting in the ini file */
2020-11-19 02:38:00 -08:00
#else
#define LOG_ENTRY_SIZE 1 /**< The size of the live data packet. This MUST match ochBlockSize setting in the ini file */
#endif
2022-11-05 15:43:29 -07:00
byte getTSLogEntry(uint16_t byteNum);
int16_t getReadableLogEntry(uint16_t logIndex);
#if defined(FPU_MAX_SIZE) && FPU_MAX_SIZE >= 32 //cppcheck-suppress misra-c2012-20.9
2022-11-05 15:43:29 -07:00
float getReadableFloatLogEntry(uint16_t logIndex);
#endif
uint8_t getLegacySecondarySerialLogEntry(uint16_t byteNum);
2022-11-05 15:43:29 -07:00
bool is2ByteEntry(uint8_t key);
2021-10-12 17:53:46 -07:00
Refactor comms: save 130+ bytes RAM (#906) * Remove serialCRC - only used within parseSerial() Also hoist the CRC read into a function. * Minimize global variable visibility * Encapsulate write of multi-byte primitives * Factor out sendBufferAndCrc() * Push safety test into TS_CommandButtonsHandler() * Extract writePage() * Simpler parsing * Remove some functions from public interface * Store constant arrays in progmem * Centralize high speed logger start/stop code * Factor out loadO2Calibration() * Factor out temperature calibration table update functions * Remove dead code * Fix sendToothLog() * Fix sendCompositeLog() * Replace tooth log send booleans with an enum Saves a byte * Remove sendBufferAndCrcProgMem() Use serialPayload to send * Whitespace clean up * Optimize comms.cpp for size * Replace global unsigned long with bool Saves 2 bytes * Replace 2 global bools with an enum Saves a byte, reads better. * Remove global FastCRC instance * Make sendSerialReturnCode blocking. It was using non-blocking functions but was never re-entered. Rename to make blocking & non-blocking calls more obvious. * Use one uint16_t to track RX/TX byte count * Simplify new comms log tx API * Extract loadPageToBuffer function * All endianess changes use the same code * Doxygen comments and code organization * Remove serialWriteUpdateCrc() & updateTmpCalibration() * Combine SerialStatus & logSendStatus enums. Makes sense since we can only be doing one thing at a time. * Remove global inProgressCompositeTime Only used when sending composite log * Replace 3 global bools with expanded SerialStatus enum * Remove unused global tsCanId * Limit scope of some comms globals. * Remove isMap global - replace witth function * Reduce the serial API to only 2 calls transmit & receive * Tidy up #define visibility * Fix Black* build errors * Workaround Teensy code race condition availableForWrite() is not reliable. * Prevent race condition Was pematurely setting the serialStatusFlag to SERIAL_INACTIVE before final CRC ws read from serial. * Use post write buffer availability checks Remove buffer size check prior to writing. * Write multi-byte values as single bytes. (attempt to fix Teensy 3.5 issue) * Only use Serial.available() as a boolean test (Teensy fix) * writeNonBlocking checks Serial.write() return value * Non-blocking CRC write In sendBufferAndCrcNonBlocking(). * Fix compile warning * Set serial status flag prior to transmitting! * Reliable blocking byte writes. * Fix timeout code: not firing under some conditions * MISRA fixes
2023-02-20 17:55:54 -08:00
void startToothLogger(void);
void stopToothLogger(void);
void startCompositeLogger(void);
void stopCompositeLogger(void);
void startCompositeLoggerTertiary(void);
void stopCompositeLoggerTertiary(void);
void startCompositeLoggerCams(void);
void stopCompositeLoggerCams(void);
#endif