Beginners Question about Tera Term Macro
Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: Beginners Question about Tera Term Macro
PostPosted: Thu Dec 09, 2010 4:06 pm 
Offline
Newbie

Joined: Thu Dec 09, 2010 3:29 pm
Posts: 8
Hello,

I'm a Teraterm newcomer and I have the following questions please.

1. How can I use waitrecv to match the sequence "C" and $0D ? ($43 $0D)
I tried waitrecv "C#$0D" 2 2 but without success.
Is there something like "C"+#$0D ?

I can use it successfully with a pure ASCII string.

2. What is the delimiter of line in case of recvln for example?

3. Is it possible anyhow, to terminate macro execution by a simple mouse click, but
without stopping macro execution before? I try to explain what I mean.
I'm trying to simulate a serial port communication which constantly sends data which
must be processed. The process runs in a loop.
To be able to terminate the entire macro I could use a yesnobox, but then I
have to click to the box any time the box is called, even if I don't want to leave the macro.
With other words , is there a box or something else which is visible on the screen and does
nothing until there is a click to that item ?

Thank you for your help.

Regards
Robert


Top
 Profile E-mail  
 
 Post subject: Re: Beginners Question about Tera Term Macro
PostPosted: Fri Dec 10, 2010 4:54 am 
Offline
Guru

Joined: Wed Jul 26, 2006 4:47 am
Posts: 412
Location: UK
Hi

1.
waitrecv "C"#$0D

2.
line feed (10 or 0x0A) I think . It could be carriage return and line feed (0x0A 0x0D). Should be easy to do an experiment to find out.

3.
If I understand correctly then I'm not aware of a way to do this.

Regards
Trevor


Top
 Profile E-mail  
 
 Post subject: Re: Beginners Question about Tera Term Macro
PostPosted: Fri Dec 10, 2010 1:13 pm 
Offline
Moderator, LogMeTT and TTLEditor developer
User avatar

Joined: Sat Jan 08, 2005 10:52 am
Posts: 1408
Location: Seattle, USA
You can find the entire ASCII table on our site http://logmett.com/index.php?/quick-tip ... table.html

_________________
Thanks.
Best regards,
Boris


Top
 Profile  
 
 Post subject: Re: Beginners Question about Tera Term Macro
PostPosted: Fri Dec 10, 2010 1:45 pm 
Offline
Newbie

Joined: Thu Dec 09, 2010 3:29 pm
Posts: 8
Thank you very much for your answer.

Unfortunately waitrecv "C"#$0D does still not work.

I checked

waitrecv "C" 1 1 -------> it's ok.
waitrecv #$43 1 1 ----> it's ok.

but

waitrecv #$0D 1 1 ----> it's not ok

I'm absolutely sure that I get 0x43 0x0D all the time.

Do you possibly have another idea I could check ?

Thank you.

Robert


Top
 Profile E-mail  
 
 Post subject: Re: Beginners Question about Tera Term Macro
PostPosted: Fri Dec 10, 2010 1:55 pm 
Offline
Newbie

Joined: Thu Dec 09, 2010 3:29 pm
Posts: 8
Hi,

I guess I do not have a problem with the ASCII code.
Or do I miss anything ?

I read the TT help and found also a good table there .

The problem I have is to find the right syntax for several
macro commands.

Thanks for your answer anyway.

Robert


Top
 Profile E-mail  
 
 Post subject: Re: Beginners Question about Tera Term Macro
PostPosted: Fri Dec 10, 2010 2:05 pm 
Offline
Guru

Joined: Wed Jul 26, 2006 4:47 am
Posts: 412
Location: UK
Hi Robert,
I think there is a problem with some commands detecting non printable characters. I got round this in the past by entering debug mode and waiting for the appropriate string that way. See setdebug command here:

http://ttssh2.sourceforge.jp/manual/en/macro/command/setdebug.html

Can you tell me a little more about what you are trying to do and I will knock something together?

Regards
Trevor


Top
 Profile E-mail  
 
 Post subject: Re: Beginners Question about Tera Term Macro
PostPosted: Fri Dec 10, 2010 2:50 pm 
Offline
Newbie

Joined: Thu Dec 09, 2010 3:29 pm
Posts: 8
Hi Trevor,

I really appreciate your help and your effort.

What I want to do is a rather simple task.

I would like to wait for a sequence coming via a RS232 port. After the
sequence has been recognized , I just would like send another sequence back .

The sequences I would like to check look like the following examples:

"C" 0x0D -----------> (0x43 0x0D)
"AI1;" -------------> (is already working using waitrecv "AI1;" 4 1)
0x02 "A?" 0x0D --> (0x02 0x41 0x2F 0x0D)


This is an already working example :

  1.  
  2. ...
  3. :looppol
  4.    call incrangle
  5.    call stboxpol
  6.    waitrecv "AI1;" 4 1
  7.    call sendmessage
  8.    goto looppol
  9. ...
  10.  


Would be nice if you could guide me to a solution which does the job using
partly non printable characters. Must not be waitrecv. But as a newbie, I'm not that
familiar with all possibilities of that powerful macro language, so I took the
next best command I found.

Thank you again.

Robert


Top
 Profile E-mail  
 
 Post subject: Re: Beginners Question about Tera Term Macro
PostPosted: Sun Dec 12, 2010 1:40 pm 
Offline
Newbie

Joined: Tue Aug 18, 2009 1:18 am
Posts: 9
I always flush my receive buffer prior to a wait command.

