Files
wideband/firmware/console/binary/tunerstudio_impl.h
Andrey G e5a7952db0 Ts dev (#175)
* Remove pageValueWrite command support

Move advanced pageChunkWrite is used

* Straight logic in validateOffsetCount(), simplify, move to tunerstudio.cpp

* Remove some more unused commands

* More unused defines

* Command defines cleanup

* Test command

* TS: fix signature

* pageIdentifier is optional

* pageActivate command is not used

* TS: extract offset and size from incoming packet only for packets with such data

* TS: cast to packet header

* TS: use page in commands

* TS: support scatteredOchGetCommand

* TS: incapsulation

* TS: scatter: optimization for CPU load

* More CPU load optimization

* Update libfirmware
2023-01-11 00:29:22 -08:00

60 lines
2.1 KiB
C++

/**
* @file tunerstudio_impl.h
*/
#pragma once
#include <cstdint>
#include <cstddef>
#define HIGH_SPEED_COUNT 32
#define HIGH_SPEED_OPTIMIZED
struct TsChannelBase;
typedef enum {
TS_PLAIN = 0,
TS_CRC = 1
} ts_response_format_e;
class TunerStudioBase {
public:
protected:
virtual void cmdOutputChannels(TsChannelBase* tsChannel, uint16_t offset, uint16_t count) = 0;
};
class TunerStudio : public TunerStudioBase {
public:
int handleCrcCommand(TsChannelBase* tsChannel, char *data, size_t incomingPacketSize);
bool handlePlainCommand(TsChannelBase* tsChannel, uint8_t command);
void cmdOutputChannels(TsChannelBase* tsChannel, uint16_t offset, uint16_t count) override;
void handleQueryCommand(TsChannelBase* tsChannel, ts_response_format_e mode);
void handleExecuteCommand(TsChannelBase* tsChannel, char *data, int incomingPacketSize);
void handlePageSelectCommand(TsChannelBase *tsChannel, ts_response_format_e mode);
void handleWriteChunkCommand(TsChannelBase* tsChannel, ts_response_format_e mode, uint16_t offset, uint16_t count,
void *content);
void handleCrc32Check(TsChannelBase *tsChannel, ts_response_format_e mode, uint16_t offset, uint16_t count);
void handleWriteValueCommand(TsChannelBase* tsChannel, ts_response_format_e mode, uint16_t offset, uint8_t value);
void handlePageReadCommand(TsChannelBase* tsChannel, ts_response_format_e mode, uint16_t offset, uint16_t count);
// Scatter mode support
void handleScatteredReadCommand(TsChannelBase* tsChannel);
void handleScatterListWriteCommand(TsChannelBase* tsChannel, uint16_t offset, uint16_t count, void *content);
void handleScatterListReadCommand(TsChannelBase* tsChannel, uint16_t offset, uint16_t count);
void handleScatterListCrc32Check(TsChannelBase *tsChannel, uint16_t offset, uint16_t count);
private:
void sendErrorCode(TsChannelBase* tsChannel, uint8_t code);
bool validateScatterOffsetCount(size_t offset, size_t count);
uint16_t highSpeedOffsets[HIGH_SPEED_COUNT];
#ifdef HIGH_SPEED_OPTIMIZED
uint8_t *highSpeedPtrs[HIGH_SPEED_COUNT];
size_t highSpeedSizes[HIGH_SPEED_COUNT];
size_t highSpeedChunks;
size_t highSpeedTotalSize;
#endif
};