Classes | Defines | Typedefs | Functions | Variables
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.

This transport layer only works on little-endian systems for now, as it does not perform endian correction.


Define Documentation

#define MAX_DROPPING_SOURCE   20

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


Typedef Documentation

typedef int(* AsebaCanIntVoidFP)()

Pointer to a void function returning int

Definition at line 62 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 65 of file can-net.h.

typedef void(* AsebaCanVoidVoidFP)()

Pointer to a void function

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


Function Documentation

void AsebaCanFlushQueue ( void  )

Wait until the send queue is empty

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

void AsebaCanFrameReceived ( const CanFrame frame)

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

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

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

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

Returned the minimum number of multiple of height to fit v

Definition at line 69 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:
idthe identifier of this node on the aseba CAN network
sendFrameFPpointer to a function that sends CAN frames to the data layer
isFrameRoomFPpointer to a function that returns if the data layer is ready to send frames
receivedPacketDroppedFPpointer to a function that is called when a received packet has been dropped, for various reasons but mostly related to insufficient memory
sentPacketDroppedFPpointer 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
sendQueuepointer to send queue data
sendQueueSizenumber of frame in sendQueue
recvQueuepointer to receive queue data
recvQueueSizenumber of frame in recvQueue

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

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:
datapointer where to copy the data
sizemakimum 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.
sourcethe identifier of the source of the received packet
Returns:
the amount of data copied. 0 if no data were available.

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

Return true if the recv buffer is empty, false otherwise

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

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.

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

static void AsebaCanRecvQueueFreeFrames ( uint16  id) [static]

Free frames associated with an id in the reception queue

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

static void AsebaCanRecvQueueGarbageCollect ( ) [static]

Readjust the fifo pointers

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

Returned the maximum number of used frames in the reception queue

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

Returned the minimum number of free frames in the reception queue

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

uint16 AsebaCanSend ( const uint8 data,
size_t  size 
)

Send data as an aseba packet.

Parameters:
datapointer to the data to send
sizeamount of data to send
Returns:
1 on success, 0 on failure

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

Returned the number of free frames in the send queue

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

Returned the number of used frames in the send queue

Definition at line 78 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 97 of file can-net.c.

static void AsebaCanSendQueueToPhysicalLayer ( ) [static]

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

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

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

Send data as an aseba packet.

Parameters:
datapointer to the data to send
sizeamount of data to send
sourceidentifier to use as source
Returns:
1 on success, 0 on failure

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

void AsebaIdle ( void  )

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

Definition at line 187 of file can-translator/main.c.

uint16 AsebaShouldDropPacket ( uint16  source,
const uint8 data 
)

Return true if VM will ignore the packet, false otherwise

Definition at line 192 of file can-translator/main.c.


Variable Documentation

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



aseba
Author(s): Stéphane Magnenat
autogenerated on Thu Jan 2 2014 11:17:17