How do I watch an array as ASCII values, not hex or decimal

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

Folks,

 

Is there a way in Studio to look at the values in an array as ASCII values rather than binary values? Usually you can just pick it in the column select, but in Studio, I can only find ways to see it as hex or dec.

 

Actually, while I'm on, is there not a way to have some watches as dec and some as hex? It's a proper ****ache having to continually switch between the two depending on what you're wanting to see.

 

Many thanks.

 

 

Last Edited: Fri. Apr 24, 2020 - 10:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What type does the array have? If its a char[] then it should just work.
.
Studio also has a set of expression formatters to change views, if the underlying type allows that: https://onlinedocs.microchip.com/pr/GUID-ECD8A826-B1DA-44FC-BE0B-5A53418A47BD-en-US-4.1.1/GUID-C129AC8E-1916-4EEF-9FD6-232D166BB344.html

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

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

It's an array of uint8_t. In, say, Crossworks, you simply right click on  either the array if you want everything in the array as the same format and select char so all characters in the array show their ASCII value. You could select binary, or decimal or hex etc and everything would be displayed as that format. If you only wanted one of them as char, but the rest to remain as hex, you can right click an  indviidual entry in the array and only that will change. I don't have to change the source code. It's the same in Qt creator and am pretty sure it's the same in Keil and IAR. Even the Eclipse does that I think.

 

In Atmel Studio, when you right select between hex and decimal *all* variables change between the formats in the watches, which is hugely inconvenient as there are often values you want to see as hex and others asdecimal.

 

What i would like is to be able to select a value in the watch window and have it shown as ASCII, decimal, hex (and even string sometimes is useful). In Crossworks you can also have an array displayed as a string rather than an array of ASCII chars. 

 

I would stress, I don't want to have to change the source code of it to be an array of chars, I want it to be an array of uint8_t in the source code and have the option in AS to show that array in different formats. I appreciate it might not be possible, but I am pretty sure it would be the first time I'd found an IDE that can't do that.

 

I did look at the link above and don't understand at all how you would actually use those modifiers. I'm guessing you have to use them somehow in the source code? Something I really don't want ot have to do.

 

I' om version 7 of studio FWIW.

 

Thanks. :)

 

Last Edited: Sat. Apr 25, 2020 - 08:14 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In the watch window, cast the watch (like in C) to a char[] then.
.
The watch window features a c expression interpreter, so nothing of what I showed is source code, everything is just added to the watch .

I.e, if ptr is a uint8*, but you put chars in it, then for studio to show the char array, add a watch for (char[])ptr.
.
If you want to watch it as a string and not a array of chars, use a format specifier and watch (char[])ptr,s
.
Also search around here a bit for this, I've shown it multiple times.

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

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

Sorry to be a pain, but I'm just not getting this at all.

 

I have an array BootloaderRx[BOOTLOADER_MAX_ARRAY_SIZE]  of uint8_t, which I can see in the watch Window, but no matter what I do, like BootloaderRx,x, (char[]),BootloaderRx etc etc etc is resolutely stays as decimal, unless I right click and select hex. The only thing I can do is (char *)BootloaderRx which turns it into a string, but that's no use because the string's too big, and even if you could  resize the windows on this program, the HTML received data as a string would be far too  big to show!

 

Also, I can't see any way to set some values within a structure to be different to each other. You only seem to be able to set the type of data at the structure name level, not the members of the structure.

Last Edited: Mon. Apr 27, 2020 - 11:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can I give a nudge on this please? My main issue here is getting an array of uint8_t to show as ASCII chars, not hex on dec. Thanks. :)

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


:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

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

DiBosco wrote:
getting an array of uint8_t to show as ASCII chars

Debugger aside, If the data is ASCII text, why are you not defining the array as 'char' ?

 

That's what 'char' is for!

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

Thanks I'll give that a go  meolsen. I'd tried ,c but it wasn't obvious [to me] that you had to put ,c,8. 

 

awneil wrote:

DiBosco wrote:

getting an array of uint8_t to show as ASCII chars

 

Debugger aside, If the data is ASCII text, why are you not defining the array as 'char' ?

 

That's what 'char' is for!

 

Oh, I dunno,  because the library I'm calling wants uint8_t passed to it?

 

 

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

This still doesn't work for me. If I put ,c,8 after BootloaderReceivedData to give BootloaderReceivedData,c,8 in the watch window, it tells me "could not evaluate".

 

If I just have ,c after the array name it comes out as decimal.

 

 

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

Maybe time to show a minimal code example that fails then, given that I've shown how it works..?

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

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

 

Sorry for the delay. Been busy doing non-ASCII stuff.

 

So, there is a line:

 

strncpy(sparams.cafile, NETWORK_SERVER_ROOT_CA_FILENAME, sizeof(NETWORK_SERVER_ROOT_CA_FILENAME));

 

sparams.cafile is an array of, in this case, chars and we're putting a #defined string into it.

 

 

It's the same whatever I try. whatever type of array. If I do. Here is a test array of uint8_T:

 

 

WhicI simply filled with 65 to 74 and should show A-I. I've tried brackets around TestArray, TestArray,c, TestArray,c,8 - none work. (char *) sometimes makes Studio hang!

 

I filled it like so:

 

	for (i=0;i<10;i++)
		TestArray[i] = (65 + i);

 

 

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

If you add a ,c you'll get an array of chars from that... 

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

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


Assuming you mean like below, it's still not working for me.

 

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

What device would this be for?

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

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

meolsen wrote:

What device would this be for?

 

SAM4C32C

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

Are you thinking there might be a bug for this processor?

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

No, but the debuggers are different.. However I don't have any SAMs available to me at the moment to check... 

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.