NON WORKING CODE

This commit is contained in:
tth 2020-11-02 08:41:33 +01:00
parent 87e2dfa4c8
commit c1327cf318
6 changed files with 80 additions and 12 deletions

View File

@ -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 $@
# --------------------------------------------

View File

@ -7,6 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <lo/lo.h> /* 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;
}

View File

@ -7,6 +7,7 @@
#include <sys/select.h>
#include <unistd.h>
#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 */

View File

@ -20,6 +20,7 @@ typedef struct {
#define BURP_LASER 3
#define BURP_SCENE 4
#define BURP_COLOR 5
#define BURP_TEXTE 6
/* ------------------------------------------------------------------- */

View File

@ -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);

View File

@ -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);