Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual

Page 85

Advertising
background image

KTD-S0057-I

Page 81 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


int read_bkl_val (int *val)
{
int

fd;

char

str[8];

fd = open (dev_act, O_RDONLY);

if (fd < 0)

return

-1;

if (read (fd, str, sizeof (str)) < 0)

{

close

(fd);

return

-1;

}

str [3] = '\0';

/* Maximal value is 255 */

*val = atoi (str);

close

(fd);

return

0;

}


int write_bkl_power (int pow_state)
{
int

fd;

char

str[8];

if ((pow_state < 0) || (pow_state > MAX_BKL_POW))

return

-1;

fd = open (dev_pow, O_WRONLY);

if (fd < 0)

return

-1;

sprintf (str, "%d", pow_state);

if (write (fd, str, strlen (str)) != strlen (str))

{

close

(fd);

return

-1;

}

close

(fd);

return

0;

}


int main (void)
{
int

value;

printf ("\nBacklight test program\n");

if (! read_bkl_val (&value))

printf ("Actual backlight value: %d\n", value);

else

printf ("Backlight read function fails !\n");

Advertising
This manual is related to the following products: