Blazemeter / xtn5250

IBM TN5250 terminal emulator
Apache License 2.0
10 stars 6 forks source link

Unable to send PF13 to PF24 key events #6

Closed senram closed 3 years ago

senram commented 3 years ago

Hi, I am unable to send PF13 to PF24 key events.

For troubleshooting reasons, I tried to reproduce the issue in following public server "PUB400.com" with a test function.

You can see the console output after sending F16, which neither performs the expected action nor says "Function key not allowed" (as it did for F10).

Please help to resolve the issue

    public void testFn(){

        String userId= "<>";
        String password = "<>";

        TerminalClient terminal = new TerminalClient();
        terminal.setConnectionTimeoutMillis(20000);
        terminal.connect("PUB400.com", 23);
        awaitKeyboardUnlock(terminal);

        terminal.setFieldTextByLabel("Your user name:", userId);
        terminal.setFieldTextByLabel("Password (max. 128):", password);
        terminal.sendKeyEvent(KeyEvent.VK_ENTER, 0);
        awaitKeyboardUnlock(terminal);

        terminal.setFieldTextByCoord(terminal.getCursorPosition().get().y, terminal.getCursorPosition().get().x, "1");
        terminal.sendKeyEvent(KeyEvent.VK_ENTER, 0);
        awaitKeyboardUnlock(terminal);

        terminal.setFieldTextByCoord(terminal.getCursorPosition().get().y, terminal.getCursorPosition().get().x, "1");
        terminal.sendKeyEvent(KeyEvent.VK_ENTER, 0);
        awaitKeyboardUnlock(terminal);

        terminal.setFieldTextByCoord(terminal.getCursorPosition().get().y, terminal.getCursorPosition().get().x, "1");
        terminal.sendKeyEvent(KeyEvent.VK_ENTER, 0);
        awaitKeyboardUnlock(terminal);
        System.out.println(terminal.getScreenText());

        terminal.sendKeyEvent(KeyEvent.VK_F16, 0);
        awaitKeyboardUnlock(terminal);
        System.out.println(terminal.getScreenText());

        terminal.sendKeyEvent(KeyEvent.VK_F10, 0);
        awaitKeyboardUnlock(terminal);
        System.out.println(terminal.getScreenText());

        terminal.disconnect();
    }

    public void awaitKeyboardUnlock(TerminalClient terminal){
        ScheduledExecutorService stableTimeoutExecutor = Executors
                .newSingleThreadScheduledExecutor();
        try {
            new UnlockWaiter(terminal, stableTimeoutExecutor).await(10000);
        } catch (InterruptedException | TimeoutException exception){
            throw new RuntimeException(exception.getMessage());
        }
    }

Console output:

@Google @JIRA-2 @Mainframe
Scenario: Sample Mainframe 5250 # src/test/features/diagnostic/Mainframe.feature:12
20:47:27.485 [AWT-EventQueue-0] DEBUG stepdefinitions.diagnostic.mainframe.UnlockWaiter - Start stable period since input is no longer inhibited
20:47:29.475 [AWT-EventQueue-0] DEBUG stepdefinitions.diagnostic.mainframe.UnlockWaiter - Start stable period since input is no longer inhibited
20:47:30.866 [AWT-EventQueue-0] DEBUG stepdefinitions.diagnostic.mainframe.UnlockWaiter - Start stable period since input is no longer inhibited
20:47:32.275 [AWT-EventQueue-0] DEBUG stepdefinitions.diagnostic.mainframe.UnlockWaiter - Start stable period since input is no longer inhibited
20:47:33.666 [AWT-EventQueue-0] DEBUG stepdefinitions.diagnostic.mainframe.UnlockWaiter - Start stable period since input is no longer inhibited
                         Display Job Status Attributes                          
                                                             System:   PUB400   
 Job:   QPAD124421     User:   HARISHKEV      Number:   268761                  

 Status of job . . . . . . . . . . . . . . . :   ACTIVE                         
 Current user profile  . . . . . . . . . . . :   HARISHKEV                      
 Job user identity . . . . . . . . . . . . . :   HARISHKEV                      
   Set by  . . . . . . . . . . . . . . . . . :     *DEFAULT                     
 Entered system:                                                                
   Date  . . . . . . . . . . . . . . . . . . :   20-07-19                       
   Time  . . . . . . . . . . . . . . . . . . :   12:44:22                       
 Started:                                                                       
   Date  . . . . . . . . . . . . . . . . . . :   20-07-19                       
   Time  . . . . . . . . . . . . . . . . . . :   12:44:22                       
 Subsystem . . . . . . . . . . . . . . . . . :   QINTER                         
   Subsystem pool ID . . . . . . . . . . . . :     2                            
 Type of job . . . . . . . . . . . . . . . . :   INTER                          
 Special environment . . . . . . . . . . . . :   *NONE                          
 Program return code . . . . . . . . . . . . :   0                              
                                                                        More... 
 Press Enter to continue.                                                       

 F3=Exit   F5=Refresh   F12=Cancel   F16=Job menu                               

