PDA

View Full Version : Getting Long Data


Astronouth7303
03-10-2004, 02:35 PM
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\n", (int)(Num>>24)&0xFF, (int)(Num>>16)&0xFF,
(int)(Num>>8)&0xFF, (int)Num&0xFF);

//Print Words
printf("Long %d %d\n", (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)

Dave Flowerday
03-10-2004, 03:29 PM
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:
{snip}
The problem is that the thing seems to want to increment higher sections to soon. In a pattern.

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.

Mark McLeod
03-10-2004, 04:08 PM
How do you get a Long (signed or not) from the FRC to you?
I just put some routines here 26529 that do this.

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