CrossCore XA
Revision: 1.0
Programmers Guide
Date: Jul 1, 10
7.3.4.
ioctl
Description
An ioctl function call can be used for setting the state of the front LED. It has only one data type
which was covered in section 7.2. The available ioctl operations are listed in the table below.
Define
Description
CROSS_DIG_IOC_SET_STATUS_LED
Set the state of the front LED
CROSS_DIG_IOC_SET_CAN0_LED
Set the state of the CAN0 LED
CROSS_DIG_IOC_SET_CAN1_LED
Set the state of the CAN1 LED
Include files
#include <sys/ioctl.h>
#include <dig-io.h>
Syntax
int ioctl(
int fd,
int request,
void *argp
)
Parameters
fd File
descriptor
request
Code of the request
argp
Used for transferring data in the ioctl call. In this case it is an integer.
Return value
Returns a positive value on success. In case of errors, -1 is returned and errno is set appropriately.
Example
This example shows how to operate the frontled by calling ioctl().Note that this example is
intended to show how to make the different function calls. All possible errors are not handled.
hertz = 2; /* Slow flashing */
data = (LED_RED << 8) | hertz;
fd = open(
"/dev/frontled"
, O_RDWR);
if
(!fd)
{
printf(
"Open /dev/frontled failed\n"
);
return
0;
}
res = ioctl(fd, CROSS_DIG_IOC_SET_STATUS_LED, data);
if
(res < 0)
{
printf(
"Frontled set error: %d\n"
, res);
}
else
{
printf(
"Frontled set to %d\n"
, hertz);
}
close(fd);
www.crosscontrol.com
41