HEAD and TAIL missing in PXX2 frames
This commit is contained in:
@@ -24,7 +24,6 @@
|
|||||||
void Pxx2Pulses::setupFrame(uint8_t port)
|
void Pxx2Pulses::setupFrame(uint8_t port)
|
||||||
{
|
{
|
||||||
initFrame();
|
initFrame();
|
||||||
initCrc();
|
|
||||||
|
|
||||||
static uint8_t pass[NUM_MODULES] = { MODULES_INIT(0) };
|
static uint8_t pass[NUM_MODULES] = { MODULES_INIT(0) };
|
||||||
uint8_t sendUpperChannels = 0;
|
uint8_t sendUpperChannels = 0;
|
||||||
@@ -55,6 +54,5 @@ void Pxx2Pulses::setupFrame(uint8_t port)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CRC
|
endFrame();
|
||||||
addByte(crc); // TODO need to check the CRC chosen algorithm
|
|
||||||
}
|
}
|
||||||
|
|||||||
+41
-2
@@ -41,11 +41,16 @@ class SportCrcMixin {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Pxx2Transport: public DataBuffer<uint8_t, 64>, public SportCrcMixin {
|
class Pxx2Transport: public DataBuffer<uint8_t, 64>, public PxxCrcMixin {
|
||||||
protected:
|
protected:
|
||||||
void addByte(uint8_t byte)
|
void addByte(uint8_t byte)
|
||||||
{
|
{
|
||||||
SportCrcMixin::addToCrc(byte);
|
PxxCrcMixin::addToCrc(byte);
|
||||||
|
addByteWithoutCrc(byte);
|
||||||
|
};
|
||||||
|
|
||||||
|
void addByteWithoutCrc(uint8_t byte)
|
||||||
|
{
|
||||||
*ptr++ = byte;
|
*ptr++ = byte;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,9 +68,43 @@ class Pxx2Pulses: public PxxPulses<Pxx2Transport> {
|
|||||||
uint8_t data[64];
|
uint8_t data[64];
|
||||||
uint8_t * ptr;
|
uint8_t * ptr;
|
||||||
|
|
||||||
|
void addHead()
|
||||||
|
{
|
||||||
|
// send 7E, do not CRC
|
||||||
|
Pxx2Transport::addByteWithoutCrc(0x7E);
|
||||||
|
|
||||||
|
// reserve 1 byte for LEN
|
||||||
|
Pxx2Transport::addByteWithoutCrc(0x00);
|
||||||
|
|
||||||
|
// TYPE_C + TYPE_ID
|
||||||
|
Pxx2Transport::addByte(0x26); // This one is CRC-ed on purpose
|
||||||
|
}
|
||||||
|
|
||||||
|
void addCrc()
|
||||||
|
{
|
||||||
|
Pxx2Transport::addByteWithoutCrc(PxxCrcMixin::crc >> 8);
|
||||||
|
Pxx2Transport::addByteWithoutCrc(PxxCrcMixin::crc);
|
||||||
|
}
|
||||||
|
|
||||||
void initFrame()
|
void initFrame()
|
||||||
{
|
{
|
||||||
|
// init the CRC counter
|
||||||
|
initCrc();
|
||||||
|
|
||||||
|
// reset the frame pointer
|
||||||
Pxx2Transport::initBuffer();
|
Pxx2Transport::initBuffer();
|
||||||
|
|
||||||
|
// add the frame head
|
||||||
|
addHead();
|
||||||
|
}
|
||||||
|
|
||||||
|
void endFrame()
|
||||||
|
{
|
||||||
|
// update the frame LEN = frame length minus the 2 first bytes
|
||||||
|
data[1] = getSize() - 2;
|
||||||
|
|
||||||
|
// now add the CRC
|
||||||
|
addCrc();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user