Processing data in binary (byte) form

This commit is contained in:
Ján Mátik
2020-12-23 12:09:28 +01:00
parent 5bec1cfd3f
commit 2a8261496d
4 changed files with 88 additions and 91 deletions

View File

@@ -13,7 +13,7 @@ class CommObd2Can : public CommInterface {
protected:
const uint8_t pinCanInt = 15;
const uint8_t pinCanCs = 12;
std::unique_ptr <MCP_CAN> CAN;
std::unique_ptr <MCP_CAN> CAN;
long unsigned int rxId;
unsigned char rxLen = 0;
uint8_t rxBuf[32];
@@ -22,22 +22,32 @@ class CommObd2Can : public CommInterface {
char msgString[128]; // Array to store serial string
uint16_t lastPid;
unsigned long lastDataSent = 0;
std::vector<uint8_t> mergedData;
typedef std::vector<uint8_t> frameData_t;
std::unordered_map<uint16_t, frameData_t> dataRows;
std::unordered_map<uint16_t, std::vector<uint8_t>> dataRows;
enum class enFrame_t
{
single = 0,
first = 1,
consecutive = 2,
unknown = 9
};
public:
void connectDevice() override;
void disconnectDevice() override;
void scanDevices() override;
void mainLoop() override;
void executeCommand(String cmd) override;
//
private:
void sendPID(const uint16_t pid, const String& cmd);
void sendFlowControlFrame();
uint8_t receivePID();
enFrame_t getFrameType(const uint8_t firstByte);
bool processFrameBytes();
bool processFrame();
void processMergedResponse();
};