Sign in to follow this  
Followers 0
raudi

check response in dos-box?

6 posts in this topic

Hey everybody,

I have a bit of a problem creating a script, well not a problem, It's a challenge.. :whistle:

Here's the situation:

I need to write a script that can respond to text being put on screen inside a dos-box.

I will have to run this command: "c:\serialterm com1 9600 ascii empty no seriallog.txt"

It will start a program that communicates with a device through the com1 port of the pc.

When the program is started, it displays data being sent from that device on the screen.

I've been looking for a way to somehow 'read' that data being displayed on the screen while that program is still running.

The output i need to react to is this:

a rotating / (first /, then |, then \, then -, then /, then | etc...)

When that's visible on screen, i need to send: "cmd ?" (with the Send() command)

The next respons i need to check for is: "command line initiated"

When that's visible on screen, i need to close the program and the dos-box.

I'm running AutoIt v3 and i'm using: SciTE - Version 1.72 - Jan 15 2007 21:43:31

I've tried the script from BlueBearr posted in the following thread :

http://www.autoitscript.com/forum/index.ph...&hl=dos-box

Unfortunately, it doesn't respond to the data being put on screen by serialterm.

I've been looking inside the help, the function list and i've been searching the forum for anything that could help me figure out how to do this. I'm close to desperate and I'm starting to think it isn't possible at all with AutoIt v3.

Can you please help me?

Share this post


Link to post
Share on other sites



I'm not sure, but I think StdOutRead() and/or StdErrRead() are all you need, there is nothing difficult about using that, guess either you missed it or I am not getting you. Check the help for StdOutRead() and especially the example code, which executes a dos command (dir) and reads the "dos response" (which is not so much DOS-specific as StdOut-specific, I'm willing to bet that your Term just writes to StdOut too) and shows them in msgboxes.

Try it!


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

It's been a while, haven't had the time to test the suggestions posted here until today.

I have tried 3 options, but none of them seem to work properly..

Again, the whole idea of my script is to detect the -/|\ ( rotating slash ), then send a command ( cmd?{enter} ) and wait for the response: "Command line initiated".

The first option:

http://www.autoitscript.com/forum/index.ph...st&p=110970

I used the code from the link above to write the output of my command to the clipboard.

I wanted to know if the output was read at all.

I created a while loop of 20 seconds. In the loop the data i get by using the function ConsoleRead() was constantly written to the clipboard. That was the intension.. But it didn't work at all. Only when i pressed Esc of Ctrl-Break to exit, the data was being written to the clipboard. But then it was already too late. This is the output i got when i pressed Esc:

D:\Scripting>serialterm com1 9600 ascii empty yes seriallog.txt

press Esc or Ctrl+C to terminate

ø

van Hall PLC driver

=========================

PTC rm&s

Koopmans & Zwart

=========================

v1.0a

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

-

/

|

\

MRI 90

OK

ATI

GR47

OK

GR47 found

at*e2apc=1,1

OK

at*e2apc?

*E2APC: 1,1,0,0

OK

ats0=1

OK

save

You can see that after a period of time, the rotating slash disappears and other data is starting to show up.

Before that other data is starting to show up, my script must have given the command: cmd?{enter} to proceed..

Then there's option #2..

Using the run function combined with the stdOutRead function:

#include <Constants.au3>
SplashTextOn("MyProgress", "Programming modem", 300, 100)
$CHILDDOS = Run(@ComSpec & ' /k "' & @ScriptDir & '\test.bat"', @ScriptDir, @SW_MINIMIZE, $STDIN_CHILD + $STDOUT_CHILD)
;$CHILDDOS = ShellExecute("test.bat", "", @scriptdir, "open")

While 1
    $Status = StdoutRead($CHILDDOS)
    If @error Then ExitLoop
    Select 
        Case StringInStr($Status, "|")
            sleep(1000)
                        ControlSetText("MyProgress", "", "Static1", "rotating slash found")
            beep(5000,200)
            sleep(1000)
            StdinWrite($CHILDDOS, "cmd?{enter}")
            StdinWrite($CHILDDOS)
            beep(5000,200)
            sleep(200)
            beep(5000,200)
            
        Case StringInStr($Status, "command line initiate")
            sleep(1000)
            ControlSetText("MyProgress", "", "Static1", "Command line initiated")
            sleep(1000)
            
        Case StringInStr($Status, "Starting_2")
            sleep(1000)
            ControlSetText("MyProgress", "", "Static1", "Now installing program 2")
            
        Case StringInStr($Status, "Done_2")
            sleep(1000)
            ControlSetText("MyProgress", "", "Static1", "Done install 2")
            
        Case Else
            beep(2000,500)
            
    EndSelect
    
WEnd

SplashOff()

This seemed to work, only when i disconnected the device from the serial port, the program still runs the same, there is no output whatsoever but the Select Case Endselect always does the same: First, the statement under 'Case Else' is executed, then the statements under 'Case StringInStr($Status, "|")', and the the statement under 'Case Else' again..

Have i programmed the Select Case Endselect wrong? Or did i miss something out? What seems to be the problem here? Anybody got a clue?

Finally, i tried using ShellExecute() :

Same code as option 2 but i used:

$CHILDDOS = ShellExecute("test.bat", "", @scriptdir, "open")
instead of
$CHILDDOS = Run(@ComSpec & ' /k "' & @ScriptDir & '\test.bat"', @ScriptDir, @SW_MINIMIZE, $STDIN_CHILD + $STDOUT_CHILD)

This time, i can see the program's output on screen in the dos-box, i can see the device connected to the serial port sending characters to the screen but when the rotating slash is being displayed, nothing is happening.. It just keeps on running without my script responding to any of the data..

Can you feel my frustration? Or have i missed some crucial details in my code? I would really, really, really make this work but i'm starting to believe that what i want isn't possible at all using autoitscript...

I've been searching the forum for anything that could help me solve this problem (challenge) but so far this is all i could find.. Please help me, i'm really close to desperate now.. :whistle:

Share this post


Link to post
Share on other sites

Someone, anyone? I know autoit and dos don't get along very well but there must be some answer to my question? Anybody who has experience with this kind of situations?

Share this post


Link to post
Share on other sites

is there really no-one who can help me? Nobody what so ever who has experience with this?

If it isn't possible at all (what i want) just tell me..

Share this post


Link to post
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
Sign in to follow this  
Followers 0