~ubuntu-branches/ubuntu/edgy/rxtx/edgy-201105201527

« back to all changes in this revision

Viewing changes to WinCE/gnu_io_RXTXPort.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mario Joussen
  • Date: 2006-03-01 18:56:52 UTC
  • mfrom: (1.1.2 upstream) (2.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20060301185652-ri9941gi01goklvz
Tags: 2.1.7-2
Fixed stupid bug in clean target.
(closes: Bug#354859)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*-------------------------------------------------------------------------
2
2
|   rxtx is a native interface to serial ports in java.
3
 
|   Copyright 2002 Michal Hobot MichalHobot@netscape.net
4
 
|   Copyright 1997-2002 by Trent Jarvi taj@parcelfarce.linux.theplanet.co.uk
 
3
|   Copyright 2002-2004 Michal Hobot MichalHobot@netscape.net
 
4
|   Copyright 1997-2004 by Trent Jarvi taj@parcelfarce.linux.theplanet.co.uk
5
5
|
6
6
|   This library is free software; you can redistribute it and/or
7
7
|   modify it under the terms of the GNU Library General Public
27
27
   perform:     Initialize the native library
28
28
   return:      none
29
29
   exceptions:  none
30
 
   comments:    
 
30
   comments:
31
31
 * Class:     gnu_io_RXTXPort
32
32
 * Method:    Initialize
33
33
 * Signature: ()V
58
58
  EventInfoStruct *EventInfo;
59
59
  DWORD dwErr;
60
60
 
61
 
  LPCWSTR wszName = env->GetStringChars(name, NULL); 
 
61
  LPCWSTR wszName = env->GetStringChars(name, NULL);
62
62
  HANDLE hPort = CreateFileW(wszName,      // Pointer to the name of the port
63
63
                             GENERIC_READ | GENERIC_WRITE,// Access (read-write) mode
64
64
                             0,            // Share mode
67
67
                             0,            // Port attributes
68
68
                             NULL);        // Handle to port with attribute to copy
69
69
  // If it fails to open the port, return FALSE.
70
 
  if ( hPort == INVALID_HANDLE_VALUE ) 
 
70
  if ( hPort == INVALID_HANDLE_VALUE )
71
71
  { // Could not open the port.
72
72
    CreateErrorMsg(GetLastError(), lpMsgBuf);
73
73
    throw_java_exceptionW(env, PORT_IN_USE_EXCEPTION, L"open - CreateFile", lpMsgBuf );
76
76
    env->ReleaseStringChars(name, wszName);
77
77
    return (jint)INVALID_HANDLE_VALUE;
78
78
  }
79
 
  
80
 
 
81
 
  PortDCB.DCBlength = sizeof (DCB);     
 
79
 
 
80
 
 
81
  PortDCB.DCBlength = sizeof (DCB);
82
82
 
83
83
  // Get the default port setting information.
84
84
  GetCommState(hPort, &PortDCB);
85
85
 
86
86
  // Change the DCB structure settings.
87
 
  PortDCB.fBinary = TRUE;               // Binary mode; no EOF check 
88
 
  PortDCB.fParity = TRUE;               // Enable parity checking 
89
 
  PortDCB.fOutxDsrFlow = FALSE;         // No DSR output flow control 
90
 
  PortDCB.fDtrControl = DTR_CONTROL_HANDSHAKE;// DTR flow control type 
91
 
  PortDCB.fDsrSensitivity = FALSE;      // DSR sensitivity 
92
 
  PortDCB.fTXContinueOnXoff = TRUE;     // XOFF continues Tx 
93
 
  PortDCB.fErrorChar = FALSE;           // Disable error replacement 
94
 
  PortDCB.fNull = FALSE;                // Disable null stripping 
 
87
  PortDCB.fBinary = TRUE;               // Binary mode; no EOF check
 
88
  PortDCB.fParity = TRUE;               // Enable parity checking
 
89
  PortDCB.fOutxDsrFlow = FALSE;         // No DSR output flow control
 
90
  PortDCB.fDtrControl = DTR_CONTROL_HANDSHAKE;// DTR flow control type
 
91
  PortDCB.fDsrSensitivity = FALSE;      // DSR sensitivity
 
92
  PortDCB.fTXContinueOnXoff = TRUE;     // XOFF continues Tx
 
93
  PortDCB.fErrorChar = FALSE;           // Disable error replacement
 
94
  PortDCB.fNull = FALSE;                // Disable null stripping
95
95
  PortDCB.fRtsControl = RTS_CONTROL_ENABLE;// RTS flow control
96
96
  PortDCB.fAbortOnError = FALSE;        // Do not abort reads/writes on error
97
97
 
107
107
  }
108
108
 
109
109
  // Retrieve the time-out parameters for all read and write operations
110
 
  // on the port. 
 
110
  // on the port.
111
111
  GetCommTimeouts(hPort, &CommTimeouts);
112
112
 
113
113
  // Change the COMMTIMEOUTS structure settings.
114
 
  CommTimeouts.ReadIntervalTimeout = 0;  
115
 
  CommTimeouts.ReadTotalTimeoutMultiplier = 0;  
116
 
  CommTimeouts.ReadTotalTimeoutConstant = MAXDWORD;    
117
 
  CommTimeouts.WriteTotalTimeoutMultiplier = 10;  
118
 
  CommTimeouts.WriteTotalTimeoutConstant = 1000;    
 
114
  CommTimeouts.ReadIntervalTimeout = 0;
 
115
  CommTimeouts.ReadTotalTimeoutMultiplier = 0;
 
116
  CommTimeouts.ReadTotalTimeoutConstant = MAXDWORD;
 
117
  CommTimeouts.WriteTotalTimeoutMultiplier = 10;
 
118
  CommTimeouts.WriteTotalTimeoutConstant = 1000;
119
119
 
120
120
  // Set the time-out parameters for all read and write operations
121
 
  // on the port. 
 
121
  // on the port.
122
122
  if (!SetCommTimeouts(hPort, &CommTimeouts))
123
123
  { // Unable to set the time-out parameters
124
124
    CreateErrorMsg(GetLastError(), lpMsgBuf);
129
129
    return (jint)INVALID_HANDLE_VALUE;
130
130
  }
131
131
 
132
 
  // SETRTS: Sends the RTS (request-to-send) signal. 
 
132
  // SETRTS: Sends the RTS (request-to-send) signal.
133
133
  EscapeCommFunction(hPort, SETRTS);
134
 
  
 
134
 
135
135
 
136
136
  if(dwErr = InitialiseEventInfoStruct(hPort, &EventInfo))
137
137
  { // Unable to set up EventInfo structure for event processing
156
156
                return (jint)INVALID_HANDLE_VALUE;
157
157
        }
158
158
        env->SetIntField(jobj, jfEis, (jint)EventInfo);
159
 
  
 
159
 
160
160
  env->ReleaseStringChars(name, wszName);
161
161
  // Returning HANDLE (which is a pointer) as file descriptor... Anyway, 32 bits are 32 bits
162
 
  return (jint)hPort;  
 
162
  return (jint)hPort;
163
163
}
164
164
 
