📄 basiccan.c
字号:
/***************************************************************************
basiccan.c - description
-------------------
begin : Fri May 17 2002
copyright : (C) 2002 by Raphael Zulliger
email : zulli@hsr.ch
***************************************************************************/
/***************************************************************************
* *
* This library is Copyright (c) Raphael Zulliger <zulli@gmx.net>. *
* It is licensed under the GNU Library General Public License (LGPL). *
* *
***************************************************************************/
#include <def.h>
#include <general.h>
#include <objdict.h>
#include <canop.h>
BOOL readRxBuffer(void)
{
// because arbracan AND the PIC-CAN-C-Lib can't start an interrupt when rx
// messages are in the queue, we have to poll reading... */
Message rrb_m;
BYTE rrb_i;
BOOL returnValue = FALSE;
// go through every buffer-field and check if the field is emtpy (see next if-condition)
for( rrb_i=(BYTE)0x00; rrb_i<(BYTE)RX_CAN_BUFFER_SIZE; rrb_i++ )
{
if( canMessageRxBuffer[rrb_i].valid == FALSE )
{ // now we've found an empty field, so check if there's a message in the
// can-receive buffer of the chip...
if( canReceive( (BYTE)0x00, &rrb_m ) == (BYTE)0x00 )
{ // as long as data are in the queue and we have not tryed to fill more than available fields of
// the receive buffer...
canMessageRxBuffer[rrb_i].m.len = rrb_m.len;
canMessageRxBuffer[rrb_i].m.rtr = rrb_m.rtr;
canMessageRxBuffer[rrb_i].m.cob_id.w = rrb_m.cob_id.w;
memcpy( (void*)&canMessageRxBuffer[rrb_i].m.data[0], (void*)&rrb_m.data[0], rrb_m.len );
canMessageRxBuffer[rrb_i].valid = TRUE;
returnValue = TRUE;
}
else
{ // there's no new message in the buffer, so we can leave this function
return returnValue;
}
}
}
return returnValue;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -