end of string characher
Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: end of string characher
PostPosted: Fri Nov 27, 2009 7:07 am 
Offline
Newbie

Joined: Fri Nov 27, 2009 7:02 am
Posts: 3
Hello to all,

this is my first post on this forum, maybe the answer to my question is in the old topics, but i haven't been able to find it anywhere. By the way, I start using macros, so I am quite a newbie...!

I am communicating from teraterm through serial rs232 to a microcontroller. I need to send messages to the microcontroller.
My question is, when I use the "send" command, does it automatically add the "end of string" or "null" character to the string? I guess no, because the microcontroller does not detect it. In that case, how could I add the null character to the end of the string?

Thanks very much in advance


Top
 Profile E-mail  
 
 Post subject: Re: end of string characher
PostPosted: Fri Nov 27, 2009 9:19 am 
Offline
Moderator, LogMeTT developer
User avatar

Joined: Sat Jan 08, 2005 7:52 am
Posts: 1143
Location: Seattle, WA, USA
sendln sends the string followed by end-of-line characters.

As for sending 0 (zero), I don't think it is possible because 0 is string terminator in C programming language (TeraTerm is written on C).
Still, try this and let us know if it works:
  1. send #0

_________________
Thanks.
Best regards,
// Boris


Top
 Profile E-mail  
 
 Post subject: Re: end of string characher
PostPosted: Mon Nov 30, 2009 5:03 am 
Offline
Newbie

Joined: Fri Nov 27, 2009 7:02 am
Posts: 3
Thanks Boris,

but adding that sentence, I receive a "syntax error" when I execute the macro. I guessed that was the option, but it seems not to work.

Any other suggestion? :worriedsad:

thanks very much!


Top
 Profile E-mail  
 
 Post subject: Re: end of string characher
PostPosted: Mon Nov 30, 2009 7:42 am 
Offline
Guru

Joined: Wed Jan 25, 2006 7:28 pm
Posts: 532
Location: Denver, Colorado, USA
Try using sendln instead of just send.

Or maybe set a variable and then send it.

  1. tmp='Your_string'#0
  2. sendln tmp 


Top
 Profile  
 
 Post subject: Re: end of string characher
PostPosted: Tue Dec 01, 2009 6:59 am 
Offline
Coach

Joined: Wed Jul 26, 2006 1:47 am
Posts: 89
Tera Term does not allow you to send 0 in a string hence you can't use #0 but you can send 0 as an integer. So to send 0 just use 'send 0' e.g.

  1. send 'Your String'
  2. send 0


you can use this trick to send any byte i.e. to send binary values 1 to 10 you can do this.

  1. for i 0 10
  2.     send i
  3. next


Regards
Trevor


Top
 Profile  
 
 Post subject: Re: end of string characher
PostPosted: Wed Dec 02, 2009 2:09 am 
Offline
Newbie

Joined: Fri Nov 27, 2009 7:02 am
Posts: 3
Ok, so I guess thast sendln adds #13 to the string (kind of \n in C').

none of you solutions worked for me, as I need end-of-string, and send #0 is not allowed.

thanks very much though :smile:

any other suggestion? :oops:


Top
 Profile E-mail  
 
 Post subject: Re: end of string characher
PostPosted: Wed Dec 02, 2009 2:49 am 
Offline
Coach

Joined: Wed Jul 26, 2006 1:47 am
Posts: 89
can you explain what you mean by "none of you solutions worked for me"? Your question was "how could I add the null character to the end of the string?". Null character is binary 0 which can be sent as outlined in my example. If this is not working for you then please explain what is not working -- it works for me and has done in all versions of Tera Term.

Are you sure that your micro-controller is expecting the nul character? Is your micro-controller running a command line? If so it will be expecting a carriage return (#13) not a 0 at the end of a string.

Take a step back. Find how how it works if you do it manually by typing the data into the Tera Term window (without a Tera Term macro). Once you know what is needed the macro will be easy.

Use debug mode and local echo on to see exactly what is sent and received. Set "debug=on" in your TeraTerm ini file and then you can press shift + escape to toggle debug on or off. Search the forum and Tera Term help files for debug mode for more info.

Regarding line ends #13 is carriage return (\r in C) and #10 is line feed (\n in C). By default sendln on a serial port sends a #13 at the end of the string but this depends on your settings -- sendln can send any combination of #13 and #10 as line end.

Good luck
Regards
Trevor


Top
 Profile  
 
 Post subject: Re: end of string characher
PostPosted: Mon Jul 12, 2010 12:45 am 
Offline
Newbie

Joined: Fri Jul 09, 2010 1:40 am
Posts: 2
Trevor wrote:
Tera Term does not allow you to send 0 in a string hence you can't use #0 but you can send 0 as an integer. So to send 0 just use 'send 0' e.g.

  1. send 'Your String'
  2. send 0


you can use this trick to send any byte i.e. to send binary values 1 to 10 you can do this.

  1. for i 0 10
  2.     send i
  3. next


Regards
Trevor


Hi Trevor,
I have a similar question by sending the raw data.
I have a binary file include 8 bytes of data as below:
  1. 00 00 00 00 40 E4 00 00

And I am using the command below to send the data:
  1. sendfile file.bin 1


Now I am trying to send the content data by 'send' command, and I stock.
My new command is like below:
  1. send 0 0 0 0 $40 $E4 0 0


the problem is the code "$E4", seems the 'send' command can not send the code over the ASCII table.
Although the help told me "If sending data is an integer, its lowest-order byte (0-255) is regarded as an ASCII code of the character,..." I found the possible data can only send up to code 0x7F

I have tried as below:
  1. for i 1 255
  2. send i
  3. next


Every code goes fine from 0x01 to 0x7F, when the code become 0x80, the output becomes strange codes....

How could I send a raw data code '0xE4' through the 'send' command?
Or is it impossible? The only way is to use the 'sendfile' command to send the created raw like the original one?

Thank for your kindly reply in advance.


Top
 Profile E-mail  
 
 Post subject: Re: end of string characher
PostPosted: Mon Jul 12, 2010 4:17 am 
Offline
Coach

Joined: Wed Jul 26, 2006 1:47 am
Posts: 89
Yes I can confirm that this is a bug. See bug report I created here:

http://logmett.com/forum/viewtopic.php?f=8&t=1423

Regards
Trevor


Top
 Profile  
 
 Post subject: Re: end of string characher
PostPosted: Wed Jul 14, 2010 8:33 am 
Offline
Coach

Joined: Wed Jul 26, 2006 1:47 am
Posts: 89
Mystery solved. See bug report link above.


Top
 Profile  
 
 Post subject: Re: end of string characher
PostPosted: Wed Jul 14, 2010 6:23 pm 
Offline
Newbie

Joined: Fri Jul 09, 2010 1:40 am
Posts: 2
Trevor wrote:
Mystery solved. See bug report link above.


I have test and confirmed this solution, it work!
Feedback the way to keep the language setting: Modify the TERATERM.INI:
  1. Language=English


Thank you.


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

Who is online

Users browsing this forum: No registered users and 2 guests


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:
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group