20:47:43.905 [main] DEBUG stepdefinitions.diagnostic.mainframe.UnlockWaiter - Start stable period since input is not inhibited
                         Display Job Status Attributes                          
                                                             System:   PUB400   
 Job:   QPAD124421     User:   HARISHKEV      Number:   268761                  

 Status of job . . . . . . . . . . . . . . . :   ACTIVE                         
 Current user profile  . . . . . . . . . . . :   HARISHKEV                      
 Job user identity . . . . . . . . . . . . . :   HARISHKEV                      
   Set by  . . . . . . . . . . . . . . . . . :     *DEFAULT                     
 Entered system:                                                                
   Date  . . . . . . . . . . . . . . . . . . :   20-07-19                       
   Time  . . . . . . . . . . . . . . . . . . :   12:44:22                       
 Started:                                                                       
   Date  . . . . . . . . . . . . . . . . . . :   20-07-19                       
   Time  . . . . . . . . . . . . . . . . . . :   12:44:22                       
 Subsystem . . . . . . . . . . . . . . . . . :   QINTER                         
   Subsystem pool ID . . . . . . . . . . . . :     2                            
 Type of job . . . . . . . . . . . . . . . . :   INTER                          
 Special environment . . . . . . . . . . . . :   *NONE                          
 Program return code . . . . . . . . . . . . :   0                              
                                                                        More... 
 Press Enter to continue.                                                       

 F3=Exit   F5=Refresh   F12=Cancel   F16=Job menu                               

20:47:53.177 [AWT-EventQueue-0] DEBUG stepdefinitions.diagnostic.mainframe.UnlockWaiter - Start stable period since input is no longer inhibited
                         Display Job Status Attributes                          
                                                             System:   PUB400   
 Job:   QPAD124421     User:   HARISHKEV      Number:   268761                  

 Status of job . . . . . . . . . . . . . . . :   ACTIVE                         
 Current user profile  . . . . . . . . . . . :   HARISHKEV                      
 Job user identity . . . . . . . . . . . . . :   HARISHKEV                      
   Set by  . . . . . . . . . . . . . . . . . :     *DEFAULT                     
 Entered system:                                                                
   Date  . . . . . . . . . . . . . . . . . . :   20-07-19                       
   Time  . . . . . . . . . . . . . . . . . . :   12:44:22                       
 Started:                                                                       
   Date  . . . . . . . . . . . . . . . . . . :   20-07-19                       
   Time  . . . . . . . . . . . . . . . . . . :   12:44:22                       
 Subsystem . . . . . . . . . . . . . . . . . :   QINTER                         
   Subsystem pool ID . . . . . . . . . . . . :     2                            
 Type of job . . . . . . . . . . . . . . . . :   INTER                          
 Special environment . . . . . . . . . . . . :   *NONE                          
 Program return code . . . . . . . . . . . . :   0                              
                                                                        More... 
 Press Enter to continue.                                                       

 F3=Exit   F5=Refresh   F12=Cancel   F16=Job menu                               
 Function key not allowed.                                                      
