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

Page 267

Advertising
background image

KTD-S0057-I

Page 263 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


if (write (fd_tmp, param3, strlen (param3)) != strlen (param3))

{

close

(fd_tmp);

return

-1;

}

close

(fd_tmp);

sprintf (str, io_val, io_num[gpio]);

if (!strcasecmp (param3, IO_IN))

{

if ((fd_io = open (str, O_RDONLY)) < 0)

return

-1;

gp_dir = IO_DIR_IN;

}

else

{

if ((fd_io = open (str, O_WRONLY)) < 0)

return

-1;

gp_dir = IO_DIR_OUT;

}

gp_num = gpio;

return

0;

}

if (!strcasecmp (param2, IO_CLOSE) && fd_io)

{

int fd_tmp, gpio;

char str [8];

gpio = atoi (param1);

if (gpio != gp_num)

return

-1;

close

(fd_io);

fd_io = 0;

if ((fd_tmp = open (io_unexp, O_WRONLY)) < 0)

return

-1;

sprintf (str, "%d", io_num[gpio]);

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

{

close

(fd_tmp);

return

-1;

}

close

(fd_tmp);

return

0;

}

if (!strcasecmp (param2, IO_DATA) && fd_io)

{

int

gpio;

char str [8];

gpio = atoi (param1);

if (gpio != gp_num)

return

-1;

Advertising
This manual is related to the following products: