Fraise  2.1
FRAmework for Interfacing Software and Electronics
Fraise device module

Implements Fraise device protocol on the serial device. More...

Implements Fraise device protocol on the serial device.

Initialization

void fraiseInit (void)
 Init fraise device stack. Normally automatically called by fruitInit(). More...
 

Service

void fraiseService (void)
 Fraise device service routine. More...
 

Fraise output to master

char fraiseSend (const unsigned char *buf, unsigned char len)
 Put a message into the Fraise TX queue. More...
 

Broadcast output

void fraiseSendBroadcast (const unsigned char *buf, unsigned char len)
 Broadcast a message to every connected fruit; this fonction is blocking (it returns when the message is sent) More...
 

Input Functions prototypes

User may define any of these four functions, that are called when the device receives a message. Each input function is for a specific type of message. These functions then parse the received message using one of the Input Routines or Input Macros.

void fraiseReceiveCharBroadcast ()
 String message to every device.
 
void fraiseReceiveBroadcast ()
 Raw message to every device.
 
void fraiseReceiveChar ()
 String message to this device.
 
void fraiseReceive ()
 Raw message to this device.
 

Input routines

Use these functions when parsing the current message in Input Functions.

unsigned char fraiseGetChar ()
 Get next char from receive buffer.
 
unsigned char fraisePeekChar ()
 See next char (but keep it in the buffer).
 
unsigned char fraiseGetIndex ()
 Get read index in RXbuffer.
 
unsigned char fraiseGetAt (unsigned char i)
 Get RXbuffer content at a given place.
 
unsigned char fraiseGetLen ()
 Get total length of current receive packet.
 
void fraiseSendCopy ()
 Copy the RX buffer to TX buffer, in char mode, from first RX byte to the one before current index (don't add last fraiseGetChar). Used to return queried parameter setting.
 
#define fraiseGetInt()
 Get next 16 bit integer from receive buffer.
 
#define fraiseGetLong()
 Get next 32 bit long integer from receive buffer.
 

Input macros (parameters set/get)

To be used in a switch() block.

#define PARAM_CHAR(n, p)
 in case n, assign next byte in the message to p
 
#define PARAM_INT(n, p)
 in case n, assign next 16 bit integer in the message to p
 
#define PARAM_LONG(n, p)
 in case n, assign next 32 bit integer in the message to p
 
#define GETPARAM(n, p, i)
 in case n, set i to the value of parameter p
 

Function Documentation

◆ fraiseInit()

void fraiseInit ( void  )

Init fraise device stack. Normally automatically called by fruitInit().

Configure serial port as a fraise device.

◆ fraiseService()

void fraiseService ( void  )

Fraise device service routine.

Check for input data from Fraise. This function calls input functions when the device receives a message from master.
Normal users shouldn't call fraiseService() directly, but use fruitService() instead.

◆ fraiseSend()

char fraiseSend ( const unsigned char *  buf,
unsigned char  len 
)

Put a message into the Fraise TX queue.

Parameters
bufAddress of the bytes buffer; the buffer must start with either 'C' (string message) or 'B' (raw bytes)
lenNumber of bytes in the buffer
Returns
0 : success
-1 : TX queue overload
-2 : TX buffer format error

◆ fraiseSendBroadcast()

void fraiseSendBroadcast ( const unsigned char *  buf,
unsigned char  len 
)

Broadcast a message to every connected fruit; this fonction is blocking (it returns when the message is sent)

Parameters
bufAddress of the bytes buffer; the buffer must start with either 'C' (string message) or 'B' (raw bytes)
lenNumber of bytes in the buffer