buffer_frame.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright 2017-2022 Michael Zillgith
  3. *
  4. * This file is part of lib60870-C
  5. *
  6. * lib60870-C is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * lib60870-C is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with lib60870-C. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. * See COPYING file for the complete license text.
  20. */
  21. #ifndef SRC_IEC60870_T104_BUFFER_FRAME_H_
  22. #define SRC_IEC60870_T104_BUFFER_FRAME_H_
  23. #include "frame.h"
  24. #include <stdbool.h>
  25. struct sBufferFrame {
  26. FrameVFT virtualFunctionTable;
  27. uint8_t* buffer;
  28. int msgSize;
  29. int startSize;
  30. bool isUsed;
  31. };
  32. typedef struct sBufferFrame* BufferFrame;
  33. Frame
  34. BufferFrame_initialize(BufferFrame self, uint8_t* buffer, int startSize);
  35. void
  36. BufferFrame_destroy(Frame super);
  37. void
  38. BufferFrame_resetFrame(Frame super);
  39. void
  40. BufferFrame_setNextByte(Frame super, uint8_t byte);
  41. void
  42. BufferFrame_appendBytes(Frame super, const uint8_t* bytes, int numberOfBytes);
  43. int
  44. BufferFrame_getMsgSize(Frame super);
  45. uint8_t*
  46. BufferFrame_getBuffer(Frame super);
  47. int
  48. BufferFrame_getSpaceLeft(Frame super);
  49. bool
  50. BufferFrame_isUsed(BufferFrame self);
  51. void
  52. BufferFrame_markAsUsed(BufferFrame self);
  53. #endif /* SRC_IEC60870_T104_BUFFER_FRAME_H_ */