This commit is contained in:
2024-02-20 15:00:00 +03:00
parent e4aa7b47c5
commit 27dd448cb0
4 changed files with 192 additions and 136 deletions

View File

@ -38,7 +38,7 @@ msg type:
                                        // | xxx..... | = тип сообщения
                                        // | ...xxxxx | = длина (максимум 31 бита)
                                        //  ---------- */
#define IR_MSG_ 0U // | 000..... | = Задний сигнал машинки
#define IR_MSG_BACK 0U // | 000..... | = Задний сигнал машинки
;// // | \\\x---- | = нужна ли адресация
;// // | \\\-xxxx | = длина данных (Равна нулю при отсутствии сквозных команд)
#define IR_MSG_ACCEPT 1U // | 001..... | = подтверждение
@ -139,6 +139,14 @@ typedef uint16_t crc_t;
class IR_FOX {
public:
struct PackOffsets {
uint8_t msgOffset;
uint8_t addrFromOffset;
uint8_t addrToOffset;
uint8_t dataOffset;
uint8_t crcOffset;
};
struct ErrorsStruct {
uint8_t lowSignal;
uint8_t highSignal;
@ -153,8 +161,24 @@ public:
};
struct PackOutInfo {
uint8_t* ptr;
uint8_t packSize;
PackOffsets offsets;
uint16_t crc;
ErrorsStruct err;
uint16_t rTime;
};
protected:
ErrorsStruct errors;
void checkaddressRuleApply(uint16_t &address, uint16_t &id, bool &flag) {
flag = false;
flag |= address == id;
flag |= address >= IR_Broadcast;
}
uint8_t crc8(uint8_t* data, uint8_t start, uint8_t end, uint8_t poly) { //TODO: сделать возможность межбайтовой проверки
uint8_t crc = 0xff;
size_t i, j;