Transport layer over CAN bus

Classes

struct  CanFrame

Defines

#define MAX_DROPPING_SOURCE   20

Typedefs

typedef int(* AsebaCanIntVoidFP )()
typedef void(* AsebaCanSendFrameFP )(const CanFrame *frame)
typedef void(* AsebaCanVoidVoidFP )()

Functions

void AsebaCanFlushQueue (void)
void AsebaCanFrameReceived (const CanFrame *frame)
void AsebaCanFrameSent ()
uint16 AsebaCanGetMinMultipleOfHeight (uint16 v)
void AsebaCanInit (uint16 id, AsebaCanSendFrameFP sendFrameFP, AsebaCanIntVoidFP isFrameRoomFP, AsebaCanVoidVoidFP receivedPacketDroppedFP, AsebaCanVoidVoidFP sentPacketDroppedFP, CanFrame *sendQueue, size_t sendQueueSize, CanFrame *recvQueue, size_t recvQueueSize)
uint16 AsebaCanRecv (uint8 *data, size_t size, uint16 *source)
uint16 AsebaCanRecvBufferEmpty (void)
void AsebaCanRecvFreeQueue (void)
static void AsebaCanRecvQueueFreeFrames (uint16 id)
static void AsebaCanRecvQueueGarbageCollect ()
static uint16 AsebaCanRecvQueueGetMaxUsedFrames ()
static uint16 AsebaCanRecvQueueGetMinFreeFrames ()
uint16 AsebaCanSend (const uint8 *data, size_t size)
static uint16 AsebaCanSendQueueGetFreeFrames ()
static uint16 AsebaCanSendQueueGetUsedFrames ()
static void AsebaCanSendQueueInsert (uint16 canid, const uint8 *data, size_t size)
static void AsebaCanSendQueueToPhysicalLayer ()
uint16 AsebaCanSendSpecificSource (const uint8 *data, size_t size, uint16 source)
void AsebaIdle (void)
uint16 AsebaShouldDropPacket (uint16 source, const uint8 *data)

Variables

static uint16 dropping [MAX_DROPPING_SOURCE]

Detailed Description

This layer is able to transmit messages of arbitrary length (up to the available amount of memory) over a serie of 8 bytes CAN frames. If the message is under 8 bytes, the layer uses a single frame.

The layer does not uses acknowledgment, instead it trusts the CAN checksum mechanism to ensure that other nodes on the CAN bus received the data correctly.


Define Documentation

#define MAX_DROPPING_SOURCE   20

Definition at line 327 of file can-net.c.


Typedef Documentation

typedef int(* AsebaCanIntVoidFP)()

Pointer to a void function returning int

Definition at line 63 of file can-net.h.

typedef void(* AsebaCanSendFrameFP)(const CanFrame *frame)

Pointer to a function that sends a CAN frame (max 8 bytes)

Definition at line 66 of file can-net.h.

typedef void(* AsebaCanVoidVoidFP)()

Pointer to a void function

Definition at line 60 of file can-net.h.


Function Documentation

void AsebaCanFlushQueue ( void   ) 

Wait until the send queue is empty

void AsebaCanFrameReceived ( const CanFrame frame  ) 

Data layer should call this function when a new CAN frame (max 8 bytes) is available

void AsebaCanFrameSent (  ) 

Data layer should call this function when the CAN frame (max 8 bytes) was sent successfully

uint16 AsebaCanGetMinMultipleOfHeight ( uint16  v  ) 

Returned the minimum number of multiple of height to fit v

Definition at line 49 of file can-net.c.

void AsebaCanInit ( uint16  id,
AsebaCanSendFrameFP  sendFrameFP,
AsebaCanIntVoidFP  isFrameRoomFP,
AsebaCanVoidVoidFP  receivedPacketDroppedFP,
AsebaCanVoidVoidFP  sentPacketDroppedFP,
CanFrame sendQueue,
size_t  sendQueueSize,
CanFrame recvQueue,
size_t  recvQueueSize 
)