example:
:looppol
call incrangle
call stboxpol
timeout = 5 ; 5 seconds timeout on wait command
flushrecv ; Flush receive buffer
wait #10 'C' #13 ; or you could try Waitln 'C'
if result = 0 goto error
call sendmessage
goto looppol
:Error
Messagebox 'Error' 'Timeout Occurred'


Top
 Profile E-mail  
 
 Post subject: Re: Beginners Question about Tera Term Macro
PostPosted: Sun Dec 12, 2010 3:39 pm 
Offline
Newbie

Joined: Thu Dec 09, 2010 3:29 pm
Posts: 8
Thanks for the proposal.

Unfortunately it does not work at all. Neither wait nor waitln
with different formats of the "string" will be accepted by TT or works
as expected.

Thanks anyway.


Top
 Profile E-mail  
 
 Post subject: Re: Beginners Question about Tera Term Macro
PostPosted: Tue Dec 14, 2010 2:40 am 
Offline
Newbie

Joined: Tue Aug 18, 2009 1:18 am
Posts: 9
1.) Priority one - Make sure you flush the receive buffer.
2.) Set Sync =1
3.) Use Debug mode to check your code.
4.) I had an issue once where I thought I was getting a carriage return #13(0d) at the end of text received. I sniffed the RS232 line and found I was wrong. So I used the following command.
Wait #10 'C'
and everything worked.
5.) You could try using the hex value ?
6.) You can use either hardware of Software my favorite is WireShark to Sniff your RS-232 port.
I have written alot of communication code (Xtalk, Procomm, TeraTerm) and found Debug mode and some type of Sniffing of RS232 Port can save you a lot of headaches.
By far the best communication program I have used to date is TeraTerm!

Try Wait #10 'C' see if this works?


Top
 Profile E-mail  
 
 Post subject: Re: Beginners Question about Tera Term Macro
PostPosted: Wed Dec 15, 2010 2:53 pm 
Offline
Newbie

Joined: Thu Dec 09, 2010 3:29 pm
Posts: 8
Hi,

Thanks for your effort to help me. I appreciate it very much.

Unfortunately your proposals were not successful.

1.) 2.) 3.)

  1.  
  2. ....   
  3.      setsync  1
  4. ....
  5.       flushrecv
  6.       setdebug 1
  7.       waitrecv #$43#$0D 2 1  
  8.       setdebug 0
  9.      ....
  10.  


No success.

There must be something wrong with setdebug 2 anyway. It prevents working of macro

  1. waitrecv #$43 1 1


If setdebug 1 is used it works (strange!).

4.) 5.) 6.) I can confirm that 0x43 0x0D is send. I saw it using setdebug 2 and I know it
anyway, because the code comes from a little MC board I made the SW by myself.

I'm slowly getting lost using the TTL Macro .

Any further idea ?

Thanks again.

Robert


Top
 Profile E-mail  
 
 Post subject: Re: Beginners Question about Tera Term Macro
PostPosted: Wed Dec 15, 2010 3:34 pm 
Offline
Guru

Joined: Wed Jul 26, 2006 4:47 am
Posts: 412
Location: UK
Hi Robert,
You have to detect the data in a different format when setdebug is set.

for setdebug = 2
  1. waitrecv '43 0D'  2 1

Every byte is shown in hexadecimal


for setdebug = 1
  1. waitrecv 'C^M' 2 1

In this mode non printable characters are shown as control keys e.g. ^A = 1, ^B = 2 etc.


for setdebug = 0
  1. waitrecv 'C'#13 2 1

which we think might not work from your earlier experiments.

This post touched this subject. http://logmett.com/forum/viewtopic.php?f=3&t=1478&p=5235&hilit=setdebug#p5235

Regards
Trevor


Last edited by Trevor on Wed Dec 15, 2010 5:01 pm, edited 1 time in total.

Top
 Profile E-mail  
 
 Post subject: Re: Beginners Question about Tera Term Macro
PostPosted: Wed Dec 15, 2010 4:54 pm 
Offline
Newbie

Joined: Thu Dec 09, 2010 3:29 pm
Posts: 8
Trevor,

Thank you for the explanations. I see that the characters seem to be translated
first and then compared anyhow. Not just displayed in a different format.
I removed all debug settings.

Then I checked again 'C'#13 and 'C'#$0D and #$43#$0D, but nothing matched the
stream.

Robert


Top
 Profile E-mail  
 
 Post subject: Re: Beginners Question about Tera Term Macro
PostPosted: Thu Dec 16, 2010 7:23 am 
Offline
Guru

Joined: Wed Jul 26, 2006 4:47 am
Posts: 412
Location: UK
but we know with debug off there is a problem with waitrecv and strngs with CR/LF so can you try with debug on? Something like this


  1. setdebug 1
  2. waitrecv 'C^M' 2 1 ; might need to change "2 1" to "3 1"
  3. sprintf "waitrecv 'C^M' 2 1 = %d" result
  4. messagebox inputstr 'Test'
  5. setdebug 0


OR
  1. setdebug 2
  2. waitrecv '43 0D'  2 1 ; might need to change "2 1" to "5 1"
  3. sprintf "waitrecv '43 0D'  2 1 = %d" result
  4. messagebox inputstr 'Test'
  5. setdebug 0


Regards
Trevor


Top
 Profile E-mail  
 
 Post subject: Re: Beginners Question about Tera Term Macro
PostPosted: Thu Dec 16, 2010 12:11 pm 
Offline
Newbie

Joined: Thu Dec 09, 2010 3:29 pm
Posts: 8
Trevor,

It works!.

Both proposals do the job.

I'll use setdebug 2 for the other sequences I need. I can live with it, provided
there are no other consequences I'm currently not aware of.

Thank you very much for your assistance. I really learned a lot!

Robert


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group