Log in

View Full Version : PrintToScreen() function prints out hex values?


Nathan
14-01-2008, 11:36
When I use the PrintToScreen function provided in the WPI library it prints out hexadecimal values, is there any way to make it print in decimal?

This is the code I'm using:
PrintToScreen ( "%ld\n" , temp ) ;

"temp" is a long.

I thought that "%ld" was the correct value to put in for a long? What am I doing wrong?

Thanks,
Nathan

BradAMiller
14-01-2008, 18:30
When I use the PrintToScreen function provided in the WPI library it prints out hexadecimal values, is there any way to make it print in decimal?

This is the code I'm using:
PrintToScreen ( "%ld\n" , temp ) ;

"temp" is a long.

I thought that "%ld" was the correct value to put in for a long? What am I doing wrong?

Thanks,
Nathan


Nathan -

I'm at home now and don't have a controller here to test this. But if you use printf instead of PrintToScreen, I'm pretty sure that will work as advertised. I'll try to test it tomorrow sometime when I get to the office to see what's up.

Thanks,
Brad

Nathan
14-01-2008, 22:50
Thanks for the reply Brad. Earlier today I was trying this on a Vex controller, and it printed out the hex values.

I was just recently able to try it on the 2008 FRC controller and it does NOT print out the values in hex, but in the correct decimal format.

So I guess it was just the vex controller?

Thanks,
Nathan

BradAMiller
21-01-2008, 03:39
That's curious. The Vex code is identical to the FRC code, and all it does is call printf.

Here's a thought... Microchip upgraded their library at one point a few years ago and improved the printf support. It may be that you are using an older version of their library with printf on the Vex side.

You could get the source code (included with the C18 install) of the printf function and add it to your Vex project to make that work. But if you were just prototyping on Vex and the real program is working now, it may not matter.