Init the CAN connection.

Parameters:
id the identifier of this node on the aseba CAN network
sendFrameFP pointer to a function that sends CAN frames to the data layer
isFrameRoomFP pointer to a function that returns if the data layer is ready to send frames
receivedPacketDroppedFP pointer to a function that is called when a received packet has been dropped, for various reasons but mostly related to insufficient memory
sentPacketDroppedFP pointer to a function that is called when a sent packet has been dropped (AsebaCanSend() returned 0), for various reasons but mostly related to insufficient memory
sendQueue pointer to send queue data
sendQueueSize number of frame in sendQueue
recvQueue pointer to receive queue data
recvQueueSize number of frame in recvQueue
uint16 AsebaCanRecv ( uint8 data,
size_t  size,
uint16 source 
)

Copy data from a received packet to the caller-provided buffer. Remove the packet from the reception queue afterwards.

Parameters:
data pointer where to copy the data
size makimum number of byte to copy. Actual number of byte might be smaller if packet was smaller. If packet was bigger, the rest of the data are dropped.
source the identifier of the source of the received packet
Returns:
the amount of data copied. 0 if no data were available.
uint16 AsebaCanRecvBufferEmpty ( void   ) 

Return true if the recv buffer is empty, false otherwise

void AsebaCanRecvFreeQueue ( void   ) 

Free everything in the Rx queue. Warning, this is a low-level function which should only be called if the underlaying CAN driver is disabled.

static void AsebaCanRecvQueueFreeFrames ( uint16  id  )  [static]

Free frames associated with an id in the reception queue

Definition at line 151 of file can-net.c.

static void AsebaCanRecvQueueGarbageCollect (  )  [static]

Readjust the fifo pointers

Definition at line 135 of file can-net.c.

static uint16 AsebaCanRecvQueueGetMaxUsedFrames (  )  [static]

Returned the maximum number of used frames in the reception queue

Definition at line 117 of file can-net.c.

static uint16 AsebaCanRecvQueueGetMinFreeFrames (  )  [static]

Returned the minimum number of free frames in the reception queue

Definition at line 129 of file can-net.c.

uint16 AsebaCanSend ( const uint8 data,
size_t  size 
)

Send data as an aseba packet.

Parameters:
data pointer to the data to send
size amount of data to send
Returns:
1 on success, 0 on failure
static uint16 AsebaCanSendQueueGetFreeFrames (  )  [static]

Returned the number of free frames in the send queue

Definition at line 71 of file can-net.c.

static uint16 AsebaCanSendQueueGetUsedFrames (  )  [static]

Returned the number of used frames in the send queue

Definition at line 58 of file can-net.c.

static void AsebaCanSendQueueInsert ( uint16  canid,
const uint8 data,
size_t  size 
) [static]

Insert a frame in the send queue, do not check for overwrite

Definition at line 77 of file can-net.c.

static void AsebaCanSendQueueToPhysicalLayer (  )  [static]

Send frames in send queue to physical layer until it is full

Definition at line 92 of file can-net.c.

uint16 AsebaCanSendSpecificSource ( const uint8 data,
size_t  size,
uint16  source 
)

Send data as an aseba packet.

Parameters:
data pointer to the data to send
size amount of data to send
source identifier to use as source
Returns:
1 on success, 0 on failure
void AsebaIdle ( void   ) 

Busy wait until the can buffer has room. At worst, can be an empty function

Definition at line 167 of file main.c.

uint16 AsebaShouldDropPacket ( uint16  source,
const uint8 data 
)

Return true if VM will ignore the packet, false otherwise

Definition at line 172 of file main.c.


Variable Documentation

uint16 dropping[MAX_DROPPING_SOURCE] [static]

Definition at line 328 of file can-net.c.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


asebaros
Author(s): $author
autogenerated on Mon Sep 5 08:42:05 2011