| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
package gnu.io; |
| 59 |
import java.io.InputStream; |
| 60 |
import java.io.OutputStream; |
| 61 |
import java.io.IOException; |
| 62 |
import java.util.TooManyListenersException; |
| 63 |
import java.lang.Math; |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
final public class RXTXPort extends SerialPort |
| 71 |
{ |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
protected final static boolean debug = false; |
| 77 |
protected final static boolean debug_read = false; |
| 78 |
protected final static boolean debug_read_results = false; |
| 79 |
protected final static boolean debug_write = false; |
| 80 |
protected final static boolean debug_events = false; |
| 81 |
protected final static boolean debug_verbose = false; |
| 82 |
|
| 83 |
private static Zystem z; |
| 84 |
|
| 85 |
static |
| 86 |
{ |
| 87 |
try { |
| 88 |
z = new Zystem( Zystem.PRINT_MODE ); |
| 89 |
} catch ( Exception e ) {}; |
| 90 |
|
| 91 |
if(debug ) |
| 92 |
z.reportln( "RXTXPort {}"); |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
Initialize(); |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
private native static void Initialize(); |
| 101 |
boolean MonitorThreadAlive=false; |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
public RXTXPort( String name ) throws PortInUseException |
| 110 |
{ |
| 111 |
if (debug) |
| 112 |
z.reportln( "RXTXPort:RXTXPort("+name+") called"); |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
fd = open( name ); |
| 126 |
this.name = name; |
| 127 |
|
| 128 |
MonitorThreadLock = true; |
| 129 |
monThread = new MonitorThread(); |
| 130 |
monThread.start(); |
| 131 |
waitForTheNativeCodeSilly(); |
| 132 |
MonitorThreadAlive=true; |
| 133 |
|
| 134 |
timeout = -1; |
| 135 |
if (debug) |
| 136 |
z.reportln( "RXTXPort:RXTXPort("+name+") returns with fd = " + |
| 137 |
fd); |
| 138 |
} |
| 139 |
private native synchronized int open( String name ) |
| 140 |
throws PortInUseException; |
| 141 |
|
| 142 |
|
| 143 |
protected int fd = 0; |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
int eis = 0; |
| 149 |
|
| 150 |
int pid = 0; |
| 151 |
|
| 152 |
|
| 153 |
static boolean dsrFlag = false; |
| 154 |
|
| 155 |
|
| 156 |
private final SerialOutputStream out = new SerialOutputStream(); |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
public OutputStream getOutputStream() |
| 162 |
{ |
| 163 |
if (debug) |
| 164 |
z.reportln( "RXTXPort:getOutputStream() called and returning"); |
| 165 |
return out; |
| 166 |
} |
| 167 |
|
| 168 |
|
| 169 |
private final SerialInputStream in = new SerialInputStream(); |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
public InputStream getInputStream() |
| 176 |
{ |
| 177 |
if (debug) |
| 178 |
z.reportln( "RXTXPort:getInputStream() called and returning"); |
| 179 |
return in; |
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
private native int nativeGetParity( int fd ); |
| 196 |
private native int nativeGetFlowControlMode( int fd ); |
| 197 |
public synchronized void setSerialPortParams( int b, int d, int s, |
| 198 |
int p ) |
| 199 |
throws UnsupportedCommOperationException |
| 200 |
{ |
| 201 |
if (debug) |
| 202 |
z.reportln( "RXTXPort:setSerialPortParams(" + |
| 203 |
b + " " + d + " " + s + " " + p + ") called"); |
| 204 |
if ( nativeSetSerialPortParams( b, d, s, p ) ) |
| 205 |
throw new UnsupportedCommOperationException( |
| 206 |
"Invalid Parameter" ); |
| 207 |
speed = b; |
| 208 |
if( s== STOPBITS_1_5 ) dataBits = DATABITS_5; |
| 209 |
else dataBits = d; |
| 210 |
stopBits = s; |
| 211 |
parity = p; |
| 212 |
if (debug) |
| 213 |
z.reportln( "RXTXPort:setSerialPortParams(" + |
| 214 |
b + " " + d + " " + s + " " + p + |
| 215 |
") returning"); |
| 216 |
} |
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
private native boolean nativeSetSerialPortParams( int speed, |
| 224 |
int dataBits, int stopBits, int parity ) |
| 225 |
throws UnsupportedCommOperationException; |
| 226 |
|
| 227 |
|
| 228 |
protected int speed=9600; |
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
public int getBaudRate() |
| 234 |
{ |
| 235 |
if (debug) |
| 236 |
z.reportln( "RXTXPort:getBaudRate() called and returning " + speed); |
| 237 |
return speed; |
| 238 |
} |
| 239 |
|
| 240 |
|
| 241 |
protected int dataBits=DATABITS_8; |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
public int getDataBits() |
| 246 |
{ |
| 247 |
if (debug) |
| 248 |
z.reportln( "RXTXPort:getDataBits() called and returning " + dataBits); |
| 249 |
return dataBits; |
| 250 |
} |
| 251 |
|
| 252 |
|
| 253 |
protected int stopBits=SerialPort.STOPBITS_1; |
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
public int getStopBits() |
| 258 |
{ |
| 259 |
if (debug) |
| 260 |
z.reportln( "RXTXPort:getStopBits() called and returning " + stopBits); |
| 261 |
return stopBits; |
| 262 |
} |
| 263 |
|
| 264 |
|
| 265 |
protected int parity= SerialPort.PARITY_NONE; |
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
public int getParity() |
| 270 |
{ |
| 271 |
if (debug) |
| 272 |
z.reportln( "RXTXPort:getParity() called and returning " + parity ); |
| 273 |
return parity; |
| 274 |
} |
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
protected int flowmode = SerialPort.FLOWCONTROL_NONE; |
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
public void setFlowControlMode( int flowcontrol ) |
| 284 |
{ |
| 285 |
if (debug) |
| 286 |
z.reportln( "RXTXPort:setFlowControlMode( " + flowcontrol + " ) called"); |
| 287 |
if(monThreadisInterrupted) |
| 288 |
{ |
| 289 |
if( debug_events ) |
| 290 |
z.reportln( "RXTXPort:setFlowControlMode MonThread is Interrupeted returning" ); |
| 291 |
return; |
| 292 |
} |
| 293 |
try { |
| 294 |
setflowcontrol( flowcontrol ); |
| 295 |
} |
| 296 |
catch( IOException e ) |
| 297 |
{ |
| 298 |
e.printStackTrace(); |
| 299 |
return; |
| 300 |
} |
| 301 |
flowmode=flowcontrol; |
| 302 |
if (debug) |
| 303 |
z.reportln( "RXTXPort:setFlowControlMode( " + flowcontrol + " ) returning"); |
| 304 |
} |
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
public int getFlowControlMode() |
| 309 |
{ |
| 310 |
if (debug) |
| 311 |
z.reportln( "RXTXPort:getFlowControlMode() returning " + flowmode ); |
| 312 |
return flowmode; |
| 313 |
} |
| 314 |
native void setflowcontrol( int flowcontrol ) throws IOException; |
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
public void enableReceiveFraming( int f ) |
| 327 |
throws UnsupportedCommOperationException |
| 328 |
{ |
| 329 |
if (debug) |
| 330 |
z.reportln( "RXTXPort:enableReceiveFramming() throwing exception"); |
| 331 |
throw new UnsupportedCommOperationException( "Not supported" ); |
| 332 |
} |
| 333 |
|
| 334 |
|
| 335 |
public void disableReceiveFraming() |
| 336 |
{ |
| 337 |
if (debug) |
| 338 |
z.reportln( "RXTXPort:disableReceiveFramming() called and returning (noop)"); |
| 339 |
} |
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
public boolean isReceiveFramingEnabled() |
| 344 |
{ |
| 345 |
if (debug) |
| 346 |
z.reportln( "RXTXPort:isReceiveFrammingEnabled() called and returning " + false ); |
| 347 |
return false; |
| 348 |
} |
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
public int getReceiveFramingByte() |
| 353 |
{ |
| 354 |
if (debug) |
| 355 |
z.reportln( "RXTXPort:getReceiveFrammingByte() called and returning " + 0 ); |
| 356 |
return 0; |
| 357 |
} |
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
protected int timeout; |
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
public native int NativegetReceiveTimeout(); |
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
private native boolean NativeisReceiveTimeoutEnabled(); |
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
private native void NativeEnableReceiveTimeoutThreshold(int time, |
| 377 |
int threshold,int InputBuffer); |
| 378 |
|
| 379 |
|
| 380 |
public void disableReceiveTimeout() |
| 381 |
{ |
| 382 |
if (debug) |
| 383 |
z.reportln( "RXTXPort:disableReceiveTimeout() called"); |
| 384 |
timeout = -1; |
| 385 |
NativeEnableReceiveTimeoutThreshold( timeout , threshold, InputBuffer ); |
| 386 |
if (debug) |
| 387 |
z.reportln( "RXTXPort:disableReceiveTimeout() returning"); |
| 388 |
} |
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
public void enableReceiveTimeout( int time ) |
| 393 |
{ |
| 394 |
if (debug) |
| 395 |
z.reportln( "RXTXPort:enableReceiveTimeout() called"); |
| 396 |
if( time >= 0 ) |
| 397 |
{ |
| 398 |
timeout = time; |
| 399 |
NativeEnableReceiveTimeoutThreshold( time , threshold, |
| 400 |
InputBuffer ); |
| 401 |
} |
| 402 |
else |
| 403 |
{ |
| 404 |
throw new IllegalArgumentException |
| 405 |
( |
| 406 |
"Unexpected negative timeout value" |
| 407 |
); |
| 408 |
} |
| 409 |
if (debug) |
| 410 |
z.reportln( "RXTXPort:enableReceiveTimeout() returning"); |
| 411 |
} |
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
public boolean isReceiveTimeoutEnabled() |
| 416 |
{ |
| 417 |
if (debug) |
| 418 |
z.reportln( "RXTXPort:isReceiveTimeoutEnabled() called and returning " + NativeisReceiveTimeoutEnabled() ); |
| 419 |
return( NativeisReceiveTimeoutEnabled() ); |
| 420 |
} |
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
public int getReceiveTimeout() |
| 425 |
{ |
| 426 |
if (debug) |
| 427 |
z.reportln( "RXTXPort:getReceiveTimeout() called and returning " + NativegetReceiveTimeout() ); |
| 428 |
return(NativegetReceiveTimeout( )); |
| 429 |
} |
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
private int threshold = 0; |
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
public void enableReceiveThreshold( int thresh ) |
| 439 |
{ |
| 440 |
if (debug) |
| 441 |
z.reportln( "RXTXPort:enableReceiveThreshold( " + thresh + " ) called"); |
| 442 |
if(thresh >=0) |
| 443 |
{ |
| 444 |
threshold=thresh; |
| 445 |
NativeEnableReceiveTimeoutThreshold(timeout, threshold, |
| 446 |
InputBuffer); |
| 447 |
} |
| 448 |
else |
| 449 |
{ |
| 450 |
throw new IllegalArgumentException |
| 451 |
( |
| 452 |
"Unexpected negative threshold value" |
| 453 |
); |
| 454 |
} |
| 455 |
if (debug) |
| 456 |
z.reportln( "RXTXPort:enableReceiveThreshold( " + thresh + " ) returned"); |
| 457 |
} |
| 458 |
|
| 459 |
|
| 460 |
public void disableReceiveThreshold() |
| 461 |
{ |
| 462 |
if (debug) |
| 463 |
z.reportln( "RXTXPort:disableReceiveThreshold() called and returning"); |
| 464 |
enableReceiveThreshold(0); |
| 465 |
} |
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
public int getReceiveThreshold() |
| 470 |
{ |
| 471 |
if (debug) |
| 472 |
z.reportln( "RXTXPort:getReceiveThreshold() called and returning " + threshold); |
| 473 |
return threshold; |
| 474 |
} |
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
public boolean isReceiveThresholdEnabled() |
| 479 |
{ |
| 480 |
if (debug) |
| 481 |
z.reportln( "RXTXPort:isReceiveThresholdEnable() called and returning" + (threshold > 0) ); |
| 482 |
return(threshold>0); |
| 483 |
} |
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
private int InputBuffer=0; |
| 493 |
private int OutputBuffer=0; |
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
public void setInputBufferSize( int size ) |
| 498 |
{ |
| 499 |
if (debug) |
| 500 |
z.reportln( "RXTXPort:setInputBufferSize( " + |
| 501 |
size + ") called"); |
| 502 |
if( size < 0 ) |
| 503 |
throw new IllegalArgumentException |
| 504 |
( |
| 505 |
"Unexpected negative buffer size value" |
| 506 |
); |
| 507 |
else InputBuffer=size; |
| 508 |
if (debug) |
| 509 |
z.reportln( "RXTXPort:setInputBufferSize( " + |
| 510 |
size + ") returning"); |
| 511 |
} |
| 512 |
|
| 513 |
|
| 514 |
public int getInputBufferSize() |
| 515 |
{ |
| 516 |
if (debug) |
| 517 |
z.reportln( "RXTXPort:getInputBufferSize() called and returning " + InputBuffer ); |
| 518 |
return(InputBuffer); |
| 519 |
} |
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
public void setOutputBufferSize( int size ) |
| 524 |
{ |
| 525 |
if (debug) |
| 526 |
z.reportln( "RXTXPort:setOutputBufferSize( " + |
| 527 |
size + ") called"); |
| 528 |
if( size < 0 ) |
| 529 |
throw new IllegalArgumentException |
| 530 |
( |
| 531 |
"Unexpected negative buffer size value" |
| 532 |
); |
| 533 |
else OutputBuffer=size; |
| 534 |
if (debug) |
| 535 |
z.reportln( "RXTXPort:setOutputBufferSize( " + |
| 536 |
size + ") returned"); |
| 537 |
|
| 538 |
} |
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
public int getOutputBufferSize() |
| 543 |
{ |
| 544 |
if (debug) |
| 545 |
z.reportln( "RXTXPort:getOutputBufferSize() called and returning " + OutputBuffer ); |
| 546 |
return(OutputBuffer); |
| 547 |
} |
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
public native boolean isDTR(); |
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
public native void setDTR( boolean state ); |
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
public native void setRTS( boolean state ); |
| 566 |
private native void setDSR( boolean state ); |
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
public native boolean isCTS(); |
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
public native boolean isDSR(); |
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
public native boolean isCD(); |
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
public native boolean isRI(); |
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
public native boolean isRTS(); |
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
public native void sendBreak( int duration ); |
| 594 |
protected native void writeByte( int b, boolean i ) throws IOException; |
| 595 |
protected native void writeArray( byte b[], int off, int len, boolean i ) |
| 596 |
throws IOException; |
| 597 |
protected native boolean nativeDrain( boolean i ) throws IOException; |
| 598 |
|
| 599 |
|
| 600 |
protected native int nativeavailable() throws IOException; |
| 601 |
protected native int readByte() throws IOException; |
| 602 |
protected native int readArray( byte b[], int off, int len ) |
| 603 |
throws IOException; |
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
private SerialPortEventListener SPEventListener; |
| 608 |
|
| 609 |
|
| 610 |
private MonitorThread monThread; |
| 611 |
|
| 612 |
|
| 613 |
native void eventLoop(); |
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
boolean monThreadisInterrupted=true; |
| 619 |
private native void interruptEventLoop( ); |
| 620 |
public boolean checkMonitorThread() |
| 621 |
{ |
| 622 |
if (debug) |
| 623 |
z.reportln( "RXTXPort:checkMonitorThread()"); |
| 624 |
if(monThread != null) |
| 625 |
{ |
| 626 |
if ( debug ) |
| 627 |
z.reportln( |
| 628 |
"monThreadisInterrupted = " + |
| 629 |
monThreadisInterrupted ); |
| 630 |
return monThreadisInterrupted; |
| 631 |
} |
| 632 |
if ( debug ) |
| 633 |
z.reportln( "monThread is null " ); |
| 634 |
return(true); |
| 635 |
} |
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
public boolean sendEvent( int event, boolean state ) |
| 643 |
{ |
| 644 |
if (debug_events) |
| 645 |
z.report( "RXTXPort:sendEvent("); |
| 646 |
|
| 647 |
|
| 648 |
if ( fd == 0 || SPEventListener == null || monThread == null) |
| 649 |
{ |
| 650 |
return(true); |
| 651 |
} |
| 652 |
|
| 653 |
switch( event ) |
| 654 |
{ |
| 655 |
case SerialPortEvent.DATA_AVAILABLE: |
| 656 |
if( debug_events ) |
| 657 |
z.reportln( "DATA_AVAILABLE " + |
| 658 |
monThread.Data + ")" ); |
| 659 |
break; |
| 660 |
case SerialPortEvent.OUTPUT_BUFFER_EMPTY: |
| 661 |
if( debug_events ) |
| 662 |
z.reportln( |
| 663 |
"OUTPUT_BUFFER_EMPTY " + |
| 664 |
monThread.Output + ")" ); |
| 665 |
break; |
| 666 |
case SerialPortEvent.CTS: |
| 667 |
if( debug_events ) |
| 668 |
z.reportln( "CTS " + |
| 669 |
monThread.CTS + ")" ); |
| 670 |
break; |
| 671 |
case SerialPortEvent.DSR: |
| 672 |
if( debug_events ) |
| 673 |
z.reportln( "DSR " + |
| 674 |
monThread.Output + ")" ); |
| 675 |
break; |
| 676 |
case SerialPortEvent.RI: |
| 677 |
if( debug_events ) |
| 678 |
z.reportln( "RI " + |
| 679 |
monThread.RI + ")" ); |
| 680 |
break; |
| 681 |
case SerialPortEvent.CD: |
| 682 |
if( debug_events ) |
| 683 |
z.reportln( "CD " + |
| 684 |
monThread.CD + ")" ); |
| 685 |
break; |
| 686 |
case SerialPortEvent.OE: |
| 687 |
if( debug_events ) |
| 688 |
z.reportln( "OE " + |
| 689 |
monThread.OE + ")" ); |
| 690 |
break; |
| 691 |
case SerialPortEvent.PE: |
| 692 |
if( debug_events ) |
| 693 |
z.reportln( "PE " + |
| 694 |
monThread.PE + ")" ); |
| 695 |
break; |
| 696 |
case SerialPortEvent.FE: |
| 697 |
if( debug_events ) |
| 698 |
z.reportln( "FE " + |
| 699 |
monThread.FE + ")" ); |
| 700 |
break; |
| 701 |
case SerialPortEvent.BI: |
| 702 |
if( debug_events ) |
| 703 |
z.reportln( "BI " + |
| 704 |
monThread.BI + ")" ); |
| 705 |
break; |
| 706 |
default: |
| 707 |
if( debug_events ) |
| 708 |
z.reportln( "XXXXXXXXXXXXXX " + |
| 709 |
event + ")" ); |
| 710 |
break; |
| 711 |
} |
| 712 |
if( debug_events && debug_verbose ) |
| 713 |
z.reportln( " checking flags " ); |
| 714 |
|
| 715 |
switch( event ) |
| 716 |
{ |
| 717 |
case SerialPortEvent.DATA_AVAILABLE: |
| 718 |
if( monThread.Data ) break; |
| 719 |
return(false); |
| 720 |
case SerialPortEvent.OUTPUT_BUFFER_EMPTY: |
| 721 |
if( monThread.Output ) break; |
| 722 |
return(false); |
| 723 |
case SerialPortEvent.CTS: |
| 724 |
if( monThread.CTS ) break; |
| 725 |
return(false); |
| 726 |
case SerialPortEvent.DSR: |
| 727 |
if( monThread.DSR ) break; |
| 728 |
return(false); |
| 729 |
case SerialPortEvent.RI: |
| 730 |
if( monThread.RI ) break; |
| 731 |
return(false); |
| 732 |
case SerialPortEvent.CD: |
| 733 |
if( monThread.CD ) break; |
| 734 |
return(false); |
| 735 |
case SerialPortEvent.OE: |
| 736 |
if( monThread.OE ) break; |
| 737 |
return(false); |
| 738 |
case SerialPortEvent.PE: |
| 739 |
if( monThread.PE ) break; |
| 740 |
return(false); |
| 741 |
case SerialPortEvent.FE: |
| 742 |
if( monThread.FE ) break; |
| 743 |
return(false); |
| 744 |
case SerialPortEvent.BI: |
| 745 |
if( monThread.BI ) break; |
| 746 |
return(false); |
| 747 |
default: |
| 748 |
System.err.println( "unknown event: " + event); |
| 749 |
return(false); |
| 750 |
} |
| 751 |
if( debug_events && debug_verbose ) |
| 752 |
z.reportln( " getting event" ); |
| 753 |
SerialPortEvent e = new SerialPortEvent(this, event, !state, |
| 754 |
state ); |
| 755 |
if( debug_events && debug_verbose ) |
| 756 |
z.reportln( " sending event" ); |
| 757 |
if(monThreadisInterrupted) |
| 758 |
{ |
| 759 |
if( debug_events ) |
| 760 |
z.reportln( " sendEvent return" ); |
| 761 |
return(true); |
| 762 |
} |
| 763 |
if( SPEventListener != null ) |
| 764 |
{ |
| 765 |
SPEventListener.serialEvent( e ); |
| 766 |
} |
| 767 |
|
| 768 |
if( debug_events && debug_verbose ) |
| 769 |
z.reportln( " sendEvent return" ); |
| 770 |
|
| 771 |
if (fd == 0 || SPEventListener == null || monThread == null) |
| 772 |
{ |
| 773 |
return(true); |
| 774 |
} |
| 775 |
else |
| 776 |
{ |
| 777 |
return(false); |
| 778 |
} |
| 779 |
} |
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
boolean MonitorThreadLock = true; |
| 788 |
boolean MonitorThreadCloseLock = true; |
| 789 |
|
| 790 |
public void addEventListener( |
| 791 |
SerialPortEventListener lsnr ) throws TooManyListenersException |
| 792 |
{ |
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
if (debug) |
| 798 |
z.reportln( "RXTXPort:addEventListener()"); |
| 799 |
if( SPEventListener != null ) |
| 800 |
{ |
| 801 |
throw new TooManyListenersException(); |
| 802 |
} |
| 803 |
SPEventListener = lsnr; |
| 804 |
if( !MonitorThreadAlive ) |
| 805 |
{ |
| 806 |
MonitorThreadLock = true; |
| 807 |
monThread = new MonitorThread(); |
| 808 |
monThread.start(); |
| 809 |
waitForTheNativeCodeSilly(); |
| 810 |
MonitorThreadAlive=true; |
| 811 |
} |
| 812 |
if (debug) |
| 813 |
z.reportln( "RXTXPort:Interrupt=false"); |
| 814 |
} |
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
public void removeEventListener() |
| 819 |
{ |
| 820 |
if (debug) |
| 821 |
z.reportln( "RXTXPort:removeEventListener() called"); |
| 822 |
waitForTheNativeCodeSilly(); |
| 823 |
|
| 824 |
if( monThreadisInterrupted == true ) |
| 825 |
{ |
| 826 |
z.reportln( " RXTXPort:removeEventListener() already interrupted"); |
| 827 |
monThread = null; |
| 828 |
SPEventListener = null; |
| 829 |
Runtime.getRuntime().gc(); |
| 830 |
return; |
| 831 |
} |
| 832 |
else if( monThread != null && monThread.isAlive() ) |
| 833 |
{ |
| 834 |
if (debug) |
| 835 |
z.reportln( " RXTXPort:Interrupt=true"); |
| 836 |
monThreadisInterrupted=true; |
| 837 |
|
| 838 |
|
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
MonitorThreadCloseLock = true; |
| 843 |
if (debug) |
| 844 |
z.reportln( " RXTXPort:calling interruptEventLoop"); |
| 845 |
interruptEventLoop( ); |
| 846 |
if (debug) |
| 847 |
z.reportln(" RXTXPort:waiting on closelock"); |
| 848 |
while( MonitorThreadCloseLock ) |
| 849 |
{ |
| 850 |
if (debug) |
| 851 |
z.reportln(" ."); |
| 852 |
try { |
| 853 |
Thread.sleep(100); |
| 854 |
} catch( Exception e ) {} |
| 855 |
} |
| 856 |
if (debug) |
| 857 |
z.reportln(" RXTXPort:set closelock"); |
| 858 |
if (debug) |
| 859 |
z.reportln( " RXTXPort:calling monThread.join()"); |
| 860 |
try { |
| 861 |
monThread.join(1000); |
| 862 |
} catch (Exception ex) { |
| 863 |
|
| 864 |
ex.printStackTrace(); |
| 865 |
} |
| 866 |
if (debug) |
| 867 |
z.reportln( " RXTXPort:waiting on isAlive()"); |
| 868 |
while( monThread.isAlive() ) |
| 869 |
{ |
| 870 |
if ( debug ) |
| 871 |
z.reportln( " MonThread is still alive!"); |
| 872 |
try { |
| 873 |
monThread.join(1000); |
| 874 |
Thread.sleep( 1000 ); |
| 875 |
} catch( Exception e ){} |
| 876 |
|
| 877 |
} |
| 878 |
|
| 879 |
} |
| 880 |
if (debug) |
| 881 |
z.reportln( " RXTXPort:calling gc()"); |
| 882 |
monThread = null; |
| 883 |
SPEventListener = null; |
| 884 |
Runtime.getRuntime().gc(); |
| 885 |
MonitorThreadLock = false; |
| 886 |
MonitorThreadAlive=false; |
| 887 |
if (debug) |
| 888 |
z.reportln( "RXTXPort:removeEventListener() returning"); |
| 889 |
} |
| 890 |
|
| 891 |
|
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
|
| 896 |
|
| 897 |
|
| 898 |
|
| 899 |
protected void waitForTheNativeCodeSilly() |
| 900 |
{ |
| 901 |
while( MonitorThreadLock ) |
| 902 |
{ |
| 903 |
try { |
| 904 |
Thread.sleep(100); |
| 905 |
} catch( Exception e ) {} |
| 906 |
} |
| 907 |
} |
| 908 |
|
| 909 |
|
| 910 |
|
| 911 |
private native void nativeSetEventFlag( int fd, int event, |
| 912 |
boolean flag ); |
| 913 |
public void notifyOnDataAvailable( boolean enable ) |
| 914 |
{ |
| 915 |
if (debug) |
| 916 |
z.reportln( "RXTXPort:notifyOnDataAvailable( " + |
| 917 |
enable+" )"); |
| 918 |
|
| 919 |
waitForTheNativeCodeSilly(); |
| 920 |
|
| 921 |
MonitorThreadLock = true; |
| 922 |
nativeSetEventFlag( fd, SerialPortEvent.DATA_AVAILABLE, |
| 923 |
enable ); |
| 924 |
monThread.Data = enable; |
| 925 |
MonitorThreadLock = false; |
| 926 |
} |
| 927 |
|
| 928 |
|
| 929 |
|
| 930 |
|
| 931 |
public void notifyOnOutputEmpty( boolean enable ) |
| 932 |
{ |
| 933 |
if (debug) |
| 934 |
z.reportln( "RXTXPort:notifyOnOutputEmpty( " + |
| 935 |
enable+" )"); |
| 936 |
waitForTheNativeCodeSilly(); |
| 937 |
MonitorThreadLock = true; |
| 938 |
nativeSetEventFlag( fd, SerialPortEvent.OUTPUT_BUFFER_EMPTY, |
| 939 |
enable ); |
| 940 |
monThread.Output = enable; |
| 941 |
MonitorThreadLock = false; |
| 942 |
} |
| 943 |
|
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
public void notifyOnCTS( boolean enable ) |
| 948 |
{ |
| 949 |
if (debug) |
| 950 |
z.reportln( "RXTXPort:notifyOnCTS( " + |
| 951 |
enable+" )"); |
| 952 |
waitForTheNativeCodeSilly(); |
| 953 |
MonitorThreadLock = true; |
| 954 |
nativeSetEventFlag( fd, SerialPortEvent.CTS, enable ); |
| 955 |
monThread.CTS = enable; |
| 956 |
MonitorThreadLock = false; |
| 957 |
} |
| 958 |
|
| 959 |
|
| 960 |
|
| 961 |
public void notifyOnDSR( boolean enable ) |
| 962 |
{ |
| 963 |
if (debug) |
| 964 |
z.reportln( "RXTXPort:notifyOnDSR( " + |
| 965 |
enable+" )"); |
| 966 |
waitForTheNativeCodeSilly(); |
| 967 |
MonitorThreadLock = true; |
| 968 |
nativeSetEventFlag( fd, SerialPortEvent.DSR, enable ); |
| 969 |
monThread.DSR = enable; |
| 970 |
MonitorThreadLock = false; |
| 971 |
} |
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
public void notifyOnRingIndicator( boolean enable ) |
| 976 |
{ |
| 977 |
if (debug) |
| 978 |
z.reportln( "RXTXPort:notifyOnRingIndicator( " + |
| 979 |
enable+" )"); |
| 980 |
waitForTheNativeCodeSilly(); |
| 981 |
MonitorThreadLock = true; |
| 982 |
nativeSetEventFlag( fd, SerialPortEvent.RI, enable ); |
| 983 |
monThread.RI = enable; |
| 984 |
MonitorThreadLock = false; |
| 985 |
} |
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
public void notifyOnCarrierDetect( boolean enable ) |
| 990 |
{ |
| 991 |
if (debug) |
| 992 |
z.reportln( "RXTXPort:notifyOnCarrierDetect( " + |
| 993 |
enable+" )"); |
| 994 |
waitForTheNativeCodeSilly(); |
| 995 |
MonitorThreadLock = true; |
| 996 |
nativeSetEventFlag( fd, SerialPortEvent.CD, enable ); |
| 997 |
monThread.CD = enable; |
| 998 |
MonitorThreadLock = false; |
| 999 |
} |
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
public void notifyOnOverrunError( boolean enable ) |
| 1004 |
{ |
| 1005 |
if (debug) |
| 1006 |
z.reportln( "RXTXPort:notifyOnOverrunError( " + |
| 1007 |
enable+" )"); |
| 1008 |
waitForTheNativeCodeSilly(); |
| 1009 |
MonitorThreadLock = true; |
| 1010 |
nativeSetEventFlag( fd, SerialPortEvent.OE, enable ); |
| 1011 |
monThread.OE = enable; |
| 1012 |
MonitorThreadLock = false; |
| 1013 |
} |
| 1014 |
|
| 1015 |
|
| 1016 |
|
| 1017 |
public void notifyOnParityError( boolean enable ) |
| 1018 |
{ |
| 1019 |
if (debug) |
| 1020 |
z.reportln( "RXTXPort:notifyOnParityError( " + |
| 1021 |
enable+" )"); |
| 1022 |
waitForTheNativeCodeSilly(); |
| 1023 |
MonitorThreadLock = true; |
| 1024 |
nativeSetEventFlag( fd, SerialPortEvent.PE, enable ); |
| 1025 |
monThread.PE = enable; |
| 1026 |
MonitorThreadLock = false; |
| 1027 |
} |
| 1028 |
|
| 1029 |
|
| 1030 |
|
| 1031 |
public void notifyOnFramingError( boolean enable ) |
| 1032 |
{ |
| 1033 |
if (debug) |
| 1034 |
z.reportln( "RXTXPort:notifyOnFramingError( " + |
| 1035 |
enable+" )"); |
| 1036 |
waitForTheNativeCodeSilly(); |
| 1037 |
MonitorThreadLock = true; |
| 1038 |
nativeSetEventFlag( fd, SerialPortEvent.FE, enable ); |
| 1039 |
monThread.FE = enable; |
| 1040 |
MonitorThreadLock = false; |
| 1041 |
} |
| 1042 |
|
| 1043 |
|
| 1044 |
|
| 1045 |
public void notifyOnBreakInterrupt( boolean enable ) |
| 1046 |
{ |
| 1047 |
if (debug) |
| 1048 |
z.reportln( "RXTXPort:notifyOnBreakInterrupt( " + |
| 1049 |
enable+" )"); |
| 1050 |
waitForTheNativeCodeSilly(); |
| 1051 |
MonitorThreadLock = true; |
| 1052 |
nativeSetEventFlag( fd, SerialPortEvent.BI, enable ); |
| 1053 |
monThread.BI = enable; |
| 1054 |
MonitorThreadLock = false; |
| 1055 |
} |
| 1056 |
|
| 1057 |
|
| 1058 |
private native void nativeClose( String name ); |
| 1059 |
|
| 1060 |
|
| 1061 |
boolean closeLock = false; |
| 1062 |
public synchronized void close() |
| 1063 |
{ |
| 1064 |
if (debug) |
| 1065 |
z.reportln( "RXTXPort:close( " + this.name + " )"); |
| 1066 |
if( closeLock ) return; |
| 1067 |
closeLock = true; |
| 1068 |
if ( fd <= 0 ) |
| 1069 |
{ |
| 1070 |
z.reportln( "RXTXPort:close detected bad File Descriptor" ); |
| 1071 |
return; |
| 1072 |
} |
| 1073 |
setDTR(false); |
| 1074 |
setDSR(false); |
| 1075 |
if (debug) |
| 1076 |
z.reportln( "RXTXPort:close( " + this.name + " ) setting monThreadisInterrupted"); |
| 1077 |
if ( ! monThreadisInterrupted ) |
| 1078 |
{ |
| 1079 |
removeEventListener(); |
| 1080 |
} |
| 1081 |
if (debug) |
| 1082 |
z.reportln( "RXTXPort:close( " + this.name + " ) calling nativeClose"); |
| 1083 |
nativeClose( this.name ); |
| 1084 |
if (debug) |
| 1085 |
z.reportln( "RXTXPort:close( " + this.name + " ) calling super.close"); |
| 1086 |
super.close(); |
| 1087 |
if (debug) |
| 1088 |
z.reportln( "RXTXPort:close( " + this.name + " ) calling System.gc"); |
| 1089 |
|
| 1090 |
fd = 0; |
| 1091 |
Runtime.getRuntime().gc(); |
| 1092 |
closeLock = false; |
| 1093 |
if (debug) |
| 1094 |
z.reportln( "RXTXPort:close( " + this.name + " ) leaving"); |
| 1095 |
} |
| 1096 |
|
| 1097 |
|
| 1098 |
|
| 1099 |
protected void finalize() |
| 1100 |
{ |
| 1101 |
if (debug) |
| 1102 |
z.reportln( "RXTXPort:finalize()"); |
| 1103 |
if( fd > 0 ) close(); |
| 1104 |
z.finalize(); |
| 1105 |
} |
| 1106 |
|
| 1107 |
|
| 1108 |
class SerialOutputStream extends OutputStream |
| 1109 |
{ |
| 1110 |
|
| 1111 |
|
| 1112 |
|
| 1113 |
|
| 1114 |
public void write( int b ) throws IOException |
| 1115 |
{ |
| 1116 |
if (debug_write) |
| 1117 |
z.reportln( "RXTXPort:SerialOutputStream:write(int)"); |
| 1118 |
if( speed == 0 ) return; |
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
|
| 1123 |
|
| 1124 |
|
| 1125 |
waitForTheNativeCodeSilly(); |
| 1126 |
if ( fd == 0 ) throw new IOException(); |
| 1127 |
writeByte( b, monThreadisInterrupted ); |
| 1128 |
if (debug_write) |
| 1129 |
z.reportln( "Leaving RXTXPort:SerialOutputStream:write( int )"); |
| 1130 |
} |
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
|
| 1135 |
public void write( byte b[] ) throws IOException |
| 1136 |
{ |
| 1137 |
if (debug_write) |
| 1138 |
{ |
| 1139 |
z.reportln( "Entering RXTXPort:SerialOutputStream:write(" + b.length + ") " ); |
| 1140 |
} |
| 1141 |
if( speed == 0 ) return; |
| 1142 |
|
| 1143 |
|
| 1144 |
|
| 1145 |
|
| 1146 |
|
| 1147 |
|
| 1148 |
if ( fd == 0 ) throw new IOException(); |
| 1149 |
waitForTheNativeCodeSilly(); |
| 1150 |
writeArray( b, 0, b.length, monThreadisInterrupted ); |
| 1151 |
if (debug_write) |
| 1152 |
z.reportln( "Leaving RXTXPort:SerialOutputStream:write(" +b.length +")"); |
| 1153 |
} |
| 1154 |
|
| 1155 |
|
| 1156 |
|
| 1157 |
|
| 1158 |
|
| 1159 |
|
| 1160 |
public void write( byte b[], int off, int len ) |
| 1161 |
throws IOException |
| 1162 |
{ |
| 1163 |
if( speed == 0 ) return; |
| 1164 |
if( off + len > b.length ) |
| 1165 |
{ |
| 1166 |
throw new IndexOutOfBoundsException( |
| 1167 |
"Invalid offset/length passed to read" |
| 1168 |
); |
| 1169 |
} |
| 1170 |
|
| 1171 |
byte send[] = new byte[len]; |
| 1172 |
System.arraycopy( b, off, send, 0, len ); |
| 1173 |
if (debug_write) |
| 1174 |
{ |
| 1175 |
z.reportln( "Entering RXTXPort:SerialOutputStream:write(" + send.length + " " + off + " " + len + " " +") " ); |
| 1176 |
} |
| 1177 |
if ( fd == 0 ) throw new IOException(); |
| 1178 |
|
| 1179 |
|
| 1180 |
|
| 1181 |
|
| 1182 |
|
| 1183 |
|
| 1184 |
waitForTheNativeCodeSilly(); |
| 1185 |
writeArray( send, 0, len, monThreadisInterrupted ); |
| 1186 |
if( debug_write ) |
| 1187 |
z.reportln( "Leaving RXTXPort:SerialOutputStream:write(" + send.length + " " + off + " " + len + " " +") " ); |
| 1188 |
} |
| 1189 |
|
| 1190 |
|
| 1191 |
public void flush() throws IOException |
| 1192 |
{ |
| 1193 |
if (debug) |
| 1194 |
z.reportln( "RXTXPort:SerialOutputStream:flush() enter"); |
| 1195 |
if( speed == 0 ) return; |
| 1196 |
if ( fd == 0 ) throw new IOException(); |
| 1197 |
|
| 1198 |
|
| 1199 |
|
| 1200 |
|
| 1201 |
|
| 1202 |
|
| 1203 |
|
| 1204 |
|
| 1205 |
waitForTheNativeCodeSilly(); |
| 1206 |
|
| 1207 |
|
| 1208 |
|
| 1209 |
|
| 1210 |
if ( nativeDrain( monThreadisInterrupted ) ) |
| 1211 |
sendEvent( SerialPortEvent.OUTPUT_BUFFER_EMPTY, true ); |
| 1212 |
if (debug) |
| 1213 |
z.reportln( "RXTXPort:SerialOutputStream:flush() leave"); |
| 1214 |
} |
| 1215 |
} |
| 1216 |
|
| 1217 |
|
| 1218 |
class SerialInputStream extends InputStream |
| 1219 |
{ |
| 1220 |
|
| 1221 |
|
| 1222 |
|
| 1223 |
|
| 1224 |
|
| 1225 |
|
| 1226 |
|
| 1227 |
|
| 1228 |
|
| 1229 |
|
| 1230 |
|
| 1231 |
|
| 1232 |
|
| 1233 |
|
| 1234 |
|
| 1235 |
public synchronized int read() throws IOException |
| 1236 |
{ |
| 1237 |
if (debug_read) |
| 1238 |
z.reportln( "RXTXPort:SerialInputStream:read() called"); |
| 1239 |
if ( fd == 0 ) throw new IOException(); |
| 1240 |
waitForTheNativeCodeSilly(); |
| 1241 |
if ( monThreadisInterrupted ) |
| 1242 |
z.reportln( "+++++++++ read() monThreadisInterrupted" ); |
| 1243 |
int result = readByte(); |
| 1244 |
if (debug_read_results) |
| 1245 |
z.reportln( "RXTXPort:SerialInputStrea:read() returns byte = " + result ); |
| 1246 |
return( result ); |
| 1247 |
} |
| 1248 |
|
| 1249 |
|
| 1250 |
|
| 1251 |
|
| 1252 |
|
| 1253 |
|
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
|
| 1259 |
|
| 1260 |
|
| 1261 |
public synchronized int read( byte b[] ) throws IOException |
| 1262 |
{ |
| 1263 |
int result; |
| 1264 |
if (debug_read) |
| 1265 |
z.reportln( "RXTXPort:SerialInputStream:read(" + b.length + ") called"); |
| 1266 |
|
| 1267 |
|
| 1268 |
|
| 1269 |
|
| 1270 |
|
| 1271 |
|
| 1272 |
waitForTheNativeCodeSilly(); |
| 1273 |
result = read( b, 0, b.length); |
| 1274 |
if (debug_read_results) |
| 1275 |
z.reportln( "RXTXPort:SerialInputStream:read() returned " + result + " bytes" ); |
| 1276 |
return( result ); |
| 1277 |
} |
| 1278 |
|
| 1279 |
|
| 1280 |
|
| 1281 |
|
| 1282 |
|
| 1283 |
|
| 1284 |
|
| 1285 |
|
| 1286 |
|
| 1287 |
|
| 1288 |
|
| 1289 |
|
| 1290 |
|
| 1291 |
|
| 1292 |
|
| 1293 |
|
| 1294 |
|
| 1295 |
|
| 1296 |
|
| 1297 |
|
| 1298 |
public synchronized int read( byte b[], int off, int len ) |
| 1299 |
throws IOException |
| 1300 |
{ |
| 1301 |
if (debug_read) |
| 1302 |
z.reportln( "RXTXPort:SerialInputStream:read(" + b.length + " " + off + " " + len + ") called" ); |
| 1303 |
int result; |
| 1304 |
|
| 1305 |
|
| 1306 |
|
| 1307 |
if ( fd == 0 ) |
| 1308 |
{ |
| 1309 |
z.reportln("+++++++ IOException()\n"); |
| 1310 |
throw new IOException(); |
| 1311 |
} |
| 1312 |
|
| 1313 |
if( b==null ) |
| 1314 |
{ |
| 1315 |
z.reportln("+++++++ NullPointerException()\n"); |
| 1316 |
throw new NullPointerException(); |
| 1317 |
} |
| 1318 |
|
| 1319 |
if( (off < 0) || (len < 0) || (off+len > b.length)) |
| 1320 |
{ |
| 1321 |
z.reportln("+++++++ IndexOutOfBoundsException()\n"); |
| 1322 |
throw new IndexOutOfBoundsException(); |
| 1323 |
} |
| 1324 |
|
| 1325 |
|
| 1326 |
|
| 1327 |
|
| 1328 |
if( len==0 ) return 0; |
| 1329 |
|
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
int Minimum = len; |
| 1334 |
|
| 1335 |
if( threshold==0 ) |
| 1336 |
{ |
| 1337 |
|
| 1338 |
|
| 1339 |
|
| 1340 |
|
| 1341 |
|
| 1342 |
|
| 1343 |
|
| 1344 |
int a = nativeavailable(); |
| 1345 |
if( a == 0 ) |
| 1346 |
Minimum = 1; |
| 1347 |
else |
| 1348 |
Minimum = Math.min( Minimum, a ); |
| 1349 |
} |
| 1350 |
else |
| 1351 |
{ |
| 1352 |
|
| 1353 |
|
| 1354 |
|
| 1355 |
|
| 1356 |
|
| 1357 |
Minimum = Math.min(Minimum, threshold); |
| 1358 |
} |
| 1359 |
|
| 1360 |
|
| 1361 |
|
| 1362 |
|
| 1363 |
|
| 1364 |
|
| 1365 |
waitForTheNativeCodeSilly(); |
| 1366 |
result = readArray( b, off, Minimum); |
| 1367 |
if (debug_read_results) |
| 1368 |
z.reportln( "RXTXPort:SerialInputStream:read(" + b.length + " " + off + " " + len + ") returned " + result + " bytes" ); |
| 1369 |
return( result ); |
| 1370 |
} |
| 1371 |
|
| 1372 |
|
| 1373 |
|
| 1374 |
|
| 1375 |
public synchronized int available() throws IOException |
| 1376 |
{ |
| 1377 |
|
| 1378 |
|
| 1379 |
|
| 1380 |
|
| 1381 |
|
| 1382 |
|
| 1383 |
if ( debug_verbose ) |
| 1384 |
z.reportln( "RXTXPort:available() called" ); |
| 1385 |
int r = nativeavailable(); |
| 1386 |
if ( debug_verbose ) |
| 1387 |
z.reportln( "RXTXPort:available() returning " + |
| 1388 |
r ); |
| 1389 |
return r; |
| 1390 |
} |
| 1391 |
} |
| 1392 |
|
| 1393 |
|
| 1394 |
class MonitorThread extends Thread |
| 1395 |
{ |
| 1396 |
|
| 1397 |
|
| 1398 |
|
| 1399 |
private volatile boolean CTS=false; |
| 1400 |
private volatile boolean DSR=false; |
| 1401 |
private volatile boolean RI=false; |
| 1402 |
private volatile boolean CD=false; |
| 1403 |
private volatile boolean OE=false; |
| 1404 |
private volatile boolean PE=false; |
| 1405 |
private volatile boolean FE=false; |
| 1406 |
private volatile boolean BI=false; |
| 1407 |
private volatile boolean Data=false; |
| 1408 |
private volatile boolean Output=false; |
| 1409 |
|
| 1410 |
MonitorThread() |
| 1411 |
{ |
| 1412 |
if (debug) |
| 1413 |
z.reportln( "RXTXPort:MontitorThread:MonitorThread()"); |
| 1414 |
} |
| 1415 |
|
| 1416 |
|
| 1417 |
|
| 1418 |
public void run() |
| 1419 |
{ |
| 1420 |
if (debug) |
| 1421 |
z.reportln( "RXTXPort:MontitorThread:run()"); |
| 1422 |
monThreadisInterrupted=false; |
| 1423 |
eventLoop(); |
| 1424 |
|
| 1425 |
if (debug) |
| 1426 |
z.reportln( "eventLoop() returned"); |
| 1427 |
} |
| 1428 |
protected void finalize() throws Throwable |
| 1429 |
{ |
| 1430 |
if (debug) |
| 1431 |
z.reportln( "RXTXPort:MonitorThread exiting"); |
| 1432 |
} |
| 1433 |
} |
| 1434 |
|
| 1435 |
|
| 1436 |
|
| 1437 |
|
| 1438 |
public void setRcvFifoTrigger(int trigger){}; |
| 1439 |
|
| 1440 |
|
| 1441 |
|
| 1442 |
private native static void nativeStaticSetSerialPortParams( String f, |
| 1443 |
int b, int d, int s, int p ) |
| 1444 |
throws UnsupportedCommOperationException; |
| 1445 |
private native static boolean nativeStaticSetDSR( String port, |
| 1446 |
boolean flag ) |
| 1447 |
throws UnsupportedCommOperationException; |
| 1448 |
private native static boolean nativeStaticSetDTR( String port, |
| 1449 |
boolean flag ) |
| 1450 |
throws UnsupportedCommOperationException; |
| 1451 |
private native static boolean nativeStaticSetRTS( String port, |
| 1452 |
boolean flag ) |
| 1453 |
throws UnsupportedCommOperationException; |
| 1454 |
|
| 1455 |
private native static boolean nativeStaticIsDSR( String port ) |
| 1456 |
throws UnsupportedCommOperationException; |
| 1457 |
private native static boolean nativeStaticIsDTR( String port ) |
| 1458 |
throws UnsupportedCommOperationException; |
| 1459 |
private native static boolean nativeStaticIsRTS( String port ) |
| 1460 |
throws UnsupportedCommOperationException; |
| 1461 |
private native static boolean nativeStaticIsCTS( String port ) |
| 1462 |
throws UnsupportedCommOperationException; |
| 1463 |
private native static boolean nativeStaticIsCD( String port ) |
| 1464 |
throws UnsupportedCommOperationException; |
| 1465 |
private native static boolean nativeStaticIsRI( String port ) |
| 1466 |
throws UnsupportedCommOperationException; |
| 1467 |
|
| 1468 |
private native static int nativeStaticGetBaudRate( String port ) |
| 1469 |
throws UnsupportedCommOperationException; |
| 1470 |
private native static int nativeStaticGetDataBits( String port ) |
| 1471 |
throws UnsupportedCommOperationException; |
| 1472 |
private native static int nativeStaticGetParity( String port ) |
| 1473 |
throws UnsupportedCommOperationException; |
| 1474 |
private native static int nativeStaticGetStopBits( String port ) |
| 1475 |
throws UnsupportedCommOperationException; |
| 1476 |
|
| 1477 |
|
| 1478 |
private native byte nativeGetParityErrorChar( ) |
| 1479 |
throws UnsupportedCommOperationException; |
| 1480 |
private native boolean nativeSetParityErrorChar( byte b ) |
| 1481 |
throws UnsupportedCommOperationException; |
| 1482 |
private native byte nativeGetEndOfInputChar( ) |
| 1483 |
throws UnsupportedCommOperationException; |
| 1484 |
private native boolean nativeSetEndOfInputChar( byte b ) |
| 1485 |
throws UnsupportedCommOperationException; |
| 1486 |
private native boolean nativeSetUartType(String type, boolean test) |
| 1487 |
throws UnsupportedCommOperationException; |
| 1488 |
native String nativeGetUartType() |
| 1489 |
throws UnsupportedCommOperationException; |
| 1490 |
private native boolean nativeSetBaudBase(int BaudBase) |
| 1491 |
throws UnsupportedCommOperationException; |
| 1492 |
private native int nativeGetBaudBase() |
| 1493 |
throws UnsupportedCommOperationException; |
| 1494 |
private native boolean nativeSetDivisor(int Divisor) |
| 1495 |
throws UnsupportedCommOperationException; |
| 1496 |
private native int nativeGetDivisor() |
| 1497 |
throws UnsupportedCommOperationException; |
| 1498 |
private native boolean nativeSetLowLatency() |
| 1499 |
throws UnsupportedCommOperationException; |
| 1500 |
private native boolean nativeGetLowLatency() |
| 1501 |
throws UnsupportedCommOperationException; |
| 1502 |
private native boolean nativeSetCallOutHangup(boolean NoHup) |
| 1503 |
throws UnsupportedCommOperationException; |
| 1504 |
private native boolean nativeGetCallOutHangup() |
| 1505 |
throws UnsupportedCommOperationException; |
| 1506 |
|
| 1507 |
|
| 1508 |
|
| 1509 |
|
| 1510 |
|
| 1511 |
|
| 1512 |
|
| 1513 |
|
| 1514 |
|
| 1515 |
|
| 1516 |
|
| 1517 |
|
| 1518 |
|
| 1519 |
|
| 1520 |
public static int staticGetBaudRate( String port ) |
| 1521 |
throws UnsupportedCommOperationException |
| 1522 |
{ |
| 1523 |
if ( debug ) |
| 1524 |
z.reportln( |
| 1525 |
"RXTXPort:staticGetBaudRate( " + port + " )"); |
| 1526 |
return(nativeStaticGetBaudRate( port )); |
| 1527 |
} |
| 1528 |
|
| 1529 |
|
| 1530 |
|
| 1531 |
|
| 1532 |
|
| 1533 |
|
| 1534 |
|
| 1535 |
|
| 1536 |
|
| 1537 |
|
| 1538 |
public static int staticGetDataBits( String port ) |
| 1539 |
throws UnsupportedCommOperationException |
| 1540 |
{ |
| 1541 |
if ( debug ) |
| 1542 |
z.reportln( |
| 1543 |
"RXTXPort:staticGetDataBits( " + port + " )"); |
| 1544 |
return(nativeStaticGetDataBits( port ) ); |
| 1545 |
} |
| 1546 |
|
| 1547 |
|
| 1548 |
|
| 1549 |
|
| 1550 |
|
| 1551 |
|
| 1552 |
|
| 1553 |
|
| 1554 |
|
| 1555 |
|
| 1556 |
|
| 1557 |
public static int staticGetParity( String port ) |
| 1558 |
throws UnsupportedCommOperationException |
| 1559 |
{ |
| 1560 |
if ( debug ) |
| 1561 |
z.reportln( |
| 1562 |
"RXTXPort:staticGetParity( " + port + " )"); |
| 1563 |
return( nativeStaticGetParity( port ) ); |
| 1564 |
} |
| 1565 |
|
| 1566 |
|
| 1567 |
|
| 1568 |
|
| 1569 |
|
| 1570 |
|
| 1571 |
|
| 1572 |
|
| 1573 |
|
| 1574 |
|
| 1575 |
|
| 1576 |
public static int staticGetStopBits( String port ) |
| 1577 |
throws UnsupportedCommOperationException |
| 1578 |
{ |
| 1579 |
if ( debug ) |
| 1580 |
z.reportln( |
| 1581 |
"RXTXPort:staticGetStopBits( " + port + " )"); |
| 1582 |
return(nativeStaticGetStopBits( port ) ); |
| 1583 |
} |
| 1584 |
|
| 1585 |
|
| 1586 |
|
| 1587 |
|
| 1588 |
|
| 1589 |
|
| 1590 |
|
| 1591 |
|
| 1592 |
|
| 1593 |
|
| 1594 |
|
| 1595 |
|
| 1596 |
|
| 1597 |
|
| 1598 |
|
| 1599 |
|
| 1600 |
|
| 1601 |
|
| 1602 |
public static void staticSetSerialPortParams( String f, int b, int d, |
| 1603 |
int s, int p ) |
| 1604 |
throws UnsupportedCommOperationException |
| 1605 |
{ |
| 1606 |
if ( debug ) |
| 1607 |
z.reportln( |
| 1608 |
"RXTXPort:staticSetSerialPortParams( " + |
| 1609 |
f + " " + b + " " + d + " " + s + " " + p ); |
| 1610 |
nativeStaticSetSerialPortParams( f, b, d, s, p ); |
| 1611 |
} |
| 1612 |
|
| 1613 |
|
| 1614 |
|
| 1615 |
|
| 1616 |
|
| 1617 |
|
| 1618 |
|
| 1619 |
|
| 1620 |
|
| 1621 |
|
| 1622 |
|
| 1623 |
|
| 1624 |
|
| 1625 |
|
| 1626 |
|
| 1627 |
public static boolean staticSetDSR( String port, boolean flag ) |
| 1628 |
throws UnsupportedCommOperationException |
| 1629 |
{ |
| 1630 |
if ( debug ) |
| 1631 |
z.reportln( "RXTXPort:staticSetDSR( " + port + |
| 1632 |
" " + flag ); |
| 1633 |
return( nativeStaticSetDSR( port, flag ) ); |
| 1634 |
} |
| 1635 |
|
| 1636 |
|
| 1637 |
|
| 1638 |
|
| 1639 |
|
| 1640 |
|
| 1641 |
|
| 1642 |
|
| 1643 |
|
| 1644 |
|
| 1645 |
|
| 1646 |
|
| 1647 |
|
| 1648 |
|
| 1649 |
|
| 1650 |
public static boolean staticSetDTR( String port, boolean flag ) |
| 1651 |
throws UnsupportedCommOperationException |
| 1652 |
{ |
| 1653 |
if ( debug ) |
| 1654 |
z.reportln( "RXTXPort:staticSetDTR( " + port + |
| 1655 |
" " + flag ); |
| 1656 |
return( nativeStaticSetDTR( port, flag ) ); |
| 1657 |
} |
| 1658 |
|
| 1659 |
|
| 1660 |
|
| 1661 |
|
| 1662 |
|
| 1663 |
|
| 1664 |
|
| 1665 |
|
| 1666 |
|
| 1667 |
|
| 1668 |
|
| 1669 |
|
| 1670 |
|
| 1671 |
|
| 1672 |
|
| 1673 |
public static boolean staticSetRTS( String port, boolean flag ) |
| 1674 |
throws UnsupportedCommOperationException |
| 1675 |
{ |
| 1676 |
if ( debug ) |
| 1677 |
z.reportln( "RXTXPort:staticSetRTS( " + port + |
| 1678 |
" " + flag ); |
| 1679 |
return( nativeStaticSetRTS( port, flag ) ); |
| 1680 |
} |
| 1681 |
|
| 1682 |
|
| 1683 |
|
| 1684 |
|
| 1685 |
|
| 1686 |
|
| 1687 |
|
| 1688 |
|
| 1689 |
|
| 1690 |
|
| 1691 |
|
| 1692 |
|
| 1693 |
|
| 1694 |
|
| 1695 |
public static boolean staticIsRTS( String port ) |
| 1696 |
throws UnsupportedCommOperationException |
| 1697 |
{ |
| 1698 |
if ( debug ) |
| 1699 |
z.reportln( "RXTXPort:staticIsRTS( " + port + " )" ); |
| 1700 |
return( nativeStaticIsRTS( port ) ); |
| 1701 |
} |
| 1702 |
|
| 1703 |
|
| 1704 |
|
| 1705 |
|
| 1706 |
|
| 1707 |
|
| 1708 |
|
| 1709 |
|
| 1710 |
|
| 1711 |
|
| 1712 |
|
| 1713 |
|
| 1714 |
|
| 1715 |
public static boolean staticIsCD( String port ) |
| 1716 |
throws UnsupportedCommOperationException |
| 1717 |
{ |
| 1718 |
if ( debug ) |
| 1719 |
z.reportln( "RXTXPort:staticIsCD( " + port + " )" ); |
| 1720 |
return( nativeStaticIsCD( port ) ); |
| 1721 |
} |
| 1722 |
|
| 1723 |
|
| 1724 |
|
| 1725 |
|
| 1726 |
|
| 1727 |
|
| 1728 |
|
| 1729 |
|
| 1730 |
|
| 1731 |
|
| 1732 |
|
| 1733 |
|
| 1734 |
|
| 1735 |
public static boolean staticIsCTS( String port ) |
| 1736 |
throws UnsupportedCommOperationException |
| 1737 |
{ |
| 1738 |
if ( debug ) |
| 1739 |
z.reportln( "RXTXPort:staticIsCTS( " + port + " )" ); |
| 1740 |
return( nativeStaticIsCTS( port ) ); |
| 1741 |
} |
| 1742 |
|
| 1743 |
|
| 1744 |
|
| 1745 |
|
| 1746 |
|
| 1747 |
|
| 1748 |
|
| 1749 |
|
| 1750 |
|
| 1751 |
|
| 1752 |
|
| 1753 |
|
| 1754 |
|
| 1755 |
public static boolean staticIsDSR( String port ) |
| 1756 |
throws UnsupportedCommOperationException |
| 1757 |
{ |
| 1758 |
if ( debug ) |
| 1759 |
z.reportln( "RXTXPort:staticIsDSR( " + port + " )" ); |
| 1760 |
return( nativeStaticIsDSR( port ) ); |
| 1761 |
} |
| 1762 |
|
| 1763 |
|
| 1764 |
|
| 1765 |
|
| 1766 |
|
| 1767 |
|
| 1768 |
|
| 1769 |
|
| 1770 |
|
| 1771 |
|
| 1772 |
|
| 1773 |
|
| 1774 |
|
| 1775 |
public static boolean staticIsDTR( String port ) |
| 1776 |
throws UnsupportedCommOperationException |
| 1777 |
{ |
| 1778 |
if ( debug ) |
| 1779 |
z.reportln( "RXTXPort:staticIsDTR( " + port + " )" ); |
| 1780 |
return( nativeStaticIsDTR( port ) ); |
| 1781 |
} |
| 1782 |
|
| 1783 |
|
| 1784 |
|
| 1785 |
|
| 1786 |
|
| 1787 |
|
| 1788 |
|
| 1789 |
|
| 1790 |
|
| 1791 |
|
| 1792 |
|
| 1793 |
|
| 1794 |
|
| 1795 |
public static boolean staticIsRI( String port ) |
| 1796 |
throws UnsupportedCommOperationException |
| 1797 |
{ |
| 1798 |
if ( debug ) |
| 1799 |
z.reportln( "RXTXPort:staticIsRI( " + port + " )" ); |
| 1800 |
return( nativeStaticIsRI( port ) ); |
| 1801 |
} |
| 1802 |
|
| 1803 |
|
| 1804 |
|
| 1805 |
|
| 1806 |
|
| 1807 |
|
| 1808 |
|
| 1809 |
|
| 1810 |
|
| 1811 |
|
| 1812 |
|
| 1813 |
|
| 1814 |
public byte getParityErrorChar( ) |
| 1815 |
throws UnsupportedCommOperationException |
| 1816 |
{ |
| 1817 |
byte ret; |
| 1818 |
if ( debug ) |
| 1819 |
z.reportln( "getParityErrorChar()" ); |
| 1820 |
ret = nativeGetParityErrorChar(); |
| 1821 |
if ( debug ) |
| 1822 |
z.reportln( "getParityErrorChar() returns " + |
| 1823 |
ret ); |
| 1824 |
return( ret ); |
| 1825 |
} |
| 1826 |
|
| 1827 |
|
| 1828 |
|
| 1829 |
|
| 1830 |
|
| 1831 |
|
| 1832 |
|
| 1833 |
|
| 1834 |
|
| 1835 |
|
| 1836 |
|
| 1837 |
|
| 1838 |
public boolean setParityErrorChar( byte b ) |
| 1839 |
throws UnsupportedCommOperationException |
| 1840 |
{ |
| 1841 |
if ( debug ) |
| 1842 |
z.reportln( "setParityErrorChar(" + b + ")" ); |
| 1843 |
return( nativeSetParityErrorChar( b ) ); |
| 1844 |
} |
| 1845 |
|
| 1846 |
|
| 1847 |
|
| 1848 |
|
| 1849 |
|
| 1850 |
|
| 1851 |
|
| 1852 |
|
| 1853 |
|
| 1854 |
|
| 1855 |
|
| 1856 |
public byte getEndOfInputChar( ) |
| 1857 |
throws UnsupportedCommOperationException |
| 1858 |
{ |
| 1859 |
byte ret; |
| 1860 |
if ( debug ) |
| 1861 |
z.reportln( "getEndOfInputChar()" ); |
| 1862 |
ret = nativeGetEndOfInputChar(); |
| 1863 |
if ( debug ) |
| 1864 |
z.reportln( "getEndOfInputChar() returns " + |
| 1865 |
ret ); |
| 1866 |
return( ret ); |
| 1867 |
} |
| 1868 |
|
| 1869 |
|
| 1870 |
|
| 1871 |
|
| 1872 |
|
| 1873 |
|
| 1874 |
|
| 1875 |
|
| 1876 |
|
| 1877 |
|
| 1878 |
public boolean setEndOfInputChar( byte b ) |
| 1879 |
throws UnsupportedCommOperationException |
| 1880 |
{ |
| 1881 |
if ( debug ) |
| 1882 |
z.reportln( "setEndOfInputChar(" + b + ")" ); |
| 1883 |
return( nativeSetEndOfInputChar( b ) ); |
| 1884 |
} |
| 1885 |
|
| 1886 |
|
| 1887 |
|
| 1888 |
|
| 1889 |
|
| 1890 |
|
| 1891 |
|
| 1892 |
|
| 1893 |
|
| 1894 |
|
| 1895 |
|
| 1896 |
|
| 1897 |
public boolean setUARTType(String type, boolean test) |
| 1898 |
throws UnsupportedCommOperationException |
| 1899 |
{ |
| 1900 |
if ( debug ) |
| 1901 |
z.reportln( "RXTXPort:setUARTType()"); |
| 1902 |
return nativeSetUartType(type, test); |
| 1903 |
} |
| 1904 |
|
| 1905 |
|
| 1906 |
|
| 1907 |
|
| 1908 |
|
| 1909 |
|
| 1910 |
|
| 1911 |
|
| 1912 |
|
| 1913 |
public String getUARTType() throws UnsupportedCommOperationException |
| 1914 |
{ |
| 1915 |
return nativeGetUartType(); |
| 1916 |
} |
| 1917 |
|
| 1918 |
|
| 1919 |
|
| 1920 |
|
| 1921 |
|
| 1922 |
|
| 1923 |
|
| 1924 |
|
| 1925 |
|
| 1926 |
public boolean setBaudBase(int BaudBase) |
| 1927 |
throws UnsupportedCommOperationException |
| 1928 |
{ |
| 1929 |
if ( debug ) |
| 1930 |
z.reportln( "RXTXPort:setBaudBase()"); |
| 1931 |
return nativeSetBaudBase(BaudBase); |
| 1932 |
} |
| 1933 |
|
| 1934 |
|
| 1935 |
|
| 1936 |
|
| 1937 |
|
| 1938 |
|
| 1939 |
|
| 1940 |
public int getBaudBase() throws UnsupportedCommOperationException |
| 1941 |
{ |
| 1942 |
if ( debug ) |
| 1943 |
z.reportln( "RXTXPort:getBaudBase()"); |
| 1944 |
return nativeGetBaudBase(); |
| 1945 |
} |
| 1946 |
|
| 1947 |
|
| 1948 |
|
| 1949 |
|
| 1950 |
|
| 1951 |
|
| 1952 |
|
| 1953 |
public boolean setDivisor(int Divisor) |
| 1954 |
throws UnsupportedCommOperationException |
| 1955 |
{ |
| 1956 |
if ( debug ) |
| 1957 |
z.reportln( "RXTXPort:setDivisor()"); |
| 1958 |
return nativeSetDivisor(Divisor); |
| 1959 |
} |
| 1960 |
|
| 1961 |
|
| 1962 |
|
| 1963 |
|
| 1964 |
|
| 1965 |
|
| 1966 |
|
| 1967 |
public int getDivisor() throws UnsupportedCommOperationException |
| 1968 |
{ |
| 1969 |
if ( debug ) |
| 1970 |
z.reportln( "RXTXPort:getDivisor()"); |
| 1971 |
return nativeGetDivisor(); |
| 1972 |
} |
| 1973 |
|
| 1974 |
|
| 1975 |
|
| 1976 |
|
| 1977 |
|
| 1978 |
|
| 1979 |
|
| 1980 |
public boolean setLowLatency() throws UnsupportedCommOperationException |
| 1981 |
{ |
| 1982 |
if ( debug ) |
| 1983 |
z.reportln( "RXTXPort:setLowLatency()"); |
| 1984 |
return nativeSetLowLatency(); |
| 1985 |
} |
| 1986 |
|
| 1987 |
|
| 1988 |
|
| 1989 |
|
| 1990 |
|
| 1991 |
|
| 1992 |
|
| 1993 |
public boolean getLowLatency() throws UnsupportedCommOperationException |
| 1994 |
{ |
| 1995 |
if ( debug ) |
| 1996 |
z.reportln( "RXTXPort:getLowLatency()"); |
| 1997 |
return nativeGetLowLatency(); |
| 1998 |
} |
| 1999 |
|
| 2000 |
|
| 2001 |
|
| 2002 |
|
| 2003 |
|
| 2004 |
|
| 2005 |
|
| 2006 |
public boolean setCallOutHangup(boolean NoHup) |
| 2007 |
throws UnsupportedCommOperationException |
| 2008 |
{ |
| 2009 |
if ( debug ) |
| 2010 |
z.reportln( "RXTXPort:setCallOutHangup()"); |
| 2011 |
return nativeSetCallOutHangup(NoHup); |
| 2012 |
} |
| 2013 |
|
| 2014 |
|
| 2015 |
|
| 2016 |
|
| 2017 |
|
| 2018 |
|
| 2019 |
|
| 2020 |
public boolean getCallOutHangup() |
| 2021 |
throws UnsupportedCommOperationException |
| 2022 |
{ |
| 2023 |
if ( debug ) |
| 2024 |
z.reportln( "RXTXPort:getCallOutHangup()"); |
| 2025 |
return nativeGetCallOutHangup(); |
| 2026 |
} |
| 2027 |
|
| 2028 |
|
| 2029 |
} |