Baraujo25 commented 3 years ago
Hi @senram, As far as I have seen on your code (I did not test it), you are trying to send a PF13. In order to actually sent that key, you should call terminal.sendKeyEvent(KeyEvent.VK_F1, KeyEvent.SHIFT_MASK); Mapping would be something like: Key Java call
F1 terminal.sendKeyEvent(KeyEvent.VK_F1, 0);
F2 terminal.sendKeyEvent(KeyEvent.VK_F2, 0);
F3 terminal.sendKeyEvent(KeyEvent.VK_F3, 0);
F12 terminal.sendKeyEvent(KeyEvent.VK_F12, 0);
F13 terminal.sendKeyEvent(KeyEvent.VK_F1, KeyEvent.SHIFT_MASK);
F14 terminal.sendKeyEvent(KeyEvent.VK_F2, KeyEvent.SHIFT_MASK);
F15 terminal.sendKeyEvent(KeyEvent.VK_F3, KeyEvent.SHIFT_MASK);
F24 terminal.sendKeyEvent(KeyEvent.VK_F12, KeyEvent.SHIFT_MASK);

Let me know if the issue persists. I will be looking forward to your response.

Best regards,

senram commented 3 years ago

Thanks @Baraujo25 . it worked.

Console Output:

                         Display Job Status Attributes                          
                                                             System:   PUB400   
 Job:   QPAD231129     User:   HARISHKEV      Number:   286428                  

 Status of job . . . . . . . . . . . . . . . :   ACTIVE                         
 Current user profile  . . . . . . . . . . . :   HARISHKEV                      
 Job user identity . . . . . . . . . . . . . :   HARISHKEV                      
   Set by  . . . . . . . . . . . . . . . . . :     *DEFAULT                     
 Entered system:                                                                
   Date  . . . . . . . . . . . . . . . . . . :   20-07-19                       
   Time  . . . . . . . . . . . . . . . . . . :   23:11:31                       
 Started:                                                                       
   Date  . . . . . . . . . . . . . . . . . . :   20-07-19                       
   Time  . . . . . . . . . . . . . . . . . . :   23:11:31                       
 Subsystem . . . . . . . . . . . . . . . . . :   QINTER                         
   Subsystem pool ID . . . . . . . . . . . . :     2                            
 Type of job . . . . . . . . . . . . . . . . :   INTER                          
 Special environment . . . . . . . . . . . . :   *NONE                          
 Program return code . . . . . . . . . . . . :   0                              
                                                                        More... 
 Press Enter to continue.                                                       

 F3=Exit   F5=Refresh   F12=Cancel   F16=Job menu                               

07:14:43.370 [AWT-EventQueue-0] DEBUG stepdefinitions.diagnostic.mainframe.UnlockWaiter - Start stable period since input is no longer inhibited
                                 Work with Job                                  
                                                             System:   PUB400   
 Job:   QPAD231129     User:   HARISHKEV      Number:   286428                  

 Select one of the following:                                                   

      1. Display job status attributes                                          
      2. Display job definition attributes                                      
      3. Display job run attributes, if active                                  
      4. Work with spooled files                                                

     10. Display job log, if active, on job queue, or pending                   
     11. Display call stack, if active                                          
     12. Work with locks, if active                                             
     13. Display library list, if active                                        
     14. Display open files, if active                                          
     15. Display file overrides, if active                                      
     16. Display commitment control status, if active                           
                                                                        More... 
 Selection or command                                                           
 ===>                                                                           

 F3=Exit   F4=Prompt   F9=Retrieve   F12=Cancel                                 

07:14:44.759 [AWT-EventQueue-0] DEBUG stepdefinitions.diagnostic.mainframe.UnlockWaiter - Start stable period since input is no longer inhibited
                                 Work with Job                                  
                                                             System:   PUB400   
 Job:   QPAD231129     User:   HARISHKEV      Number:   286428                  

 Select one of the following:                                                   

      1. Display job status attributes                                          
      2. Display job definition attributes                                      
      3. Display job run attributes, if active                                  
      4. Work with spooled files                                                

     10. Display job log, if active, on job queue, or pending                   
     11. Display call stack, if active                                          
     12. Work with locks, if active                                             
     13. Display library list, if active                                        
     14. Display open files, if active                                          
     15. Display file overrides, if active                                      
     16. Display commitment control status, if active                           
                                                                        More... 
 Selection or command                                                           
 ===>                                                                           

 F3=Exit   F4=Prompt   F9=Retrieve   F12=Cancel                                 
 Function key not allowed.                                                      

===============================================
CoreFramework
Total tests run: 1, Failures: 0, Skips: 0
===============================================

Process finished with exit code 0