Jump to content

Hyperterminal Console read characters


Recommended Posts

Greetings to AutoIt community.

I am using AutoIt v3. My requirement is to automate some activities where hyperterminal is launched and connected to an embedded device through serial COM port. Based on what gets displayed on hyperterminal, some commands need to be typed. This means characters and strings getting displayed in hyperterminal need to be identified and parsed to perform further actions.

I am able to launch hyperterminal and enter characters into the terminal. But I am stuck at reading characters from hyperterminal. Some support in achieving this will be very helpful.

Using CommMG UDF would not be an ideal choice because I think CommMG needs full access of COM port which means hyperterminal cannot be connected to same com port in parallel.

Thanks
Mayur

Link to comment
Share on other sites

21 hours ago, AutoBert said:

StdoutRead didn't work? Show a runable (reproducer) script with the issue.

I couldn't achieve what I wanted with StdoutRead( )
Details on how I tested are ..........

Code:

#include <GuiEdit.au3>

Local $iPID = Run("C:\Projects\Utilities\Hyperterminal\hypertrm.exe")
Local $hWnd = WinWaitActive("Connection Description")

ControlSend($hWnd, "Connection Description", "Edit1", "CONSOLE_1")
Send("{TAB}{TAB}{ENTER}")

Local $idCombo = WinWaitActive("Connect To")
Send("{TAB}{ENTER}")
Send("!r")
Send("1")
Send("1") ; Configuring com port conection settings


Send("{ENTER}") ;Reached Terminal screen

Send("{ENTER}")
Send("{ENTER}") ;Login request appears in console
Sleep(2000)
;Local $Console = StdoutRead($iPID)
;Local $Console = StdoutRead($iPID, True, False)
;Local $Console = StdoutRead($iPID, False, False)
;Local $Console = StdoutRead($iPID, False, True)
Local $Console = StdoutRead($iPID, True, True)

MsgBox($MB_SYSTEMMODAL, "Information", "$Console: " & $Console)

When hyperterminal prints "login:" automatically user name should get entered. But the string "login:" is not getting recognized by StdoutRead() as shown in the screenshot.

Autoit Automation.jpg

Link to comment
Share on other sites

You must use the parameter opt_flag with one of both:

Quote

$STDOUT_CHILD (0x2) = Provide a handle to the child's STDOUT stream
 $STDERR_MERGED (0x8) = Provides the same handle for STDOUT and STDERR. Implies both $STDOUT_CHILD and $STDERR_CHILD.

, try this script:

#include <GuiEdit.au3>

Local $iPID = Run("C:\Projects\Utilities\Hyperterminal\hypertrm.exe",@SW_SHOW,$STDOUT_CHILD)
if @error Then Exit

Local $hWnd = WinWaitActive("Connection Description")

ControlSend($hWnd, "Connection Description", "Edit1", "CONSOLE_1")
Send("{TAB}{TAB}{ENTER}")

Local $idCombo = WinWaitActive("Connect To")
Send("{TAB}{ENTER}")
Send("!r")
Send("1")
Send("1") ; Configuring com port conection settings


Send("{ENTER}") ;Reached Terminal screen

Send("{ENTER}")
Send("{ENTER}") ;Login request appears in console
Sleep(2000)

Local $Console, $oldcon

While ProcessExists($iPID)
    $Console = StdoutRead($iPID)
    If $Console<>$oldcon Then
        MsgBox($MB_SYSTEMMODAL, "Information", "$Console: " & $Console,5)
        $oldcon=$Console
        $Console=''
    EndIf
WEnd

 

Edited by AutoBert
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...