PIC24 Support Libraries
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
dataXfer.c File Reference

Implementation of the uC data transfer protocol. More...

#include "dataXfer.h"
#include <string.h>
#include <stdio.h>

Go to the source code of this file.

Functions

void initDataXfer ()
 
int formatVar (uint u_varIndex, char *psz_buf)
 
Send functions
void outCharXfer (char c)
 
void specifyVar (uint u_varIndex, volatile void *pv_data, uint u_size, BOOL b_isWriteable, char *psz_format, char *psz_name, char *psz_desc)
 
void sendVar (uint u_varIndex)
 

Detailed Description

Implementation of the uC data transfer protocol.

Definition in file dataXfer.c.

Function Documentation

int formatVar ( uint  u_varIndex,
char *  psz_buf 
)

Return a string with the data stored in the given variable formatted using the format string contained in the variable. Limitation: current, use of a string (s format) will probably crash the program. PC only.

Parameters
u_varIndexThe index of the variable to send; must be from 0 to NUM_XFER_VARS.
psz_bufBuffer large enough to contain the formatted string.
Returns
On success, the total number of characters written is returned. This count does not include the additional null-character automatically appended at the end of the string. On failure, a negative number is returned.

Definition at line 121 of file dataXfer.c.

Referenced by testFormatIndexTooHigh(), and testFormatIndexUnspecificed().

void initDataXfer ( )

Initialize the data transfer system. This must be called before calling any of the data transfer functions in the library.

Definition at line 10 of file dataXfer.c.

Referenced by runTest().

void outCharXfer ( char  c)

Send one character to the uC, escaping if necessary.

Parameters
cCharacter to send.

Definition at line 20 of file dataXfer.c.

Referenced by sendVar(), and specifyVar().

void sendVar ( uint  u_varIndex)

Send an already-specified variable;

See Also
specifyVar.
Parameters
u_varIndexThe index of the variable to send; must be from 0 to NUM_XFER_VARS.

Definition at line 77 of file dataXfer.c.

Referenced by checkSendVar(), testSendIndexTooHigh(), testSendIndexUnspecificed(), and testSendToReadOnly().

void specifyVar ( uint  u_varIndex,
volatile void *  pv_data,
uint  u_size,
BOOL  b_isWriteable,
char *  psz_format,
char *  psz_name,
char *  psz_desc 
)

Specify a variable to be sent or received.

Parameters
u_varIndexA value from 0-NUM_XFER_VARS, unique for each var
pv_dataA pointer to the data to be sent
u_sizeSize of the data in bytes; must be from 1 to 256.
b_isWriteableTrue if the PC is allowed to change this variable; false otherwise. This does NOT restrict the PIC to read-only access to this variable.
psz_formatprintf format string to use in displaying the Variable.
psz_nameName of this variable, typically the same as used in the code
psz_descDescription of this variable.

Definition at line 28 of file dataXfer.c.

Referenced by testSpecifyIndexTooHigh(), testSpecifyInvalidSize(), testSpecifyLongDesc(), testSpecifyLongFormat(), testSpecifyLongName(), testSpecifyMinimalVar(), and testSpecifyNullData().