How send special character like "

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

Hi.

I use AVR and codevision compiler.

I want send this string: 

putsf( "AT^SYSCFGEX="0201",3FFFFFFF,1,2,7FFFFFFFFFFFFFFF,, \r\n" );

it is a easy way to do it ?

Thank you

Thierry Pottier

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

Use escape notation: \x22 = quote character (pretty sure that is the right code and the correct syntax - please check it for yourself).

 

Jim

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

Last Edited: Thu. Jul 6, 2017 - 08:07 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thank you.

compiler happy no error message.. will try ...

 

Thierry Pottier

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

TPE wrote:
will try ...
Won't work for the first ", because the following characters are also valid hex characters. Either use the octal notation or simply \".

Stefan Ernst

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

TPE wrote:
putsf( "AT^SYSCFGEX="0201",3FFFFFFF,1,2,7FFFFFFFFFFFFFFF,, \r\n" );

 

try this:

 

putsf( "AT^SYSCFGEX=\"0201\",3FFFFFFF,1,2,7FFFFFFFFFFFFFFF,, \r\n" );

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

sternst wrote:
Won't work for the first ", because the following characters are also valid hex characters. Either use the octal notation or simply \".

 

Haven't we just been here recently? ;)  Like "deja vu all over again", to quote Yogi Berra.

 

At least one reference says

\xnn \xnn arbitrary hexadecimal value byte nn

...implying exactly two hexits.  Isn't \u for "extended" bytes?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

theusch wrote:
...implying exactly two hexits.
The C standard says:

EXAMPLE 3 Even if eight bits are used for objects that have type char, the construction '\x123'
specifies an integer character constant containing only one character, since a hexadecimal escape sequence
is terminated only by a non-hexadecimal character. To specify an integer character constant containing the
two characters whose values are '\x12' and '3', the construction '\0223' may be used, since an octal
escape sequence is terminated after three octal digits. (The value of this two-character integer character
constant is implementation-defined.)

 

Edit: just done a quick test:

#include <avr/io.h>
#include <string.h>

char str[] = "\x1234567890abcdef";

volatile uint8_t a, b;

int main (void) {
	
	a = strlen(str);
	b = str[0];

	while(1);
}

a = 1

b = 239 (0xef)

And you get the warning "hex escape sequence out of range".

Stefan Ernst

Last Edited: Thu. Jul 6, 2017 - 10:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:
Haven't we just been here recently? ;)  Like "deja vu all over again"

 

You mean this: https://www.avrfreaks.net/comment... ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, I started that earlier one just a few days ago. The one that awneil referenced :) So, its not very far back. 

 

Jim

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

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

Actually, that one was by Fianawarrior.

 

Are you thinking of this: https://www.avrfreaks.net/forum/cc-character-literals ?

 

 

 

There was another a while back with someone getting the quotes (among other things) in AT Commands wrong: https://www.avrfreaks.net/comment...

 

Anyhow, here's the list of standard 'C' escape sequences again: https://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences (should also be in any 'C' textbook)

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've moaned often about the way \xNN (or rather \xNNNNNNNNNN....) works in the past. It's bitten me a few times when the "word" that follows the \xNN starts with characters in the range A..F and they get "eaten" by the escape sequence. Don't know what others do to confound this but:

"\x1BAbsolutely"

is probably best written as:

"\x1B" "Absolutely"

(implicit string concatenation) So it really does encode 0x1B and not 0xAB (and then deliver "solutely").

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

clawson wrote:
what others do

 

I would probably

#define ASCII_ESC "\x1B"

and use it as

ASCII_ESC "Absolutely"

being equivalent to your example.

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...