port.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * FreeModbus Libary: Linux 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: port.h,v 1.1 2006/08/01 20:58:49 wolti Exp $
  20. */
  21. #ifndef PORT_H
  22. #define PORT_H
  23. #include <assert.h>
  24. #define INLINE
  25. #define PR_BEGIN_EXTERN_C extern "C" {
  26. #define PR_END_EXTERN_C }
  27. #ifdef __cplusplus
  28. PR_BEGIN_EXTERN_C
  29. #endif
  30. /* ----------------------- Defines ------------------------------------------*/
  31. #define ENTER_CRITICAL_SECTION(x) vMBPortEnterCritical(x)
  32. #define EXIT_CRITICAL_SECTION(x) vMBPortExitCritical(x)
  33. #define MB_PORT_HAS_CLOSE 1
  34. #ifndef TRUE
  35. #define TRUE 1
  36. #endif
  37. #ifndef FALSE
  38. #define FALSE 0
  39. #endif
  40. /* ----------------------- Type definitions ---------------------------------*/
  41. typedef enum
  42. {
  43. MB_LOG_ERROR = 0,
  44. MB_LOG_WARN = 1,
  45. MB_LOG_INFO = 2,
  46. MB_LOG_DEBUG = 3
  47. } eMBPortLogLevel;
  48. typedef int SOCKET;
  49. #define SOCKET_ERROR (-1)
  50. #define INVALID_SOCKET (~0)
  51. typedef char BOOL;
  52. typedef unsigned char UCHAR;
  53. typedef char CHAR;
  54. typedef unsigned short USHORT;
  55. typedef short SHORT;
  56. typedef unsigned long ULONG;
  57. typedef long LONG;
  58. typedef struct _fmodbus_t fmodbus_t;
  59. /* ----------------------- Function prototypes ------------------------------*/
  60. void vMBPortEnterCritical( fmodbus_t* );
  61. void vMBPortExitCritical( fmodbus_t* );
  62. void vMBPortLog( eMBPortLogLevel eLevel, const CHAR * szModule,
  63. const CHAR * szFmt, ... );
  64. void vMBPortTimerPoll( fmodbus_t* ctx );
  65. BOOL xMBPortSerialPoll( fmodbus_t* ctx );
  66. BOOL xMBPortSerialSetTimeout(fmodbus_t* ctx, ULONG dwTimeoutMs );
  67. #ifdef __cplusplus
  68. PR_END_EXTERN_C
  69. #endif
  70. #endif /* PORT_H */