165
165
 
175
175
 * Signature: (IIII)V
176
176
 */
177
177
JNIEXPORT void JNICALL Java_gnu_io_RXTXPort_nativeSetSerialPortParams(JNIEnv *env, jobject jobj, jint speed, jint dataBits, jint stopBits, jint parity)
178
 
 
178
{
179
179
  DCB PortDCB;
180
180
  LPCWSTR lpMsgBuf;
181
181
 
198
198
  }
199
199
 
200
200
  // Change the DCB structure settings.
201
 
  PortDCB.BaudRate = speed;             // Current baud 
202
 
  PortDCB.ByteSize = (BYTE)dataBits;    // Number of bits/byte, 4-8 
203
 
  PortDCB.Parity = (BYTE)parity;        // 0-4=no,odd,even,mark,space 
204
 
  switch(stopBits) 
 
201
  PortDCB.BaudRate = speed;             // Current baud
 
202
  PortDCB.ByteSize = (BYTE)dataBits;    // Number of bits/byte, 4-8
 
203
  PortDCB.Parity = (BYTE)parity;        // 0-4=no,odd,even,mark,space
 
204
  switch(stopBits)
205
205
  {
206
206
    case gnu_io_RXTXPort_STOPBITS_1:
207
207
      PortDCB.StopBits = ONESTOPBIT;
217
217
 
218
218
    default:
219
219
      throw_java_exceptionW(env, UNSUPPORTED_COMM_OPERATION, L"nativeSetSerialPortParams", L"Incorrect stopBits");
220
 
      
 
220
 
221
221
  }
