LCOV - code coverage report
Current view: top level - src/MIDI_Parsers - SysExBuffer.cpp (source / functions) Hit Total Coverage
Test: 19d2efc7037c2e176feca44750a12594c76f466f Lines: 24 24 100.0 %
Date: 2019-11-24 14:50:27 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #include "SysExBuffer.hpp"
       2             : 
       3             : BEGIN_CS_NAMESPACE
       4             : 
       5          33 : void SysExBuffer::start() {
       6          33 :     SysExLength = 0; // if the previous message wasn't finished, overwrite it
       7          33 :     receiving = true;
       8          33 :     DEBUG("Start SysEx");
       9          33 : }
      10             : 
      11          33 : void SysExBuffer::end() {
      12          33 :     receiving = false;
      13          33 :     DEBUG("End SysEx");
      14          33 : }
      15             : 
      16         404 : bool SysExBuffer::add(uint8_t data) {
      17         404 :     if (!hasSpaceLeft()) // if the buffer is full
      18           4 :         return false;
      19         400 :     SysExBuffer[SysExLength] = data; // add the data to the buffer
      20         400 :     ++SysExLength;
      21         400 :     return true;
      22         404 : }
      23             : 
      24         404 : bool SysExBuffer::hasSpaceLeft() const {
      25         404 :     bool avail = SysExLength < SYSEX_BUFFER_SIZE;
      26         404 :     if (!avail)
      27           4 :         DEBUG("SysEx buffer full");
      28         404 :     return avail;
      29             : }
      30             : 
      31         348 : bool SysExBuffer::isReceiving() const { return receiving; }
      32             : 
      33          80 : const uint8_t *SysExBuffer::getBuffer() const { return SysExBuffer; }
      34             : 
      35          80 : size_t SysExBuffer::getLength() const { return SysExLength; }
      36             : 
      37             : END_CS_NAMESPACE

Generated by: LCOV version 1.14-5-g4ff2ed6