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!

Echo Received Characters 1

Status
Not open for further replies.

zugos

Programmer
Jul 7, 2008
7
US
Hi,

I am looking for aspect script that would wait for any characters and echo them back to sender.

Thank you,
Zugos
 
Are you wanting to echo characters as they are received or when a full line of data has been received? If the latter, rget would probably work best (might need to tweak some of the settings for that command depending on the system you are working with). The transmit command would be used to resend the characters.

 
When full line of data received. I created something like:

set aspect RXDATA ON
while $RXDATA
rget Msg 30
if SUCCESS
termwrites Msg
transmit Msg
transmit "^M^J"
pause 3
endif
endwhile

I haven't test it yet but hoping that it works. My other question is if the user sends Carriage return line feed at the end of the message do I have to handle that differently?

Thank you.
 
You can use the set ASPECT rgetchar command with the STRIP keyword to detect the end of a line using either the carriage return or the linefeed command. However, you can only specify one or the other with this command since only one rgetchar can be specified. What I would do in that case is key off the linefeed if it is the last character in the string sent by the other system, and then use:

strreplace sVar "`r" ""

to delete any carriage returns from the received string.

 
OK I finally started testing the script where I am sending a message from a device and the script should echo the message back to me but sometimes I get the message and other times I don't unless I send another message.

I can't seem to find the problem. I tried different things but didn't work out. Do you guys see anything wrong with this script? Thank you.

while $CARRIER
capture on
yield
set ASPECT rgetchar 10 STRIP
strreplace Msg "`r" ""
rget Msg QUITETIMER
transmit Msg
transmit "^M^J"
pause 3
endwhile
 
Hi,

After working on my other projects, I came back to this project again and can't seem to get it working. It echos the message intermittently. Here is the part that suppose to echo the message:

while $CARRIER
capture on
yield
rget Msg 50
set ASPECT rgetchar 10 STRIP
strreplace Msg "`r" ""
transmit Msg
transmit "^M^J"
pause 3
endwhile

 
Ok. I got it working I had add two rget commands to capture the data properly.

while $CARRIER
capture on
yield
set aspect RXDATA ON
rget Msg
rget Msg
set aspect RXDATA OFF
strreplace Msg "`r" ""
transmit Msg
transmit "^M^J"
pause 3
endwhile

I only have one problem now. I want to stop and start the script after 30 seconds. Is there a command to stop and start the script?

Thank you.
 
When you say start the script, do you mean launch Procomm and run the script, or have another script launch it for you?

As for stopping the script, you can use either the exit or halt command (they act a bit differently, depending on if there was a parent script that called the executing script), or you can use the pwexit command which closes down the script and shuts down Procomm as well.


 
Thank you for your response.

I thought that there is way to stop and start the script automatically. But now I understand that once I stop the script I cannot started it again unless I create another script that will launch it for me, which I really don't want to do. Let me try to explain the problem that I am having maybe there is another way.

I have script that opens a connection with a modem, which waits for a ring. Another user calls the modem and starts sending messages. The modem echoes the message back confirming that it received it. If there is no activity for 30 seconds I want to reset everything and restart the modem connection. I am doing this now by using clear command and sending disconnect command to modem. But when I start the modem the terminal screen is blank and I don't see the initialization string and OK message unless I manually stop and start the script. Basically whatever stop/start button is doing, I would like do it automatically thru the script. Is there a way do that? Or do I need to write another script to start? If I do what is the command to start the script?

Thank you again.
 
Sorry I wasn't able to get back to this sooner.

Is your script on the dialing side or is it on the end receiving the phone calls? It sounds like the latter. Are you using modem command mode in your script? If so, that command only "works" once and has to be reset before each modem connection attempt, although there is a modification that can be made to a Procomm configuration file to change this behavior. I wonder if that might be what you are seeing a symptom of.

I think probably the best way to do this is to have a subprocedure in your script that does all the work and is called by the main procedure on the necessary time schedule.

 
Thank you for your response. I am on the receiving end.

I solved the problem for now by creating two scripts where one script halts itself and the other script starts it. Everything seems the be working fine now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top