222
222
 
223
223
  // Configure the port according to the specifications of the DCB structure.
251
251
 * Signature: (I)V
252
252
 */
253
253
JNIEXPORT void JNICALL Java_gnu_io_RXTXPort_setflowcontrol(JNIEnv *env, jobject jobj, jint flowcontrol)
254
 
 
254
{
255
255
  DCB PortDCB;
256
256
  LPCWSTR lpMsgBuf;
257
257
 
286
286
    PortDCB.fInX = TRUE;
287
287
  else
288
288
    PortDCB.fInX = FALSE;
289
 
  
 
289
 
290
290
  if(flowcontrol & gnu_io_RXTXPort_FLOWCONTROL_XONXOFF_OUT)
291
291
    PortDCB.fOutX = TRUE;
292
292
  else
293
 
    PortDCB.fOutX = FALSE;           
 
293
    PortDCB.fOutX = FALSE;
294
294
 
295
295
  // Configure the port according to the specifications of the DCB structure.
296
296
  if (!SetCommState (hPort, &PortDCB))
325
325
    printj(env, L"--- RXTXPort.NativegetReceiveTimeout() called\n");
326
326
  )
327
327
 
328
 
  // Retrieve the time-out parameters for all read and write operations on the port. 
 
328
  // Retrieve the time-out parameters for all read and write operations on the port.
329
329
  if (!GetCommTimeouts(hPort, &CommTimeouts))
330
330
  { // Unable to get the time-out parameters
331
331
    CreateErrorMsg(GetLastError(), lpMsgBuf);
362
362
  )
363
363
 
364
364
  // Retrieve the time-out parameters for all read and write operations
365
 
  // on the port. 
 
365
  // on the port.
366
366
  if (!GetCommTimeouts(hPort, &CommTimeouts))
367
367
  { // Unable to get the time-out parameters
368
368
    CreateErrorMsg(GetLastError(), lpMsgBuf);
399
399
  )
400
400
 
401
401
  // Retrieve the time-out parameters for all read and write operations
402
 
  // on the port. 
 
402
  // on the port.
403
403
  if (!GetCommTimeouts(hPort, &CommTimeouts))
404
404
  { // Unable to get the time-out parameters
405
405
    CreateErrorMsg(GetLastError(), lpMsgBuf);
412
412
  /* ------ from javax.comm.CommPort javadoc -------------------------------------------------------------
413
413
  |    Threshold   |    Timeout   |Read Buffer Size | Read Behaviour
414
414
  |State   |Value  |State   |Value|                 |
415
 
  |disabled|  -    |disabled| -   |    n bytes      | block until any data is available 
416
 
  |enabled |m bytes|disabled| -   |    n bytes      | block until min(m,n) bytes are available 
417
 
  |disabled|  -    |enabled |x ms |    n bytes      | block for x ms or until any data is available 
418
 
  |enabled |m bytes|enabled |x ms |    n bytes      | block for x ms or until min(m,n) bytes are available 
 
415
  |disabled|  -    |disabled| -   |    n bytes      | block until any data is available
 
416
  |enabled |m bytes|disabled| -   |    n bytes      | block until min(m,n) bytes are available
 
417
  |disabled|  -    |enabled |x ms |    n bytes      | block for x ms or until any data is available
 
418
  |enabled |m bytes|enabled |x ms |    n bytes      | block for x ms or until min(m,n) bytes are available
419
419
  --------------------------------------------------------------------------------------------------------
420
 
  
421
 
  Enabling the Timeout OR Threshold with a value a zero is a special case. 
422
 
  This causes the underlying driver to poll for incoming data instead being event driven. 
 
420
 
 
421
  Enabling the Timeout OR Threshold with a value a zero is a special case.
 
422
  This causes the underlying driver to poll for incoming data instead being event driven.
423
423
  Otherwise, the behaviour is identical to having both the Timeout and Threshold disabled.
424
424
  */
425
425
 
428
428
 
429
429
  if(time == 0)
430
430
  { // polling mode - return if no data
431
 
    CommTimeouts.ReadIntervalTimeout = MAXDWORD;  
432
 
    CommTimeouts.ReadTotalTimeoutMultiplier = MAXDWORD;  
433
 
    CommTimeouts.ReadTotalTimeoutConstant = 1;    
434
 
  } 
 
431
    CommTimeouts.ReadIntervalTimeout = MAXDWORD;
 
432
    CommTimeouts.ReadTotalTimeoutMultiplier = MAXDWORD;
 
433
    CommTimeouts.ReadTotalTimeoutConstant = 1;
 
434
  }
