comparison src/org/tn5250j/framework/tn5250/tnvt.java @ 414:12b2a3a35afe

more debugging looking for duplicate transmission
author Carl Byington <carl@five-ten-sg.com>
date Sat, 25 Oct 2014 10:52:39 -0700
parents da2814f6f05e
children 09c1d3aae3f0
comparison
equal deleted inserted replaced
413:da2814f6f05e 414:12b2a3a35afe
414 private final void writeByte(byte abyte0[]) throws IOException { 414 private final void writeByte(byte abyte0[]) throws IOException {
415 bout.write(abyte0); 415 bout.write(abyte0);
416 bout.flush(); 416 bout.flush();
417 } 417 }
418 418
419 // private final void writeByte(byte byte0) throws IOException {
420 //
421 // bout.write(byte0);
422 // bout.flush();
423 // }
424
425 public final void sendHeartBeat() throws IOException {
426 byte[] b = { (byte) 0xff, (byte) 0xf1 };
427 bout.write(b);
428 bout.flush();
429 }
430
431 private final void readImmediate(int readType) { 419 private final void readImmediate(int readType) {
432 if (screen52.isStatusErrorCode()) { 420 if (screen52.isStatusErrorCode()) {
433 screen52.restoreErrorLine(); 421 screen52.restoreErrorLine();
434 screen52.setStatus(Screen5250.STATUS_ERROR_CODE, 422 screen52.setStatus(Screen5250.STATUS_ERROR_CODE,
435 Screen5250.STATUS_VALUE_OFF, null); 423 Screen5250.STATUS_VALUE_OFF, null);
447 pendingUnlock = false; 435 pendingUnlock = false;
448 invited = false; 436 invited = false;
449 screen52.getScreenFields().readFormatTable(baosp, readType, codePage); 437 screen52.getScreenFields().readFormatTable(baosp, readType, codePage);
450 438
451 try { 439 try {
440 Log.i(TAG, "readImmediate() writeGDS()");
452 writeGDS(0, 3, baosp.toByteArray()); 441 writeGDS(0, 3, baosp.toByteArray());
453 } 442 }
454 catch (IOException ioe) { 443 catch (IOException ioe) {
455 Log.w(TAG, ioe.getMessage()); 444 Log.w(TAG, ioe.getMessage());
456 baosp.reset();
457 } 445 }
458 446
459 baosp.reset(); 447 baosp.reset();
460 } 448 }
461 449
484 if (dataIncluded(aid)) 472 if (dataIncluded(aid))
485 screen52.getScreenFields().readFormatTable(baosp, readType, 473 screen52.getScreenFields().readFormatTable(baosp, readType,
486 codePage); 474 codePage);
487 475
488 try { 476 try {
477 Log.i(TAG, "sendAidKey() writeGDS()");
489 writeGDS(0, 3, baosp.toByteArray()); 478 writeGDS(0, 3, baosp.toByteArray());
490 } 479 }
491 catch (IOException ioe) { 480 catch (IOException ioe) {
492 Log.w(TAG, ioe.getMessage()); 481 Log.w(TAG, ioe.getMessage());
493 baosp.reset(); 482 baosp.reset();
593 baosp.write(screen52.getCurrentRow()); 582 baosp.write(screen52.getCurrentRow());
594 baosp.write(screen52.getCurrentCol()); 583 baosp.write(screen52.getCurrentCol());
595 baosp.write(AID_HELP); 584 baosp.write(AID_HELP);
596 585
597 try { 586 try {
587 Log.i(TAG, "sendHelpRequest() writeGDS()");
598 writeGDS(0, 3, baosp.toByteArray()); 588 writeGDS(0, 3, baosp.toByteArray());
599 } 589 }
600 catch (IOException ioe) { 590 catch (IOException ioe) {
601 Log.w(TAG, ioe.getMessage()); 591 Log.w(TAG, ioe.getMessage());
602 } 592 }
622 // bit 6 - TRQ Test request key 612 // bit 6 - TRQ Test request key
623 // bit 7 - HLP 613 // bit 7 - HLP
624 614
625 // System.out.println("Attention key sent"); 615 // System.out.println("Attention key sent");
626 try { 616 try {
617 Log.i(TAG, "sendAttentionKey() writeGDS()");
627 writeGDS(0x40, 0, null); 618 writeGDS(0x40, 0, null);
628 } 619 }
629 catch (IOException ioe) { 620 catch (IOException ioe) {
630 Log.w(TAG, ioe.getMessage()); 621 Log.w(TAG, ioe.getMessage());
631 } 622 }
670 661
671 bytes = baosp.toByteArray(); 662 bytes = baosp.toByteArray();
672 } 663 }
673 664
674 try { 665 try {
666 Log.i(TAG, "systemRequest() writeGDS()");
675 writeGDS(4, 0, bytes); 667 writeGDS(4, 0, bytes);
676 } 668 }
677 catch (IOException ioe) { 669 catch (IOException ioe) {
678 Log.i(TAG, ioe.getMessage()); 670 Log.i(TAG, ioe.getMessage());
679 } 671 }
700 // Client: sends header with the 000A12A0 00000400 000AFFEF 692 // Client: sends header with the 000A12A0 00000400 000AFFEF
701 // Opcode = Cancel Invite to 693 // Opcode = Cancel Invite to
702 // indicate that the work station is 694 // indicate that the work station is
703 // no longer invited. 695 // no longer invited.
704 try { 696 try {
697 Log.i(TAG, "cancelInvite() writeGDS()");
705 writeGDS(0, 10, null); 698 writeGDS(0, 10, null);
706 } 699 }
707 catch (IOException ioe) { 700 catch (IOException ioe) {
708 Log.w(TAG, ioe.getMessage()); 701 Log.w(TAG, ioe.getMessage());
709 } 702 }
740 baosp.write(screen52.getCurrentRow()); 733 baosp.write(screen52.getCurrentRow());
741 baosp.write(screen52.getCurrentCol()); 734 baosp.write(screen52.getCurrentCol());
742 baosp.write(AID_PRINT); // aid key 735 baosp.write(AID_PRINT); // aid key
743 736
744 try { 737 try {
738 Log.i(TAG, "hostPrint() writeGDS()");
745 writeGDS(0, 3, baosp.toByteArray()); 739 writeGDS(0, 3, baosp.toByteArray());
746 } 740 }
747 catch (IOException ioe) { 741 catch (IOException ioe) {
748 Log.w(TAG, ioe.getMessage()); 742 Log.w(TAG, ioe.getMessage());
749 } 743 }
805 baosrsp = appendByteStream(baosrsp.toByteArray()); 799 baosrsp = appendByteStream(baosrsp.toByteArray());
806 // make sure we indicate no more to be sent 800 // make sure we indicate no more to be sent
807 baosrsp.write(IAC); 801 baosrsp.write(IAC);
808 baosrsp.write(EOR); 802 baosrsp.write(EOR);
809 baosrsp.writeTo(bout); 803 baosrsp.writeTo(bout);
810 // byte[] b = new byte[baosrsp.size()];
811 // b = baosrsp.toByteArray();
812 // dump(b);
813 bout.flush(); 804 bout.flush();
814 // baos = null;
815 baosrsp.reset(); 805 baosrsp.reset();
816 } 806 }
817 807
818 protected final int getOpCode() { 808 protected final int getOpCode() {
819 return bk.getOpCode(); 809 return bk.getOpCode();
820 } 810 }
821
822 // private final void sendNotify() throws IOException {
823 //
824 // writeGDS(0, 0, null);
825 // }
826 811
827 protected boolean[] getActiveAidKeys() { 812 protected boolean[] getActiveAidKeys() {
828 boolean aids[] = new boolean[dataIncluded.length]; 813 boolean aids[] = new boolean[dataIncluded.length];
829 System.arraycopy(dataIncluded, 0, aids, 0, dataIncluded.length); 814 System.arraycopy(dataIncluded, 0, aids, 0, dataIncluded.length);
830 return aids; 815 return aids;
1130 private final void readScreen() throws IOException { 1115 private final void readScreen() throws IOException {
1131 int rows = screen52.getRows(); 1116 int rows = screen52.getRows();
1132 int cols = screen52.getColumns(); 1117 int cols = screen52.getColumns();
1133 byte abyte0[] = new byte[rows * cols]; 1118 byte abyte0[] = new byte[rows * cols];
1134 fillScreenArray(abyte0, rows, cols); 1119 fillScreenArray(abyte0, rows, cols);
1120 Log.i(TAG, "readScreen() writeGDS()");
1135 writeGDS(0, 0, abyte0); 1121 writeGDS(0, 0, abyte0);
1136 abyte0 = null; 1122 abyte0 = null;
1137 } 1123 }
1138 1124
1139 private final void fillScreenArray(byte[] sa, int rows, int cols) { 1125 private final void fillScreenArray(byte[] sa, int rows, int cols) {
1281 // screen52.getScreenFields().setCurrentField(null); // set it to null 1267 // screen52.getScreenFields().setCurrentField(null); // set it to null
1282 // for GC ? 1268 // for GC ?
1283 // screen52.clearTable(); 1269 // screen52.clearTable();
1284 1270
1285 try { 1271 try {
1272 Log.i(TAG, "saveScreen() writeGDS()");
1286 writeGDS(0, 3, sc.toByteArray()); 1273 writeGDS(0, 3, sc.toByteArray());
1287 } 1274 }
1288 catch (IOException ioe) { 1275 catch (IOException ioe) {
1289 Log.w(TAG, ioe.getMessage()); 1276 Log.w(TAG, ioe.getMessage());
1290 } 1277 }
1620 baosp.write(modifier); 1607 baosp.write(modifier);
1621 baosp.write(uByte1); 1608 baosp.write(uByte1);
1622 baosp.write(uByte2); 1609 baosp.write(uByte2);
1623 1610
1624 try { 1611 try {
1612 Log.i(TAG, "sendNegResponse() writeGDS()");
1625 writeGDS(128, 0, baosp.toByteArray()); 1613 writeGDS(128, 0, baosp.toByteArray());
1626 } 1614 }
1627 catch (IOException ioe) { 1615 catch (IOException ioe) {
1628 Log.w(TAG, ioe.getMessage()); 1616 Log.w(TAG, ioe.getMessage());
1629 } 1617 }
1635 screen52.setPrehelpState(true, true, false); 1623 screen52.setPrehelpState(true, true, false);
1636 baosp.write(0x00); 1624 baosp.write(0x00);
1637 baosp.write(ec); 1625 baosp.write(ec);
1638 1626
1639 try { 1627 try {
1628 Log.i(TAG, "sendNegResponse2() writeGDS()");
1640 writeGDS(1, 0, baosp.toByteArray()); 1629 writeGDS(1, 0, baosp.toByteArray());
1641 } 1630 }
1642 catch (IOException ioe) { 1631 catch (IOException ioe) {
1643 Log.w(TAG, ioe.getMessage()); 1632 Log.w(TAG, ioe.getMessage());
1644 } 1633 }
2342 abyte0[59] = 0; 2331 abyte0[59] = 0;
2343 abyte0[60] = 0; 2332 abyte0[60] = 0;
2344 abyte0[61] = 0; // gridlines are not supported 2333 abyte0[61] = 0; // gridlines are not supported
2345 abyte0[62] = 0; // gridlines are not supported 2334 abyte0[62] = 0; // gridlines are not supported
2346 abyte0[63] = 0; 2335 abyte0[63] = 0;
2336 Log.i(TAG, "sendQueryResponse() writeGDS()");
2347 writeGDS(0, 0, abyte0); // now tell them about us 2337 writeGDS(0, 0, abyte0); // now tell them about us
2348 abyte0 = null; 2338 abyte0 = null;
2349 } 2339 }
2350 2340
2351 protected final boolean negotiate(byte abyte0[]) throws IOException { 2341 protected final boolean negotiate(byte abyte0[]) throws IOException {