Getting Long Data

How do you get a Long (signed or not) from the FRC to you?

I’m currently using printf() in a way so that, basically:

void printl(long Num)
{
 //Print Bytes
 printf("Long %d %d %d %d
", (int)(Num>>24)&0xFF, (int)(Num>>16)&0xFF, 
     (int)(Num>>8)&0xFF, (int)Num&0xFF);
 
 //Print Words
   printf("Long %d %d
", (int)(Num>>16)&0xFFFF, (int)Num&0xFFFF);
}

The problem is that the thing seems to want to increment higher sections to soon. In a pattern.

...
0 0 0 8
0 0 1 9
...
0 0 1 16
0 1 1 17
...

:confused:
(or:

...
0 8
1 9
...

) :confused:

The other option is to use 4 user bytes. but we only have 6. well, 4 User + 2 LED + 1 UserCmd.

Can anyone offer suggestions? This little bug really affects results. (bland understatement)

The problem is that you’re printing out each byte of the long as a base-10 number. Try using %x instead of %d. That way, you’ll get the right numbers out, but they’ll be in hex. If you want it in decimal, your best bet is to modify printf_lib.c (specifically the printi function) to accept long arguments.

I just put some routines here /t/printf-bug-beware/51489/1 that do this.

You can just call the one routine that prints decimals without changing any of your own printfs.