435
435
  else if(time == -1)
436
436
  { // disable timeout
437
 
    CommTimeouts.ReadIntervalTimeout = 0;  
438
 
    CommTimeouts.ReadTotalTimeoutMultiplier = 0;  
439
 
    CommTimeouts.ReadTotalTimeoutConstant = 0;    
 
437
    CommTimeouts.ReadIntervalTimeout = 0;
 
438
    CommTimeouts.ReadTotalTimeoutMultiplier = 0;
 
439
    CommTimeouts.ReadTotalTimeoutConstant = 0;
440
440
  }
441
441
  else
442
442
  { // set timeout
443
 
    CommTimeouts.ReadIntervalTimeout = 0;  
444
 
    CommTimeouts.ReadTotalTimeoutMultiplier = 0;  
445
 
    CommTimeouts.ReadTotalTimeoutConstant = time;    
 
443
    CommTimeouts.ReadIntervalTimeout = 0;
 
444
    CommTimeouts.ReadTotalTimeoutMultiplier = 0;
 
445
    CommTimeouts.ReadTotalTimeoutConstant = time;
446
446
  }
447
447
 
448
448
  // Set the time-out parameters for all read and write operations
449
 
  // on the port. 
 
449
  // on the port.
450
450
  if (!SetCommTimeouts (hPort, &CommTimeouts))
451
451
  { // Unable to set the time-out parameters
452
452
    CreateErrorMsg(GetLastError(), lpMsgBuf);
475
475
  DCB PortDCB;
476
476
  HANDLE hPort = get_fd(env, jobj);
477
477
 
478
 
  PortDCB.DCBlength = sizeof(DCB);     
 
478
  PortDCB.DCBlength = sizeof(DCB);
479
479
 
480
480
  // Get the default port setting information.
481
481
  if(!GetCommState(hPort, &PortDCB))
484
484
    return JNI_FALSE;
485
485
  }
486
486
 
487
 
  // This is not completely correct: I assume that nobody's playing with 
488
 
  // manually setting/resetting DTR. Instead, DTR is in handshake mode (ON unless 
 
487
  // This is not completely correct: I assume that nobody's playing with
 
488
  // manually setting/resetting DTR. Instead, DTR is in handshake mode (ON unless
489
489
  // port closed) or disable mode (OFF).
490
490
  // So, don't use EscapeCommFunction(SETDTR/CLRDTR) in this library!
491
491
  return PortDCB.fDtrControl != DTR_CONTROL_DISABLE ? JNI_TRUE : JNI_FALSE;
505
505
 * Signature: (Z)V
506
506
 */
