enc.c 945 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <labcomm_fd_writer.h>
#include <labcomm_default_error_handler.h>
#include <labcomm_default_memory.h>
#include <labcomm_default_scheduler.h>
#include "jg.h"
#include <stdio.h>

struct labcomm_encoder *enc_init( int fd) {
  struct labcomm_encoder *encoder;

  encoder = labcomm_encoder_new(labcomm_fd_writer_new(
				  labcomm_default_memory, fd, 1), 
				labcomm_default_error_handler, 
				labcomm_default_memory,
				labcomm_default_scheduler);
  labcomm_encoder_register_jg_foo(encoder);
  return encoder;
}

Sven Gestegård Robertz's avatar
Sven Gestegård Robertz committed
23
24
void enc_run(struct labcomm_encoder *encoder, jg_foo *v) {
#if 0
25
26
27
28
29
30
31
32
33
34
	jg_foo v;

	v.b = 17.17;
	v.c = 1742;
	v.d = 4217;
	v.e = "hello";
	v.f = 17;
	v.g = 42;
	v.h = 2;
	v.i = 42.42;
Sven Gestegård Robertz's avatar
Sven Gestegård Robertz committed
35
#endif
36
37

	usleep(500000);
Sven Gestegård Robertz's avatar
Sven Gestegård Robertz committed
38
39
40
	v->b += 42;
	v->h += 42000000;
	labcomm_encode_jg_foo(encoder, v);
41
42
43
44
45
}

void enc_cleanup(struct labcomm_encoder *encoder) {
	labcomm_encoder_free(encoder);
}