aura  0.1
 All Data Structures Functions Variables Modules Pages
test-susb.c
1 #include <aura/aura.h>
2 #include <unistd.h>
3 int main() {
4  int ret;
5 
6  slog_init(NULL, 88);
7  struct aura_node *n = aura_open("simpleusb", "../simpleusbconfigs/susb-test.conf");
8 
9  if (!n) {
10  printf("err\n");
11  return -1;
12  }
13  aura_wait_status(n, AURA_STATUS_ONLINE);
14 
15  struct aura_buffer *retbuf;
16 
17  ret = aura_call(n, "led_ctl", &retbuf, 0x100, 0x100);
18  slog(0, SLOG_DEBUG, "call ret %d", ret);
19  if (0 != ret)
20  exit(1);
21 
22  aura_buffer_release(retbuf);
23 
24 
25  uint32_t a = rand();
26  uint32_t b = rand();
27  ret = aura_call(n, "write", &retbuf, 0xa, 0xb, a, b);
28  slog(0, SLOG_DEBUG, "call ret %d", ret);
29  if (0 != ret)
30  exit(1);
31 
32  aura_buffer_release(retbuf);
33 
34  ret = aura_call(n, "read", &retbuf, 0x0, 0x0);
35  slog(0, SLOG_DEBUG, "call ret %d", ret);
36  if (0 != ret)
37  exit(1);
38 
39  aura_hexdump("buffer", retbuf->data, retbuf->size);
40  slog(0, SLOG_INFO, "a=%x b= %x", a, b);
41  uint32_t tmp = aura_buffer_get_u32(retbuf);
42  if (a != tmp) {
43  slog(0, SLOG_ERROR, "%x != %x", tmp, a);
44  exit(1);
45  }
46 
47  tmp = aura_buffer_get_u32(retbuf);
48  if (b != tmp) {
49  slog(0, SLOG_ERROR, "%x != %x", tmp, b);
50  exit(1);
51  }
52  aura_buffer_release(retbuf);
53 
54  printf("TEST_OK!\n");
55  aura_close(n);
56  return 0;
57 }
58 
59 /*
60 
61  0000 40 01 00 01 00 01 00 00 00 01 00 01 @...........
62  0000 40 01 00 01 00 01 00 00 00 01 00 01 @...........
63 
64 */
void aura_wait_status(struct aura_node *node, int status)
Definition: aura.c:607
uint32_t aura_buffer_get_u32(struct aura_buffer *buf)
Get an unsigned 32 bit integer from aura buffer.
int aura_call(struct aura_node *node, const char *name, struct aura_buffer **retbuf,...)
Definition: aura.c:666
struct aura_node * aura_open(const char *name, const char *opts)
Definition: aura.c:34
int size
Definition: aura.h:337
void aura_buffer_release(struct aura_buffer *buf)
Definition: buffer.c:80
void aura_close(struct aura_node *node)
Definition: aura.c:102
char * data
Definition: aura.h:347