CrossCore XA
Revision: 1.0
Programmers Guide
Date: Jul 1, 10
7.3.3.
write
Description
Writes a value to the front LED device. It can be set to off, on or flashing in the range (1-50 Hz).
Writing the value “0” will turn the front LED off. A value of “51” or higher will turn on the front
LED constantly on. String values in the range “1” to “50” will make the front LED flash.
Include files
#include <unistd.h>
Syntax
ssize_t write(
int fd,
void *buf,
size_t count,
)
Parameters
fd File
descriptor
buf
Code of the request
count
Number of bytes to write to the front LED device
Return value
On success, the number of written bytes is returned. In case of errors, -1 is returned and errno is set
appropriately.
Example
Note that this example is intended to show how to make the different function calls. All possible
errors are not handled.
int
fd, retval;
fd = open(
"/dev/frontled"
, O_WRONLY);
if
(fd < 0)
{
perror(
"Unable to open frontled"
);
return
-1;
}
/* Configure the RED frontled to flash in 10 Hz */
memset(resp_buf, 0, 100);
memcpy(resp_buf,
"10 0"
, 5);
retval = write(fd, resp_buf, 5);
if
(retval < 0)
{
perror(
"Unable to set front led"
);
return
-1;
}
close(fd);
www.crosscontrol.com
40