CrossCore XA
Revision: 1.0
Programmers Guide
Date: Jul 1, 10
5.3.4.
write
Description
Writes a value to a PWR-device. Values can be set on or off independently.
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/cross_pwr_io”
, O_WRONLY);
if
(fd < 0)
{
perror(
"Unable to open cross_pwr_io"
);
return
-1;
}
/* Set the output 0(Eth) to 0 */
memset(resp_buf, 0, 100);
memcpy(resp_buf,
"0 0"
, 4);
retval = write(fd, resp_buf, 4);
if
(retval < 0)
{
perror(
"Unable to set PWR-state"
);
return
-1;
}
close(fd);
www.crosscontrol.com
32