|
|
View previous topic :: View next topic |
Author |
Message |
lecutus
Joined: 12 Aug 2009 Posts: 40
|
What does int filthit:3 mean? |
Posted: Tue Mar 02, 2010 4:51 pm |
|
|
What does int filthit:3 mean?
I was doing some code testing and wanted to see what the CANbus was bringing in. So looking at examples, I decided to check what the rxstat had in it.
rxstat is define as using the struct rx_stat.
Code: |
struct rx_stat {
int1 err_ovfl;
int filthit:3;
int1 buffer;
int1 rtr;
int1 ext;
int1 inv;
};
|
I asked the question like this:
Code: |
printf("\r\nGOT: BUFF=%U ID=%LU LEN=%U OVF=%U ", rxstat.buffer, rx_id, rx_len, rxstat.err_ovfl);
printf("FILT=%U RTR=%U EXT=%U INV=%U", rxstat.filthit, rxstat.rtr, rxstat.ext, rxstat.inv);
|
I got a "error 57 , Expecting structure/union"
The offending portion was:
rxstat.buffer
and
rxstat.buffer
The above example is from EX_CAN.c
So a two fold question:
What does int filthit:3 mean? and Why does rxstat.buffer throw an error?
Thanks L. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
lecutus
Joined: 12 Aug 2009 Posts: 40
|
|
Posted: Wed Mar 03, 2010 10:29 am |
|
|
Thanks I have the first part of my question answered. Now for the second part.
I got a "error 57 , Expecting structure/union" twice, concerning rxstat.buffer and rxstat.filthit.
The code I used was from one of the examples sent with the compiler, EX_CAN.c, just a cut and paste.
Quote: |
if(can_getd(rx_id, &buffer[0], rx_len, rxstat)) //...then get data from buffer
{
printf("\r\nGOT: BUFF=%U ID=%LU LEN=%U OVF=%U ", rxstat.buffer, rx_id, rx_len, rxstat.err_ovfl);
printf("FILT=%U RTR=%U EXT=%U INV=%U", rxstat.filthit, rxstat.rtr, rxstat.ext, rxstat.inv);
printf("\r\n DATA = ");
for (i=0;i<rx_len;i++)
{
printf("%X ",buffer[i]);
}
printf("\r\n");
}
else
{
printf("\r\nFAIL on GETD\r\n");
|
I did do the #include <can-18xxx8.c>. I checked the spelling of structure type and the variable that took the structure type.
So what am I missing.
Thanks
L. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 03, 2010 12:48 pm |
|
|
Post your PIC and your compiler version. |
|
|
lecutus
Joined: 12 Aug 2009 Posts: 40
|
|
Posted: Thu Mar 04, 2010 8:12 am |
|
|
Sorry, I forgot the protocol.
I'm using PIC18F258 with PCWHD 4.079
For the record I have :
Code: |
int buffer[8],rx_len,rxstat;
|
As an observation, does using can_getd implicitly make rxstat a structure if used like this:
Code: |
int1 can_getd(int32 & id, int * data, int & len, struct rx_stat & stat)
|
Or should rx_stat be declared as a structure before use?
L. |
|
|
Ttelmah Guest
|
|
Posted: Thu Mar 04, 2010 9:28 am |
|
|
No.
The declaration shown, for can_getd, has no effect at all on 'rxstat'. It makes the _pointer_ passed to the function, into a pointer to a structure of type rx_stat. Inside the function you can then access the parts using:
stat->filthit
for example, but not using the '.' notation, unless you dereference the pointer (*).
It sounds like this is where your problem actually lies....
Best Wishes |
|
|
lecutus
Joined: 12 Aug 2009 Posts: 40
|
|
Posted: Thu Mar 04, 2010 1:14 pm |
|
|
Thanks
I wish they would have mentioned that in the example. |
|
|
Ttelmah Guest
|
|
Posted: Thu Mar 04, 2010 3:11 pm |
|
|
That is standard C.....
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|