Brief description of class still missing. More...
#include <UbxBuffer.h>
Public Member Functions | |
| void | startBroadcast () |
| UbxBuffer (int fd, GpsServer *server, UbxDevice *device) | |
| ~UbxBuffer () | |
Protected Member Functions | |
| virtual int | bytesAvailable (char *buffer, int byteCount) |
Brief description of class still missing.
Full description of class still missing
| UbxBuffer::UbxBuffer | ( | int | fd, |
| GpsServer * | server, | ||
| UbxDevice * | device | ||
| ) |
Description of constructor still missing
References TRACE.
: DynamicBuffer(fd) { TRACE; _oldFix=new GpsFix; _newFix=new GpsFix; _server=server; _index=0; _device=device; }
| int UbxBuffer::bytesAvailable | ( | char * | buffer, |
| int | byteCount | ||
| ) | [protected, virtual] |
Returns the number of accepted bytes.
Implements GpCoreTools::DynamicBuffer.
References GpCoreTools::DynamicBuffer::debugBuffer(), GpCoreTools::DynamicBuffer::debugIgnoreByte(), GpCoreTools::MessageClassIdHeader::isValid(), GpCoreTools::MessageClassIdHeader::lengthLittleEndian(), GpCoreTools::MessageClassIdHeader::messageClass, GpCoreTools::MessageClassIdHeader::messageId, GpCoreTools::DynamicBuffer::read(), and TRACE.
{
TRACE;
// If less bytes are available, just wait for more data.
int readBytes=MessageClassIdHeader::SynchronizationSize+
MessageClassIdHeader::HeaderSize+
MessageClassIdHeader::CheckSumSize;
if(byteCount<readBytes) {
return 0;
}
// Expects that the buffer begins with the U-Blox packet tag 0xB5 0x62
// If there are some garbage at the beginning scan for the first
// match of the tag (try to synchronize)
MessageClassIdHeader * hdr=reinterpret_cast<MessageClassIdHeader *>(buffer);
if(!hdr->isValid()) {
return 1;
}
unsigned short length=hdr->lengthLittleEndian();
readBytes+=length;
if(byteCount<readBytes) {
return 0;
}
buffer+=MessageClassIdHeader::SynchronizationSize+MessageClassIdHeader::HeaderSize;
char * payload=buffer;
buffer+=length;
if(hdr->isValid(*reinterpret_cast<const FletcherChecksum *>(buffer), payload, length)) {
read(*hdr, payload, length);
} else {
Log::write(0, "[ERROR] received block class 0x%02hhX id 0x%02hhX with bad checksum\n", hdr->messageClass(), hdr->messageId());
debugBuffer();
// Instead of skipping completely the corrupted block, scan it byte per byte to find 0xB5 0x62
debugIgnoreByte();
return 1;
}
return readBytes;
}
| void UbxBuffer::startBroadcast | ( | ) |
References WaranCore::GpsFix::reset(), and TRACE.