You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
3.9 KiB

5 years ago
  1. /*-------------------------------------------------------------------------
  2. | rxtx is a native interface to serial ports in java.
  3. | Copyright 2002-2004 Michal Hobot MichalHobot@netscape.net
  4. | Copyright 1997-2004 by Trent Jarvi taj@parcelfarce.linux.theplanet.co.uk
  5. |
  6. | This library is free software; you can redistribute it and/or
  7. | modify it under the terms of the GNU Library 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. | Library General Public License for more details.
  15. |
  16. | You should have received a copy of the GNU Library General Public
  17. | License along with this library; if not, write to the Free
  18. | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. --------------------------------------------------------------------------*/
  20. #if !defined(Included_RXTXHELPERS_H)
  21. #define Included_RXTXSERIAL_H
  22. /* javax.comm.SerialPortEvent constants */
  23. #define SPE_DATA_AVAILABLE 1
  24. #define SPE_OUTPUT_BUFFER_EMPTY 2
  25. #define SPE_CTS 3
  26. #define SPE_DSR 4
  27. #define SPE_RI 5
  28. #define SPE_CD 6
  29. #define SPE_OE 7
  30. #define SPE_PE 8
  31. #define SPE_FE 9
  32. #define SPE_BI 10
  33. #define PORT_SERIAL 1
  34. #define PORT_PARALLEL 2
  35. #define PORT_I2C 3
  36. #define PORT_RS485 4
  37. #define PORT_RAW 5
  38. #define CreateErrorMsg(dwError, lpMsgBuf) \
  39. FormatMessage( \
  40. FORMAT_MESSAGE_ALLOCATE_BUFFER | \
  41. FORMAT_MESSAGE_FROM_SYSTEM | \
  42. FORMAT_MESSAGE_IGNORE_INSERTS, \
  43. NULL, \
  44. dwError, \
  45. 0, \
  46. (LPTSTR) & (lpMsgBuf), \
  47. 0, \
  48. NULL \
  49. ), \
  50. ((WCHAR *)lpMsgBuf)[wcslen((WCHAR *)lpMsgBuf)-2] = '\0'
  51. #define ReleaseErrorMsg(lpMsgBuf) LocalFree((LPVOID)(lpMsgBuf))
  52. #if defined(DEBUG)
  53. # define IF_DEBUG(x) {x}
  54. #else
  55. # define IF_DEBUG(x)
  56. #endif
  57. /* java exception class names */
  58. #define UNSUPPORTED_COMM_OPERATION "javax/comm/UnsupportedCommOperationException"
  59. #define ARRAY_INDEX_OUT_OF_BOUNDS "java/lang/ArrayIndexOutOfBoundsException"
  60. #define OUT_OF_MEMORY "java/lang/OutOfMemoryError"
  61. #define IO_EXCEPTION "java/io/IOException"
  62. #define PORT_IN_USE_EXCEPTION "javax/comm/PortInUseException"
  63. typedef struct
  64. {
  65. /* Port handle */
  66. HANDLE fd;
  67. /* flags for events */
  68. DWORD ef;
  69. /* event handle for Monitor interthread signalling*/
  70. HANDLE eventHandle;
  71. /* current serial event */
  72. DWORD event;
  73. /* EventThread sets this flag to TRUE when it's ready */
  74. bool eventThreadReady;
  75. } EventInfoStruct;
  76. long get_java_int_var(JNIEnv *, jobject, char *);
  77. bool get_java_boolean_var(JNIEnv *, jobject, char *);
  78. bool get_java_boolean_var2(JNIEnv *, jobject, jclass, char *);
  79. void throw_java_exception(JNIEnv *, const char *, const char *, const char *);
  80. void throw_java_exceptionW(JNIEnv *, const char *, const wchar_t *, const wchar_t *);
  81. HANDLE get_fd(JNIEnv *, jobject);
  82. EventInfoStruct *get_eis(JNIEnv *, jobject);
  83. int printj(JNIEnv *, wchar_t *, ...);
  84. DWORD __stdcall CommEventThread(LPVOID);
  85. //void setEventFlags(JNIEnv *env, jobject jobj, bool ef[]);
  86. int InitialiseEventInfoStruct(HANDLE, EventInfoStruct **);
  87. int SendEvents(JNIEnv *, jobject, DWORD, EventInfoStruct *, jmethodID);
  88. #endif //Included_RXTXHELPERS_H