Browse Source

NON WORKING CODE

tth 2 months ago
parent
commit
c1327cf318
6 changed files with 80 additions and 12 deletions
  1. 3
    3
      specific/Makefile
  2. 46
    7
      specific/asyncburp.c
  3. 7
    1
      specific/burpmsg.c
  4. 1
    0
      specific/burpmsg.h
  5. 22
    1
      specific/laserblast.c
  6. 1
    0
      specific/laserblast.h

+ 3
- 3
specific/Makefile View File

@@ -14,14 +14,14 @@ joy2laser:	joy2laser.c Makefile laserblast.o
14 14
 
15 15
 #			--------------------------------------------
16 16
 
17
-asyncburp.o:	asyncburp.c burpmsg.h Makefile
17
+asyncburp.o:	asyncburp.c burpmsg.h laserblast.h Makefile
18 18
 	gcc -c ${OPTS} $<
19 19
 
20 20
 burpmsg.o:	burpmsg.c burpmsg.h Makefile
21 21
 	gcc -c ${OPTS} $<
22 22
 
23
-asyncburp:	asyncburp.o burpmsg.o
24
-	gcc ${OPTS} $< burpmsg.o -llo -o $@
23
+asyncburp:	asyncburp.o burpmsg.o laserblast.o
24
+	gcc ${OPTS} $< laserblast.o burpmsg.o -llo -o $@
25 25
 
26 26
 #			--------------------------------------------
27 27
 

+ 46
- 7
specific/asyncburp.c View File

@@ -7,6 +7,7 @@
7 7
 #include  <stdio.h>
8 8
 #include  <stdlib.h>
9 9
 #include  <unistd.h>
10
+#include  <string.h>
10 11
 
11 12
 #include  <lo/lo.h>			/* OSC library */
12 13
 
@@ -25,18 +26,54 @@
25 26
 int		verbosity;		/* global variable */
26 27
 
27 28
 /* ------------------------------------------------------------------- */
28
-static int bloub(void)
29
+/* ------------------------------------------------------------------- */
30
+int init_osc_receiver(char *port, int notused)
29 31
 {
30
-BurpMsg			message;
31 32
 
33
+#if DEBUG_LEVEL
34
+fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, port, notused);
35
+#endif
32 36
 
33
-message.magic = BURP_MAGIC;
37
+return -1;
38
+}
39
+/* ------------------------------------------------------------------- */
40
+int init_osc_sender(char *r_host, char *r_port, int notused)
41
+{
42
+int			foo;
34 43
 
35
-display_burp_msg(&message, NULL);
44
+#if DEBUG_LEVEL
45
+fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n", __func__,
46
+				r_host, r_port, notused);
47
+#endif
48
+
49
+foo = blast_init(r_host, r_port, 0, 0);
50
+if (foo) {
51
+	fprintf(stderr, "blast_init return %d\n", foo);
52
+	return -2;
53
+	}
54
+
55
+if (verbosity) blast_NOP(getpid());
36 56
 
37 57
 return 0;
38 58
 }
39 59
 /* ------------------------------------------------------------------- */
60
+/*
61
+ *	this is a tool function for debugging, do not use in real life
62
+ */
63
+static int tentative(void)
64
+{
65
+int		foo;
66
+
67
+blast_rewind();
68
+
69
+blast_addpoint(200, 200, 0xff0000);
70
+blast_addpoint(300, 300, 0xff0000);
71
+
72
+blast_flush(0);
73
+
74
+return 42;
75
+}
76
+/* ------------------------------------------------------------------- */
40 77
 static int help(int krkrkr)
41 78
 {
42 79
 puts("HELP ME !");
@@ -49,7 +86,6 @@ puts("\t-v\t\tincrease verbosity");
49 86
 return 1;
50 87
 }
51 88
 /* ------------------------------------------------------------------- */
52
-
53 89
 int main(int argc, char *argv[])
