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

XgDevTran


Functions

int NutDeviceReadTran (NUTDEVICE *dev, void *data, int size)
 Read up to a specified number of bytes from a device translating non printables.

int NutDeviceWriteTran (NUTDEVICE *dev, CONST void *data)
 Write a buffer to a specified device.


Function Documentation

int NutDeviceReadTran NUTDEVICE   dev,
void *    data,
int    size
 

Read up to a specified number of bytes from a device translating non printables.

This call works like NutDeviceRead(), 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 that read from. A null pointer specifies the first on-chip UART. If this pointer is not null, it must have been retrieved by using the NutDeviceOpen() function.
data  Pointer to the buffer that receives the translated string.
size  Size of the buffer.
Returns:
The number of bytes read, 0 on timeouts and broken connections or -1 in case of an error. Due to code translation, the number of bytes read be less than the number of characters returned in the string.

int NutDeviceWriteTran NUTDEVICE   dev,
CONST void *    data
 

Write a buffer to a specified device.

This is a raw output without any character translation like EOL (end of line).

Parameters:
dev  Identifies the device to write to. A null pointer may be used for unbuffered output to the first on-chip UART. If this pointer is not null, it must have been retrieved by directly or indirectly calling NutDeviceOpen() for real devices. For virtual devices this pointer is returned by the function that creates the device.
data  Buffer to be written.
len  Number of characters to be printed.
Returns:
If successful, the number of bytes added to the output buffer. This may be less than the specified number of bytes to print. The return value -1 indicates an error.


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