bugfix nextAsap, translateAsap, Tx extended frame format (#26)

* bugfix, print not allowed in constructor

* Update tpuart_data_link_layer.cpp

- start confirm timout only after last byte was sent
- increase BYTE_TIMEOUT

* bugfix nextAsap, translateAsap

* bugfix Extended Frame Format TX
This commit is contained in:
Bernator 2019-08-09 17:34:43 +02:00 committed by thelsing
parent 1c53cf83cd
commit 626d1b73d1
3 changed files with 19 additions and 10 deletions

View File

@ -29,7 +29,7 @@ uint16_t AssociationTableObject::entryCount()
return ntohs(_tableData[0]); return ntohs(_tableData[0]);
} }
uint16_t AssociationTableObject::operator[](uint16_t idx) uint16_t AssociationTableObject::getTSAP(uint16_t idx)
{ {
if (idx < 0 || idx >= entryCount()) if (idx < 0 || idx >= entryCount())
return 0; return 0;
@ -37,6 +37,14 @@ uint16_t AssociationTableObject::operator[](uint16_t idx)
return ntohs(_tableData[2 * idx + 1]); return ntohs(_tableData[2 * idx + 1]);
} }
uint16_t AssociationTableObject::getASAP(uint16_t idx)
{
if (idx < 0 || idx >= entryCount())
return 0;
return ntohs(_tableData[2 * idx + 2]);
}
uint8_t* AssociationTableObject::save(uint8_t* buffer) uint8_t* AssociationTableObject::save(uint8_t* buffer)
{ {
return TableObject::save(buffer); return TableObject::save(buffer);
@ -53,10 +61,10 @@ uint8_t* AssociationTableObject::restore(uint8_t* buffer)
int32_t AssociationTableObject::translateAsap(uint16_t asap) int32_t AssociationTableObject::translateAsap(uint16_t asap)
{ {
uint16_t entries = entryCount(); uint16_t entries = entryCount();
for (uint16_t i = 0; i < entries * 2; i+=2) for (uint16_t i = 0; i < entries; i++)
{ {
if (operator[](i + 1) == asap) if (getASAP(i) == asap)
return operator[](i); return getTSAP(i);
} }
return -1; return -1;
} }
@ -97,11 +105,11 @@ int32_t AssociationTableObject::nextAsap(uint16_t tsap, uint16_t& startIdx)
uint16_t entries = entryCount(); uint16_t entries = entryCount();
for (uint16_t i = startIdx; i < entries; i++) for (uint16_t i = startIdx; i < entries; i++)
{ {
startIdx = i; startIdx = i+1;
if (operator[](i) == tsap) if (getTSAP(i) == tsap)
{ {
return operator[](i+1); return getASAP(i);
} }
} }
return -1; return -1;

View File

@ -21,6 +21,7 @@ class AssociationTableObject : public TableObject
private: private:
uint16_t entryCount(); uint16_t entryCount();
uint16_t operator[](uint16_t idx); uint16_t getTSAP(uint16_t idx);
uint16_t getASAP(uint16_t idx);
uint16_t* _tableData = 0; uint16_t* _tableData = 0;
}; };

View File

@ -235,7 +235,7 @@ void TpUartDataLinkLayer::loop()
//Destination Address + payload available //Destination Address + payload available
_xorSum ^= rxByte; _xorSum ^= rxByte;
//check if echo //check if echo
if (!((buffer[0] ^ _sendBuffer[0]) & ~0x20) && !memcmp(buffer + 2, _sendBuffer + 1, 5)) if (!((buffer[0] ^ _sendBuffer[0]) & ~0x20) && !memcmp(buffer + _convert + 1, _sendBuffer + 1, 5))
{ //ignore repeated bit of control byte { //ignore repeated bit of control byte
_isEcho = true; _isEcho = true;
} }