Public Member Functions | Protected Member Functions
GpsBuffer Class Reference

Brief description of class still missing. More...

#include <GpsBuffer.h>

Inheritance diagram for GpsBuffer:
GpCoreTools::DynamicBuffer

List of all members.

Public Member Functions

void broadcast (const char *bytes, int bytesCount)
 GpsBuffer (int fileDescriptor, UbxDevice *device, GpsServer *server)
 ~GpsBuffer ()

Protected Member Functions

virtual int bytesAvailable (char *buffer, int bytesCount)

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

GpsBuffer::GpsBuffer ( int  fileDescriptor,
UbxDevice device,
GpsServer server 
)

Description of constructor still missing

References TRACE.

    : DynamicBuffer(fileDescriptor)
{
  TRACE;
  _device=device;
  _server=server;
  _broadcast=false;
}

Description of destructor still missing

References TRACE.

{
  TRACE;
}

Member Function Documentation

void GpsBuffer::broadcast ( const char *  bytes,
int  bytesCount 
)

References GpCoreTools::DynamicBuffer::send(), and TRACE.

{
  TRACE;
  if(_broadcast) {
    char buf[32];
    snprintf(buf, 32, "broadcast=%i\n", bytesCount);
    send(buf, strlen(buf));
    send(bytes, bytesCount);
  }
}
int GpsBuffer::bytesAvailable ( char *  buffer,
int  bytesCount 
) [protected, virtual]

Communication protocol:

'start' Requests acquisition to start 'stop' Requests acquisition to stop 'broadcast=on/off' Starts/stops broadcast 'state' Returns current status 'raw' Requests sending current raw file 'navigation' Requests download of navigation from GPS

Implements GpCoreTools::DynamicBuffer.

References UbxDevice::requestNavigation(), UbxDevice::sendRaw(), UbxDevice::sendState(), UbxDevice::startBroadcast(), UbxDevice::startRecording(), UbxDevice::stopRecording(), and TRACE.

{
  TRACE;
  int bytesRead=0;
  while(bytesRead<bytesCount) {
    // Scan for a line
    int newBytesRead;
    for(newBytesRead=bytesRead; newBytesRead<bytesCount && buffer[newBytesRead]!='\n'; newBytesRead++) {}
    if(newBytesRead==bytesCount) {
      return bytesRead; // partial line
    }
    switch(buffer[bytesRead]) {
    case 'b':
      if(File::match(buffer, bytesRead, bytesCount, "broadcast=on")) {
        _broadcast=true;
        _device->startBroadcast();
      } if(File::match(buffer, bytesRead, bytesCount, "broadcast=off")) {
        _broadcast=false;
      }
      break;
    case 'n':
      if(File::match(buffer, bytesRead, bytesCount, "navigation")) {
        _device->requestNavigation();
      }
      break;
    case 'r':
      if(File::match(buffer, bytesRead, bytesCount, "raw")) {
        _device->sendRaw(this);
      }
      break;
    case 's':
      if(File::match(buffer, bytesRead, bytesCount, "state")) {
        _device->sendState(this);
      } else if(File::match(buffer, bytesRead, bytesCount, "stop")) {
        _device->stopRecording();
      } else if(File::match(buffer, bytesRead, bytesCount, "start")) {
        _device->startRecording();
      }
      break;
    default:
      break;
    }
    bytesRead=newBytesRead+1;
    // Skip blanks and additionnal end of line characters
    while(bytesRead<bytesCount && isspace(buffer[bytesRead])) {bytesRead++;}
  }
  return bytesRead;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines