ODCom.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* OpenDoors Online Software Programming Toolkit
  2. * (C) Copyright 1991 - 1999 by Brian Pirie.
  3. *
  4. * Oct-2001 door32.sys/socket modifications by Rob Swindell (www.synchro.net)
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library 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 GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. *
  21. * File: ODCom.h
  22. *
  23. * Description: Public definitions for serial communications module, which
  24. * is implemented in odcom.c
  25. *
  26. * Revisions: Date Ver Who Change
  27. * ---------------------------------------------------------------
  28. * Oct 21, 1994 6.00 BP Created.
  29. * Jan 01, 1995 6.00 BP Added ODComWaitEvent().
  30. * Dec 21, 1995 6.00 BP Add ability to use already open port.
  31. * Jan 09, 1996 6.00 BP Supply actual in/out buffer size used.
  32. * Feb 19, 1996 6.00 BP Changed version number to 6.00.
  33. * Mar 03, 1996 6.10 BP Begin version 6.10.
  34. * Mar 06, 1996 6.10 BP Initial support for Door32 interface.
  35. * Oct 19, 2001 6.20 RS Added TCP/IP socket (telnet) support.
  36. */
  37. #ifndef _INC_ODCOM
  38. #define _INC_ODCOM
  39. /* odtypes.h is needed for definitions of tODHandle, and BOOL. */
  40. #include "ODTypes.h"
  41. /* Serial I/O handle. */
  42. typedef tODHandle tPortHandle;
  43. /* Flow Control setting manifest constants. */
  44. #define FLOW_NONE 0x00
  45. #define FLOW_RTSCTS 0x02
  46. #define FLOW_DEFAULT 0x80
  47. /* Parity bit setting manifest constants. */
  48. #define ODPARITY_NONE 0x00
  49. #define ODPARITY_ODD 0x08
  50. #define ODPARITY_EVEN 0x18
  51. #define ODPARITY_MASK 0x18
  52. /* Stop bit setting manifest constants. */
  53. #define STOP_ONE 0x00
  54. #define STOP_ONE_POINT_FIVE 0x04 /* Only with DATABITS_FIVE. */
  55. #define STOP_TWO 0x04 /* Only if not using DATABITS_FIVE. */
  56. #define STOP_MASK 0x04
  57. /* Character length manifest constants. */
  58. #define DATABITS_FIVE 0x00
  59. #define DATABITS_SIX 0x01
  60. #define DATABITS_SEVEN 0x02
  61. #define DATABITS_EIGHT 0x03
  62. #define DATABITS_MASK 0x03
  63. /* FIFO setting constants. */
  64. #define FIFO_DISABLE 0x00
  65. #define FIFO_ENABLE 0x01
  66. #define FIFO_TRIGGER_1 0x00
  67. #define FIFO_TRIGGER_4 0x40
  68. #define FIFO_TRIGGER_8 0x80
  69. #define FIFO_TRIGGER_14 0xc0
  70. /* Misc. manifest constants. */
  71. #define SPEED_UNSPECIFIED 0
  72. #define SIZE_NON_ZERO -1
  73. /* Serial I/O method settings. */
  74. typedef enum
  75. {
  76. kComMethodUnspecified,
  77. kComMethodFOSSIL,
  78. kComMethodUART,
  79. kComMethodWin32,
  80. kComMethodDoor32,
  81. kComMethodSocket,
  82. kComMethodStdIO
  83. } tComMethod;
  84. /* Serial I/O event types. */
  85. typedef enum
  86. {
  87. kNoCarrier
  88. } tComEvent;
  89. /* Serial I/O function prototypes. */
  90. tODResult ODComAlloc(tPortHandle *phPort);
  91. tODResult ODComFree(tPortHandle hPort);
  92. tODResult ODComSetIdleFunction(tPortHandle hPort,
  93. void (*pfCallback)(void));
  94. tODResult ODComSetFlowControl(tPortHandle hPort, BYTE btFlowControlSetting);
  95. tODResult ODComSetSpeed(tPortHandle hPort, long lSpeed);
  96. tODResult ODComSetPort(tPortHandle hPort, BYTE btPort);
  97. tODResult ODComSetIRQ(tPortHandle hPort, BYTE btIRQLevel);
  98. tODResult ODComSetPortAddress(tPortHandle hPort, int nPortAddress);
  99. tODResult ODComSetWordFormat(tPortHandle hPort, BYTE btWordFormat);
  100. tODResult ODComSetRXBuf(tPortHandle hPort, int nReceiveBufferSize);
  101. tODResult ODComSetTXBuf(tPortHandle hPort, int nTransmitBufferSize);
  102. tODResult ODComSetFIFO(tPortHandle hPort, BYTE btFIFOSetting);
  103. tODResult ODComSetPreferredMethod(tPortHandle hPort, tComMethod Method);
  104. tODResult ODComGetMethod(tPortHandle hPort, tComMethod *pMethod);
  105. tODResult ODComOpen(tPortHandle hPort);
  106. tODResult ODComOpenFromExistingHandle(tPortHandle hPort,
  107. DWORD dwExistingHandle);
  108. tODResult ODComClose(tPortHandle hPort);
  109. tODResult ODComClearInbound(tPortHandle hPort);
  110. tODResult ODComClearOutbound(tPortHandle hPort);
  111. tODResult ODComInbound(tPortHandle hPort, int *pnInboundWaiting);
  112. tODResult ODComOutbound(tPortHandle hPort, int *pnOutboundWaiting);
  113. tODResult ODComCarrier(tPortHandle hPort, BOOL *pbIsCarrier);
  114. tODResult ODComSetDTR(tPortHandle hPort, BOOL bHigh);
  115. tODResult ODComSendByte(tPortHandle hPort, BYTE btToSend);
  116. tODResult ODComGetByte(tPortHandle hPort, char *pbtNext, BOOL bWait);
  117. tODResult ODComSendBuffer(tPortHandle hPort, BYTE *pbtBuffer, int nSize);
  118. tODResult ODComGetBuffer(tPortHandle hPort, BYTE *pbtBuffer, int nSize,
  119. int *pnBytesRead);
  120. tODResult ODComWaitEvent(tPortHandle hPort, tComEvent Event);
  121. #endif /* !_INC_ODCOM */