Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

XgIfStran


Functions

int NutIfStreamReadTran (NUTDEVICE *dev, char *data, int size)
 Read from a stream device translating non printables.

int NutIfStreamWriteTran (NUTDEVICE *dev, CONST char *data)
 Translate and write a string to a stream device.


Function Documentation

int NutIfStreamReadTran NUTDEVICE   dev,
char *    data,
int    size
 

Read from a stream device translating non printables.

This call works like NutIfStreamRead(), but translates character codes below 33, above 126 or equal 34 into their hex representation prepended by a backslash and the letter x. Backslashes are duplicated and the complete string is terminated by character code zero. This offers the ability to store binary data in printable strings.

Todo:
Very specific code, should be moved to an extra module to save ROM space of ordinary applications.
Parameters:
dev  Identifies the device to read from. This pointer must have been retrieved by calling NutDeviceOpen().
data  Pointer to the buffer that receives the translated string.
size  Size of the buffer.
Returns:
The number of bytes read or -1 in case of an error. Due to code translation, this may be less than the number of characters returned in the string.

int NutIfStreamWriteTran NUTDEVICE   dev,
CONST char *    data
 

Translate and write a string to a stream device.

This call works like NutIfStreamWrite(), but translates any backslash followed by the letter x followed by two hexadecimal uppercase digits into the binary representation. Simple backslashes are expected to be duplicated and the complete string must be terminated by character code zero. This offers the ability to write binary data from a printable strings.

The data isn't immediately transfered to the physical device, but buffered in a transmit buffer. Transmission starts either when the buffer is full or when this function is called with a zero data pointer.

Parameters:
dev  Identifies the device to write to. This pointer must have been retrieved by calling NutDeviceOpen().
data  Pointer to a zero terminated string to be translated and written. If this pointer is NULL, the stream device starts transmitting the buffered data.
Returns:
The number of characters written or -1 in case of an error. Due to code translation, this may be less than the number of characters contained in the string.


Generated on Thu Jan 30 22:30:59 2003 for EduNet by doxygen1.2.18