Source code for /engineering/SERIAL-TEST/FBUFFER.CPPOriginal file FBUFFER.CPP
   1 // --------------------------------------------------------------------------
   2 // --
   3 // -- FBUFFERS - FIFO buffers.
   4 // --
   5 // --
   6 // --------------------------------------------------------------------------
   7 
   8 // --------------------------------------------------------------------------
   9 // -- Includes
  10 // --------------------------------------------------------------------------
  11 #include <stdio.h>
  12 #include <stdlib.h>
  13 #include "defines.h"
  14 #include "fbuffer.h"
  15 
  16 // --------------------------------------------------------------------------
  17 // -- Definitions
  18 // --------------------------------------------------------------------------
  19 
  20 // --------------------------------------------------------------------------
  21 // -- Methods
  22 // --------------------------------------------------------------------------
  23 
  24 // --- Constructor ------------------
  25 FBuffer::FBuffer( unsigned int  size) {
  26 
  27    currentStop = 0;
  28    if (size > FB_MAX_BUFFER_SIZE) size = FB_MAX_BUFFER_SIZE;
  29 
  30    buffer = (unsigned char *) malloc(size);
  31    roverStart   = buffer;
  32    roverEnd     = buffer;
  33    currentStart = 0;
  34    currentStop  = 0;
  35 
  36 };
  37 
  38 // --- Destructor -------------------
  39 FBuffer::~FBuffer() {
  40 
  41    delete(buffer);
  42 
  43 }
  44