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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture Remote Device Text 1

Status
Not open for further replies.

flea333

Technical User
Sep 4, 2003
47
US
I am connected to a device on a com port that has its own program to respond to commands through Procomm or equivalent. I want to capture the replied text into a string. So when I type a certain command I can find out the current settings on the device I'm connected to. I use TRANSMIT to send commands, but how do I read the response?

Lee
 
You can use rget (likely you will need to call this command twice, with the second execution getting the received string) to retrieve this information from the port. Note that this will cause the information to not appear on screen. Other options if the expected response is constant is waitfor or when target.


aspect@aspectscripting.com
 
For some reason it is only capturing the first word returned. I type 'key' and it returns 'key off', but the rget is only getting key.
 
The key is probably coming from what you typed. Try issuing another rget command and see if that attempt has the string you are looking for. By default, rget terminates when it receives a carriage return, so it is likely seeing the echo of your command and keying off that instead of the following response from the other computer.


aspect@aspectscripting.com
 
I don't see another way around it. This is my code:

TRANSMIT "Key^M"
rget cKey
usermsg cKey

usermsg just reports 'Key.' I don't see why rget would just be getting the command.
 
Add another rget cKey after the first rget command and see what the usermsg command reports then. I imagine it will have the string you are looking for. If not, try adding a third rget in case the other computer is echoing back additional carriage returns.


aspect@aspectscripting.com
 
Indeed it works. I guess the first rget was getting my entered command, the second gets the reply. Actually I did make this nice little script to get the response as well:

pause 1
row1 = $ROW
col1 = $COL
row = $ROW - 2
col = $COL - 5
locate row col ;move cursor to response
termreads cKey 7 ;read line
strtok token cKey " " 2 ;grab the second word
if strcmp token "Off" ;see if Key is off
key = "On"
nkey = 1
dlgupdate 0 10 ;make sure you update button text
else
key = "Off"
nkey = 0
dlgupdate 0 10
endif
locate row1 col1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top