portevent.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * FreeModbus Libary: BARE Port
  3. * Copyright (C) 2006 Christian Walter <wolti@sil.at>
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. *
  19. * File: $Id$
  20. */
  21. /* ----------------------- Modbus includes ----------------------------------*/
  22. #include "mb.h"
  23. #include "mbport.h"
  24. /* ----------------------- Variables ----------------------------------------*/
  25. static eMBEventType eQueuedEvent;
  26. static BOOL xEventInQueue;
  27. /* ----------------------- Start implementation -----------------------------*/
  28. BOOL
  29. xMBPortEventInit( void )
  30. {
  31. xEventInQueue = FALSE;
  32. return TRUE;
  33. }
  34. BOOL
  35. xMBPortEventPost( eMBEventType eEvent )
  36. {
  37. xEventInQueue = TRUE;
  38. eQueuedEvent = eEvent;
  39. return TRUE;
  40. }
  41. BOOL
  42. xMBPortEventGet( eMBEventType * eEvent )
  43. {
  44. BOOL xEventHappened = FALSE;
  45. if( xEventInQueue )
  46. {
  47. *eEvent = eQueuedEvent;
  48. xEventInQueue = FALSE;
  49. xEventHappened = TRUE;
  50. }
  51. return xEventHappened;
  52. }