diff --git a/specific/Makefile b/specific/Makefile index c43b291..5a24ab9 100644 --- a/specific/Makefile +++ b/specific/Makefile @@ -14,14 +14,14 @@ joy2laser: joy2laser.c Makefile laserblast.o # -------------------------------------------- -asyncburp.o: asyncburp.c burpmsg.h Makefile +asyncburp.o: asyncburp.c burpmsg.h laserblast.h Makefile gcc -c ${OPTS} $< burpmsg.o: burpmsg.c burpmsg.h Makefile gcc -c ${OPTS} $< -asyncburp: asyncburp.o burpmsg.o - gcc ${OPTS} $< burpmsg.o -llo -o $@ +asyncburp: asyncburp.o burpmsg.o laserblast.o + gcc ${OPTS} $< laserblast.o burpmsg.o -llo -o $@ # -------------------------------------------- diff --git a/specific/asyncburp.c b/specific/asyncburp.c index ac31dcc..7cecb33 100644 --- a/specific/asyncburp.c +++ b/specific/asyncburp.c @@ -7,6 +7,7 @@ #include #include #include +#include #include /* OSC library */ @@ -25,18 +26,54 @@ int verbosity; /* global variable */ /* ------------------------------------------------------------------- */ -static int bloub(void) +/* ------------------------------------------------------------------- */ +int init_osc_receiver(char *port, int notused) { -BurpMsg message; +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, port, notused); +#endif -message.magic = BURP_MAGIC; +return -1; +} +/* ------------------------------------------------------------------- */ +int init_osc_sender(char *r_host, char *r_port, int notused) +{ +int foo; -display_burp_msg(&message, NULL); +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n", __func__, + r_host, r_port, notused); +#endif + +foo = blast_init(r_host, r_port, 0, 0); +if (foo) { + fprintf(stderr, "blast_init return %d\n", foo); + return -2; + } + +if (verbosity) blast_NOP(getpid()); return 0; } /* ------------------------------------------------------------------- */ +/* + * this is a tool function for debugging, do not use in real life + */ +static int tentative(void) +{ +int foo; + +blast_rewind(); + +blast_addpoint(200, 200, 0xff0000); +blast_addpoint(300, 300, 0xff0000); + +blast_flush(0); + +return 42; +} +/* ------------------------------------------------------------------- */ static int help(int krkrkr) { puts("HELP ME !"); @@ -49,7 +86,6 @@ puts("\t-v\t\tincrease verbosity"); return 1; } /* ------------------------------------------------------------------- */ - int main(int argc, char *argv[]) { char *local_port = LOCAL_PORT; @@ -58,7 +94,7 @@ char *remote_port = REMOTE_PORT; int lasernumber, scenenumber; -int opt; +int opt, foo; fprintf(stderr, "%s compiled %s at %s\n",argv[0], __DATE__, __TIME__); @@ -87,7 +123,10 @@ if (verbosity) { fprintf(stderr, "scn/laser : %d %d\n", scenenumber, lasernumber); } - bloub(); +foo = init_osc_sender(remote_host, remote_port, 0); +fprintf(stderr, "init osc sender -> %d\n", foo); + +tentative(); return 2; } diff --git a/specific/burpmsg.c b/specific/burpmsg.c index d82c921..40bd4cd 100644 --- a/specific/burpmsg.c +++ b/specific/burpmsg.c @@ -7,6 +7,7 @@ #include #include +#include "laserblast.h" #include "burpmsg.h" @@ -37,6 +38,9 @@ switch(header->msgtype) { case BURP_SCENE: txt_type = "scene"; break; + case BURP_TEXTE: + txt_type = "texte"; + break; default: fprintf(stderr, "burpmsg at %p : invalid msgtype %d\n", @@ -44,7 +48,7 @@ switch(header->msgtype) { return -1; } -fprintf(stderr, "%4d %12s %9d %3d\n", +fprintf(stderr, "type %4d/%-8s serial %9d szdata %3d\n", header->msgtype, txt_type, header->serial, header->szdata); return 0; @@ -80,6 +84,8 @@ for(;;) { /* start of infinite loop */ foo, sizeof(BurpMsg)); } display_burp_msg(&message, NULL); + /* read appended datas */ + } else { /* got a time out */ diff --git a/specific/burpmsg.h b/specific/burpmsg.h index 7e6fb30..a975943 100644 --- a/specific/burpmsg.h +++ b/specific/burpmsg.h @@ -20,6 +20,7 @@ typedef struct { #define BURP_LASER 3 #define BURP_SCENE 4 #define BURP_COLOR 5 +#define BURP_TEXTE 6 /* ------------------------------------------------------------------- */ diff --git a/specific/laserblast.c b/specific/laserblast.c index 4e2e1c3..1057464 100644 --- a/specific/laserblast.c +++ b/specific/laserblast.c @@ -46,6 +46,27 @@ x_scale = y_scale = 700; big_buffer[0] = '\0'; /* clear buffer */ curpos = 0; /* index in buffer */ +return 0; +} +/* ------------------------------------------------------------------- */ +/* + * this function is for test purpose, don't use in the + * real world, Just don't, OK? + */ +int blast_NOP(int reason) +{ +int foo; +char msg[50]; + +fprintf(stderr, "===== BLAST NOP %d\n", reason); + +sprintf(msg, "BLAST NOP %d", reason); +foo = lo_send(lo_addr, "/dev/null", "s", msg); +if (-1==foo) { + fprintf(stderr, "%s : error %d\n", __func__, foo); + return -1; + } + return 0; } /* ------------------------------------------------------------------- */ @@ -79,7 +100,7 @@ return -1; int blast_addpoint(float x, float y, long col) { char buff[100]; -int foo, sz; +int sz; sz = sprintf(buff, "(%.2f, %.2f, %ld),", x, y, col); diff --git a/specific/laserblast.h b/specific/laserblast.h index 050dde0..ce00cdb 100644 --- a/specific/laserblast.h +++ b/specific/laserblast.h @@ -11,3 +11,4 @@ int blast_setscale(int width, int height); int blast_addpoint(float fx, float fy, long col); int blast_flush(int notused); +int blast_NOP(int reason);