507
507
JNIEXPORT void JNICALL Java_gnu_io_RXTXPort_setDTR(JNIEnv *env, jobject jobj, jboolean state)
508
 
 
508
{
509
509
  DCB PortDCB;
510
510
 
511
511
  HANDLE hPort = get_fd(env, jobj);
549
549
 * Signature: (Z)V
550
550
 */
551
551
JNIEXPORT void JNICALL Java_gnu_io_RXTXPort_setRTS(JNIEnv *env, jobject jobj, jboolean state)
552
 
 
552
{
553
553
  HANDLE hPort = get_fd(env, jobj);
554
 
  
 
554
 
555
555
  // EscapeCommFunction will fail if there's RTS/CTS flowcontrol. If it is incorrect,
556
556
  // we could turn flowcontrol off when getting to this function
557
557
  if(state == JNI_TRUE)
575
575
 * Signature: (Z)V
576
576
 */
577
577
JNIEXPORT void JNICALL Java_gnu_io_RXTXPort_setDSR(JNIEnv *env, jobject jobj, jboolean state)
578
 
 
578
{
579
579
  DCB PortDCB;
580
580
 
581
581
  HANDLE hPort = get_fd(env, jobj);
594
594
  else
595
595
    PortDCB.fOutxDsrFlow = FALSE;
596
596
 
597
 
  // Configure the port according to the specifications of the DCB 
 
597
  // Configure the port according to the specifications of the DCB
598
598
  // structure.
599
599
  if (!SetCommState (hPort, &PortDCB))
600
600
  { //Unable to configure the serial port
623
623
 
624
624
  if(!GetCommModemStatus(hPort, &ModemStat))
625
625
    return JNI_FALSE;
626
 
  
 
626
 
627
627
  return ModemStat|MS_CTS_ON ? JNI_TRUE : JNI_FALSE;
628
628
}
629
629
 
647
647
 
648
648
  if(!GetCommModemStatus(hPort, &ModemStat))
649
649
    return JNI_FALSE;
650
 
  
 
650
 
651
651
  return ModemStat|MS_DSR_ON ? JNI_TRUE : JNI_FALSE;
652
652
}
653
653
 
674
674
 
675
675
  if(!GetCommModemStatus(hPort, &ModemStat))
676
676
    return JNI_FALSE;
677
 
  
 
677
 
678
678
  return ModemStat|MS_RLSD_ON ? JNI_TRUE : JNI_FALSE;
679
679
}
680
680
 
698
698
 
699
699
  if(!GetCommModemStatus(hPort, &ModemStat))
700
700
    return JNI_FALSE;
701
 
  
 
701
 
702
702
  return ModemStat|MS_RING_ON ? JNI_TRUE : JNI_FALSE;
703
703
}
704
704
 
739
739
    printj(env, L"Undefined condition: isRTS() but control is RTS_CONTROL_HANDSHAKE. Returning FALSE\n");
740
740
    return JNI_FALSE;
741
741
  }
742
 
  
 
742
 
743
743
  return JNI_FALSE;
744
744
}
745
745
 
755
755
 * Signature: (I)V
756
756
 */
