Do popular terminal emulators send strings or char arrays?

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ie: Do they NULL terminate the character arrays?

By 'popular', I mean Hyperterminal and TeraTerm.

I am reading characters until I encounter '\0', and want to make sure this actually happens.

char * USART_Rx_str(char * FirstByte)
{
	char * LastByte = FirstByte;
	
	do {
		while ((UCSRA & (1 << RXC)) == 0) {};
		*LastByte = UDR;
	} while (*(LastByte++) != '\0');

	return LastByte;
}

I realize this doesn't check to see if it is writing into unallocated memory :P . Will have to look into that!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Depends on the terminal emulator program.

Most will send one Byte, (char) at a time. If you tic the box it will save them up and send them all at once when you hit "Enter".

You can have them include a Carraige Return or Carraige Return and Line Feed, when you hit Enter if you so desire.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No, terminal programs just send streams of characters, a null would not be sent unless it was deliberately part of the stream. The terminal programs are character based, not block based. So there is no need for a terminator.

The null terminator you are talking about is a C construct [other languages use it too] it is not a serial ascii transport concept. Unless some higher level transport is using it, but most ASCII protocols [ANSI/VT-100] do not use it.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks. :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In fact, most of the algorithms for sending a string of characters from a micro tests the character for a null, if not send it and increment the index/pointer. Thus, the micro will send all the characters UP TO and not including the null.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net