[Si443x] Fixed known binary receive length

pull/427/head
jgromes 2021-11-21 21:16:37 +01:00
rodzic e4eec9c5bd
commit c99e79073f
2 zmienionych plików z 21 dodań i 4 usunięć

Wyświetl plik

@ -285,14 +285,22 @@ int16_t Si443x::readData(uint8_t* data, size_t len) {
clearIRQFlags();
// get packet length
size_t length = len;
if(len == RADIOLIB_SI443X_MAX_PACKET_LENGTH) {
length = getPacketLength();
size_t length = getPacketLength();
size_t dumpLen = 0;
if((len != 0) && (len < length)) {
// user requested less data than we got, only return what was requested
dumpLen = length - len;
length = len;
}
// read packet data
_mod->SPIreadRegisterBurst(RADIOLIB_SI443X_REG_FIFO_ACCESS, length, data);
// dump the bytes that weren't requested
if(dumpLen != 0) {
clearFIFO(dumpLen);
}
// clear internal flag so getPacketLength can return the new packet length
_packetLengthQueried = false;
@ -647,6 +655,13 @@ void Si443x::clearIRQFlags() {
_mod->SPIreadRegisterBurst(RADIOLIB_SI443X_REG_INTERRUPT_STATUS_1, 2, buff);
}
void Si443x::clearFIFO(size_t count) {
while(count) {
_mod->SPIreadRegister(RADIOLIB_SI443X_REG_FIFO_ACCESS);
count--;
}
}
int16_t Si443x::config() {
// set mode to standby
int16_t state = standby();

Wyświetl plik

@ -695,7 +695,8 @@ class Si443x: public PhysicalLayer {
\param data Pointer to array to save the received binary data.
\param len Number of bytes that will be received. Must be known in advance for binary transmissions.
\param len Number of bytes that will be read. When set to 0, the packet length will be retreived automatically.
When more bytes than received are requested, only the number of bytes requested will be returned.
\returns \ref status_codes
*/
@ -838,6 +839,7 @@ class Si443x: public PhysicalLayer {
#endif
bool findChip();
void clearIRQFlags();
void clearFIFO(size_t count);
int16_t config();
int16_t updateClockRecovery();
int16_t directMode();