HIPC  0.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
client_led.c
Go to the documentation of this file.
1 #include <unistd.h>
2 
3 #include <stdio.h>
4 
6 #include <hipc/session.h>
7 
8 #include "CFGled.h"
9 #include "CFGled_ccfg.h"
10 
11 int main(void)
12 {
13  hipc_session sess;
14  struct STRUprm prm;
15  int fdr = STDIN_FILENO;
16  int fdw = STDOUT_FILENO;
17  int i;
18  unsigned int len;
19 
20  hipcOpen(&sess, &HIPCUD_CFGled_CCFG,
21  hipcPosixReadMsg, &fdr, hipcPosixWriteMsg, &fdw);
22  HIPC_ERRCHECK(&sess);
23 
24  len = 1600;
25  for (i = 0; i < 4; ++i) {
26  prm.led = 1;
27  hipcPut(&sess, "STRUprm.led", &prm);
28  HIPC_ERRCHECK(&sess);
29  usleep(len * 1000);
30  len /= 2;
31 
32  prm.led = 0;
33  hipcPut(&sess, "STRUprm.led", &prm);
34  HIPC_ERRCHECK(&sess);
35  usleep(1000 * 1000);
36  }
37 
38  hipcClose(&sess);
39  HIPC_ERRCHECK(&sess);
40  fprintf(stderr, "end\n");
41 
42  return 0;
43 }
int main(void)
Definition: client_led.c:11
enum HIPC_errno hipcPut(hipc_session *const sess_p, char const *const str, void *const cimg)
Puts data specified by str from a HIPC server.
Definition: session.c:361
enum HIPC_errno hipcOpen(hipc_session *const sess_p, struct HIPC_client const *const clbase_p, enum HIPC_errno(*rfnc_p)(void *, hipc_msg), void *rarg, enum HIPC_errno(*wfnc_p)(void *, const hipc_msg), void *warg)
Open a session to a HIPC server.
Definition: session.c:217
enum HIPC_errno hipcPosixReadMsg(void *arg, hipc_msg msg)
Read a HIPC message from fd.
enum HIPC_errno hipcClose(hipc_session *const sess_p)
Closes a session.
Definition: session.c:276
enum HIPC_errno hipcPosixWriteMsg(void *arg, const hipc_msg msg)
Write a HIPC message to fd.
#define HIPC_ERRCHECK(sess_p)
Checks whether an error has occurred.
Definition: session.h:72