757
757
JNIEXPORT void JNICALL Java_gnu_io_RXTXPort_sendBreak(JNIEnv *env, jobject jobj, jint duration)
758
 
 
758
{
759
759
  HANDLE hPort = get_fd(env, jobj);
760
 
  
 
760
 
761
761
  SetCommBreak(hPort);
762
762
  Sleep(duration);
763
763
  ClearCommBreak(hPort);
772
772
   exceptions:  IOException
773
773
 * Class:     gnu_io_RXTXPort
774
774
 * Method:    writeByte
775
 
 * Signature: (I)V
 
775
 * Signature: (IZ)V
776
776
 */
777
 
JNIEXPORT void JNICALL Java_gnu_io_RXTXPort_writeByte(JNIEnv *env, jobject jobj, jint b)
778
 
 
777
JNIEXPORT void JNICALL Java_gnu_io_RXTXPort_writeByte(JNIEnv *env, jobject jobj, jint b, jboolean i)
 
778
{
779
779
  DWORD dwNumBytesWritten;
780
780
  LPCWSTR lpMsgBuf;
781
781
  HANDLE hPort = get_fd(env, jobj);
783
783
 
784
784
  do {
785
785
    if (!WriteFile(hPort,              // Port handle
786
 
                   &bb,                // Pointer to the data to write 
 
786
                   &bb,                // Pointer to the data to write
787
787
                   1,                  // Number of bytes to write
788
788
                   &dwNumBytesWritten, // Pointer to the number of bytes written
789
789
                   NULL))              // Must be NULL for Windows CE
811
811
 * Signature: ([BIIZ)V
812
812
 */
813
813
JNIEXPORT void JNICALL Java_gnu_io_RXTXPort_writeArray(JNIEnv *env, jobject jobj, jbyteArray b, jint off, jint len, jboolean i)
814
 
 
814
{
815
815
  LPCWSTR lpMsgBuf;
816
816
        DWORD dwNumBytesWritten;
817
817
  jint total=0;
825
825
      printj(env, L"--- writeArray - %d bytes to write\n", len-total);
826
826
    )
827
827
    if (!WriteFile(hPort,              // Port handle
828
 
                   body+total+off,     // Pointer to the data to write 
 
828
                   body+total+off,     // Pointer to the data to write
829
829
                   len-total,          // Number of bytes to write
830
830
                   &dwNumBytesWritten, // Pointer to the number of bytes written
831
831
                   NULL))              // Must be NULL for Windows CE
839
839
    }
840
840
    total += dwNumBytesWritten;
841
841
        } while( total < len );
842
 
        
 
842
 
843
843
  env->ReleaseByteArrayElements(b, body, JNI_ABORT);
844
844
}
845
845
 
859
859
 * Method:    nativeDrain
860
860
 * Signature: ()V
861
861
 */
862
 
JNIEXPORT jboolean JNICALL Java_gnu_io_RXTXPort_nativeDrain(JNIEnv *env, jobject jobj)
863
 
 
862
JNIEXPORT jboolean JNICALL Java_gnu_io_RXTXPort_nativeDrain(JNIEnv *env, jobject jobj, jboolean i)
 
863
{
864
864
  //COMSTAT Stat;
865
865
  //DWORD dwErrors;
866
866
  HANDLE hPort = get_fd(env, jobj);
869
869
  (
870
870
    printj(env, L"--- RXTXPort.nativeDrain() called\n");
871
871
  )
872
 
  
 
872
  /*
873
873
  if(!FlushFileBuffers(hPort))
874
874
  {
875
875
    IF_DEBUG
878
878
    )
879
879
    return JNI_FALSE;
880
880
  }
881
 
   
882
 
  /* Alternative implementation:
 
881
   */
 
882
  // Alternative implementation:
 
883
  /*
883
884
  do
884
885
  {
885
886
    if(!ClearCommError(hPort, &dwErrors, &Stat))
991
992
    throw_java_exceptionW(env, ARRAY_INDEX_OUT_OF_BOUNDS, L"readArray", L"Negative number of character to read");
992
993
    return -1;
993
994
  }
994
 
  
 
995
 
995
996
  jbyte *body = env->GetByteArrayElements(b, NULL);
996
997
  threshold = get_java_int_var(env, jobj, "threshold");
997
998
 
1009
1010
 
1010
1011
    dwTotalRead += dwNumBytesRead;
1011
1012
  } while(dwNumBytesRead > 0 && threshold != 0 && dwTotalRead <= (DWORD)len && dwTotalRead < (DWORD)threshold);
1012
 
        
 
1013
 
1013
1014
  env->ReleaseByteArrayElements(b, body, 0);
1014
1015
  return dwTotalRead;
1015
1016
}
1027
1028
 * Signature: ()V
1028
1029
 */
1029
1030
JNIEXPORT void JNICALL Java_gnu_io_RXTXPort_eventLoop(JNIEnv *env, jobject jobj)
1030
 
 
1031
{
1031
1032
  jfieldID jfMonitorThreadCloseLock, jfMonitorThreadLock, jfMonThreadisInterrupted;
1032
1033
  jmethodID jmSendEvent;
1033
1034
  HANDLE hCommEventThread;
1040
1041
  (
1041
1042
    printj(env, L"--- RXTXPort.eventLoop() start\n");
1042
1043
  )
1043
 
  
 
1044
 
1044
1045
  jclass cls = env->GetObjectClass(jobj);
1045
1046
 
1046
1047
  // Get pointers to some Java variables and methods:
1078
1079
      (
1079
1080
        printj(env, L"--- RXTXPort.eventLoop() interrupted - exiting\n");
1080
1081
      )
1081
 
      
 
1082
 
1082
1083
      CloseHandle(EventInfo->eventHandle);
1083
 
      
 
1084
 
1084
1085
            env->SetBooleanField(jobj, jfMonitorThreadCloseLock, JNI_FALSE);
1085
1086
      return;
1086
1087
    }
1105
1106
        ReleaseErrorMsg(lpMsgBuf);
1106
1107
      )
1107
1108
      CloseHandle(EventInfo->eventHandle);
 
1109
          env->SetBooleanField(jobj, jfMonitorThreadCloseLock, JNI_FALSE);
1108
1110
      return;
1109
1111
    }
1110
1112
 
1121
1123
          printj(env, L"!!! eventLoop - SendEvents() result: %d\n", RetVal);
1122
1124
        )
1123
1125
        CloseHandle(EventInfo->eventHandle);
 
1126
            env->SetBooleanField(jobj, jfMonitorThreadCloseLock, JNI_FALSE);
1124
1127
        return;
1125
1128
      }
1126
1129
    }
1149
1152
 * Signature: ()V
1150
1153
 */
1151
1154
JNIEXPORT void JNICALL Java_gnu_io_RXTXPort_interruptEventLoop(JNIEnv *env, jobject jobj)
1152
 
 
1155
{
1153
1156
  jfieldID jfid;
1154
1157
  HANDLE hPort = get_fd(env, jobj);
1155
1158
 
1172
1175
 * Signature: (IIZ)V
1173
1176
 */
1174
1177
JNIEXPORT void JNICALL Java_gnu_io_RXTXPort_nativeSetEventFlag(JNIEnv *env, jobject jobj, jint fd, jint event, jboolean flag)
1175
 
 
1178
{
1176
1179
  DWORD dwErr, NewFlag;
1177
1180
  EventInfoStruct *EventInfo = get_eis(env, jobj);
1178
1181
  HANDLE hPort = (HANDLE)fd;
1219
1222
    break;
1220
1223
 
1221
1224
  }
1222
 
  
 
1225
 
1223
1226
  if(flag == JNI_TRUE)
1224
1227
    EventInfo->ef = EventInfo->ef | NewFlag;
1225
1228
  else
1237
1240
    )
1238
1241
    return;
1239
1242
  }
1240
 
   
 
1243
 
1241
1244
}
1242
1245
 
1243
1246
/*
1252
1255
 * Signature: (Ljava/lang/String{ })V
1253
1256
 */
1254
1257
JNIEXPORT void JNICALL Java_gnu_io_RXTXPort_nativeClose(JNIEnv *env, jobject jobj, jstring name)
1255
 
 
1258
{
1256
1259
  HANDLE hPort = get_fd(env, jobj);
1257
1260
 
1258
1261
  IF_DEBUG
1259
1262
  (
1260
 
    LPCWSTR wszName = env->GetStringChars(name, NULL); 
 
1263
    LPCWSTR wszName = env->GetStringChars(name, NULL);
1261
1264
    printj(env, L"--- RXTXPort.nativeClose(%s) called\n", wszName);
1262
1265
    env->ReleaseStringChars(name, wszName);
1263
1266
  )
1391
1394
   perform:     check the EndOf InputChar
1392
1395
   return:      the EndOfInputChar as an jbyte.  -1 on error
1393
1396
   exceptions:  UnsupportedCommOperationException if not implemented
1394
 
   comments:    
 
1397
   comments:
1395
1398
 * Class:     gnu_io_RXTXPort
1396
1399
 * Method:    nativeGetEndOfInputChar
1397
1400
 * Signature: ()I