Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

capture & rget & waitfor 2

Status
Not open for further replies.

ToddWW

Programmer
Mar 25, 2001
1,073
US
I use the following script to send a command to the host and capture the response in a text file. In addition, I use the waitfor command to determine when the response string is finished. The response string always terminates with a ^C
Code:
set capture file "myfile.txt"
capture on
transmit "200^M"
waitfor "^C" 10
if failure
  call processfail
endif
I've been using this for years and it has been working great with speeds from 1200 to 9600 baud. Now, I want to strip the first 5 characters from the response because I don't want those characters to be displayed in the log file.
This is what I have tried with limited success.
Code:
set capture file "myfile.txt"
capture on
transmit "200^M"
rget 5
waitfor "^C" 10
if failure
  call processfail
endif
The rget works fine. It strips the first 5 characters from the response string. The problem is that when I am communicating at higher speeds such as 9600, the waitfor command times out. Even though the ^C character is received. It seems like by the time the rget command releases to the next waitfor statement, the ^C character has already been received so the waitfor command times out. I tried using the set rxdata on and still, the waitfor command times out. Here is what my latest script looks like.
Code:
set capture file "myfile.txt"
capture on
set aspect rxdata on
transmit "600^M"
rget 5
set aspect rxdata off
waitfor "^C" 10
if failure
  call processfail
endif
Can anyone help me accomplish this. I need to strip the first 5 characters off of the response string but I want the following waitfor statement to start looking at the 6th character.

I appreciate your help.

ToddWW
 
According to the help file, the waitfor command will not work properly if set aspect rxdata is on. I'm not sure if having your script turn it off just before the waitfor will work or not, so that may be why your last script is not working as expected.

I would try using Procomm's Monitor Window with your "middle" script and see if the data is being received as you expect. I'm wondering if, due to the high speed, the sent and received data are mixing a bit, such that the rget command is getting different data than you think it is. Here is some more information on how to use the Monitor Window:

Procomm's Monitor Window can be used to view the incoming and outgoing data, in both hex and ASCII format. To activate this window, select the Data | Monitor Window menu item. Resize the Monitor Window so that you can view the entire width of the window, then click back in the Procomm Plus window so that the Monitor Window does not have focus. Incoming text is displayed in red, while text you send is colored blue. The Monitor Window can be handy for viewing incoming escape sequences (to determine if Procomm Plus is responding properly to them) or to verify that the program is sending the data you think it should be.

One possible alternative that I can think of is using the set aspect rgetchar command to have rget key off the ^C, use rget to read the entire line, use strdelete to get rid of the first five characters, and use termwrites or capturestr to get the modified string into the capture file.


aspect@aspectscripting.com
 
I really appreciate your response. Your last suggestion was what I was thinking and it looks like it will be the most solid solution.

Thanks again.

Todd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top