beautypg.com

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

Page 269

background image

KTD-S0057-I

Page 265 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


while (read (fifo_rd, buff_rd, RD_SIZE) > 0)

{

if (!strncasecmp (buff_rd, CMD_WDIO, CMD_SIZE))

{

if (!parse_wdio (buff_rd))

write

(fifo_wr,

ACK_STR,

ACK_SIZE);

else

write

(fifo_wr,

NAK_STR,

NAK_SIZE);

}

if (!strncasecmp (buff_rd, CMD_GPIO, CMD_SIZE))

{

if (!parse_gpio (buff_rd, &value))

{

if (value != -1)

{

sprintf

(buff_wr,

DATA_STR,

value);

write

(fifo_wr,

buff_wr,

strlen

(buff_wr));

}

else

write

(fifo_wr,

ACK_STR,

ACK_SIZE);

}

else

write

(fifo_wr,

NAK_STR,

NAK_SIZE);

}

if (!strncasecmp (buff_rd, CMD_EXIT, CMD_SIZE))

break;

memset (buff_rd, 0, RD_SIZE);

}

close

(fifo_rd);

unlink

(root_rd);

close

(fifo_wr);

unlink

(root_wr);

umask

(oldmask);

return

0;

}

and finally the sourcecode of the client application 'client.c':

/* Client application

* Copyright (c) 2014 Kontron Technology A/S

* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License. */

#include
#include
#include
#include
#include
#include

This manual is related to the following products: