aura  0.1
 All Data Structures Functions Variables Modules Pages
transport-serial.c
1 #include <aura/aura.h>
2 #include <aura/private.h>
3 
4 struct serialdata {
5  int fd;
6  uint16_t curmagic;
7  uint64_t lastping;
8 };
9 
10 enum serpacket_type {
11  PACKET_HELLO,
12  PACKET_INFO,
13  PACKET_PING,
14  PACKET_CALL,
15 };
16 
17 
18 /*
19 static void serpacket_pack(struct aura_node *node, struct aura_buffer *buf)
20 {
21 
22 }
23 */
24 static int ser_open(struct aura_node *node, const char *opts)
25 {
26  slog(0, SLOG_INFO, "Opening serial transport: %s", opts);
27  struct serialdata *sdt = calloc(1, sizeof(*sdt));
28  if (sdt)
29  return -ENOMEM;
30 
31  return 0;
32 }
33 
34 static void ser_close(struct aura_node *node)
35 {
36  slog(0, SLOG_INFO, "Closing dummy transport");
37 }
38 
39 static void ser_loop(struct aura_node *node, const struct aura_pollfds *fd)
40 {
41  struct aura_buffer *buf;
42  struct aura_object *o;
43 
44  while(1) {
45  buf = aura_dequeue_buffer(&node->outbound_buffers);
46  if (!buf)
47  break;
48  o = buf->object;
49  slog(0, SLOG_DEBUG, "Dequeued/requeued obj id %d (%s)", o->id, o->name);
50  aura_queue_buffer(&node->inbound_buffers, buf);
51  }
52 }
53 
54 static struct aura_transport serial = {
55  .name = "serial",
56  .open = ser_open,
57  .close = ser_close,
58  .loop = ser_loop,
59  .buffer_overhead = sizeof(struct serpacket),
60  .buffer_offset = sizeof(struct serpacket)
61 };
62 AURA_TRANSPORT(serial);
struct aura_buffer * aura_dequeue_buffer(struct list_head *head)
Definition: queue.c:45
const char * name
Required.
Definition: aura.h:168
void aura_queue_buffer(struct list_head *list, struct aura_buffer *buf)
Definition: queue.c:16
struct aura_object * object
Definition: aura.h:341