54 90
 {
55 91
 char			*local_port  = LOCAL_PORT;
@@ -58,7 +94,7 @@ char			*remote_port = REMOTE_PORT;
58 94
 
59 95
 int			lasernumber, scenenumber;
60 96
 
61
-int			opt;
97
+int			opt, foo;
62 98
 
63 99
 fprintf(stderr, "%s compiled %s at %s\n",argv[0],  __DATE__, __TIME__);
64 100
 
@@ -87,7 +123,10 @@ if (verbosity) {
87 123
 	fprintf(stderr, "scn/laser    : %d %d\n", scenenumber, lasernumber);
88 124
 	}
89 125
 
90
-			bloub();
126
+foo = init_osc_sender(remote_host, remote_port, 0);
127
+fprintf(stderr, "init osc sender -> %d\n", foo);
128
+
129
+tentative();
91 130
 
92 131
 return 2;
93 132
 }

+ 7
- 1
specific/burpmsg.c View File

@@ -7,6 +7,7 @@
7 7
 #include  <sys/select.h>
8 8
 #include  <unistd.h>
9 9
 
10
+#include  "laserblast.h"
10 11
 
11 12
 #include  "burpmsg.h"
12 13
 
@@ -37,6 +38,9 @@ switch(header->msgtype) {
37 38
 	case BURP_SCENE:
38 39
 		txt_type = "scene";
39 40
 		break;
41
+	case BURP_TEXTE:
42
+		txt_type = "texte";
43
+		break;
40 44
 
41 45
 	default:
42 46
 		fprintf(stderr, "burpmsg at %p : invalid msgtype %d\n",
@@ -44,7 +48,7 @@ switch(header->msgtype) {
44 48
 	return -1;
45 49
 	}
46 50
 
47
-fprintf(stderr, "%4d %12s   %9d   %3d\n", 
51
+fprintf(stderr, "type %4d/%-8s  serial %9d  szdata %3d\n", 
48 52
 		header->msgtype, txt_type, header->serial, header->szdata);
49 53
 
50 54
 return 0;
@@ -80,6 +84,8 @@ for(;;)	{			/* start of infinite loop */
80 84
 						foo,	sizeof(BurpMsg));
81 85
 			}
82 86
 		display_burp_msg(&message, NULL);
87
+		/* read appended datas */
88
+
83 89
 		}
84 90
 	else	{
85 91
 		/* got a time out */

+ 1
- 0
specific/burpmsg.h View File

@@ -20,6 +20,7 @@ typedef struct	{
20 20
 #define		BURP_LASER	3
21 21
 #define		BURP_SCENE	4
22 22
 #define		BURP_COLOR	5
23
+#define		BURP_TEXTE	6
23 24
 
24 25
 /* ------------------------------------------------------------------- */
25 26
 

+ 22
- 1
specific/laserblast.c View File

@@ -46,6 +46,27 @@ x_scale = y_scale = 700;
46 46
 big_buffer[0] = '\0';			/* clear buffer */
47 47
 curpos = 0;				/* index in buffer */
48 48
 
49
+return 0;
50
+}
51
+/* ------------------------------------------------------------------- */
52
+/*
53
+ *	this function is for test purpose, don't use in the
54
+ *	real world, Just don't, OK?
55
+ */
56
+int blast_NOP(int reason)
57
+{
58
+int		foo;
59
+char		msg[50];
60
+
61
+fprintf(stderr, "===== BLAST NOP %d\n", reason);
62
+
63
+sprintf(msg, "BLAST NOP %d", reason);
64
+foo = lo_send(lo_addr, "/dev/null", "s", msg);
65
+if (-1==foo) {
66
+	fprintf(stderr, "%s : error %d\n", __func__, foo);
67
+	return -1;
68
+	}
69
+
49 70
 return 0;
50 71
 }
51 72
 /* ------------------------------------------------------------------- */
@@ -79,7 +100,7 @@ return -1;
79 100
 int	blast_addpoint(float x, float y, long col)
80 101
 {
81 102
 char		buff[100];
82
-int		foo, sz;
103
+int		sz;
83 104
 
84 105
 sz = sprintf(buff, "(%.2f, %.2f, %ld),", x, y, col);
85 106
 

+ 1
- 0
specific/laserblast.h View File

@@ -11,3 +11,4 @@ int	blast_setscale(int width, int height);
11 11
 int	blast_addpoint(float fx, float fy, long col);
12 12
 int	blast_flush(int notused);
13 13
 
14
+int	blast_NOP(int reason);

Loading…
Cancel
Save