# HG changeset patch # User kazz # Date 1280072246 -32400 # Node ID 1a5de2a299874af97e7fcb60a1307e60b1b82198 # Parent e622f27c280832d8582c6ccfdd484270a50a9be1 add linda_test diff -r e622f27c2808 -r 1a5de2a29987 Renderer/Engine/lindaapi.cc --- a/Renderer/Engine/lindaapi.cc Sat Jul 17 15:09:48 2010 +0900 +++ b/Renderer/Engine/lindaapi.cc Mon Jul 26 00:37:26 2010 +0900 @@ -373,6 +373,18 @@ return(r); } +extern int psx_callback_update(unsigned int tspace_id, unsigned int id, + unsigned char *data, unsigned int size, + void(*callback)(unsigned char *,void *),void * obj) { + int r; + if ((r = psx_queue(tspace_id, id, size, data, 'u', callback, obj)) == FAIL) { + return(FAIL); + } + DEB( fprintf(stdout, "psx_update: size = %d, command = %s\n", + q_end->size, q_end->command+LINDA_HEADER_SIZE)); + return(r); +} + /*-------------------------------------------------------------------/ int psx_ld (unsigned tspace_id, unsigned int id, @@ -417,7 +429,7 @@ unsigned char *ans; DEB(fprintf(stdout, "psx_reply: search of seq = %d\n", seq)); - PSX_Debug(("psx_reply: seq %d", seq)); + PSX_Debug(("psx_reply: seq %x\n", seq)); for(q = NULL,p = reply; p; q = p,p = p->next){ if (p->seq == seq){ DEB(fprintf(stdout, "psx_reply: match of seq = %d\n", seq)); @@ -434,11 +446,11 @@ r_end = q; } } - PSX_Debug(("psx_reply: reply %x r_end %x p %x q %x",reply,r_end,p,q)); + PSX_Debug(("psx_reply: reply %p r_end %p p %p q %p\n",reply,r_end,p,q)); psx_free(p); - DEB( for(p=reply;p;p=p->next) { PSX_Debug(("psx_queue dump: seq %d mode %c %x %x",p->seq,p->mode,p,p->next))}); + DEB( for(p=reply;p;p=p->next) { PSX_Debug(("psx_queue dump: seq %d mode %c %x %x\n",p->seq,p->mode,p,p->next))}); DEB( fprintf(stdout, "psx_reply: returned answer = %s\n", ans)); - PSX_Debug(("psx_reply: answer %s",ans)); + PSX_Debug(("psx_reply: answer %s\n",ans)); return(ans); } else { if (p->mode == '?'){ @@ -449,7 +461,7 @@ } } - PSX_Debug(("psx_reply: no match seq %d",seq)); + PSX_Debug(("psx_reply: no match seq %d\n",seq)); DEB(fprintf(stdout, "psx_reply: no match of seq\n")); return(NULL); } @@ -555,7 +567,7 @@ } /* データ受け取り要求(in,rd,wait)なら受け取り用の箱を用意 */ - if (mode != 'o') { + if (mode != 'o') { if (reply == NULL){ if ((reply = (REPLY *) malloc (sizeof(REPLY))) == NULL){ return(FAIL); @@ -571,7 +583,7 @@ p->seq = (unsigned long)p; // 構造体のアドレスで識別 p->callback = callback; p->obj = obj; - PSX_Debug(("psx_queue: seq %d reply %x p %x r_end %x",seq,reply,p,r_end)); + PSX_Debug(("psx_queue: seq %d reply %p p %p r_end %p\n",p->seq,reply,p,r_end)); } else { p = 0; } @@ -641,11 +653,11 @@ mode = psx_get_mode(tuple); i = psx_get_id(tuple); unsigned int k = psx_get_seq(tuple); - PSX_Debug(("psx_chkserv: anser packet size = %d id %d seq %d", pkt,i,k)); + PSX_Debug(("psx_chkserv: anser packet size = %d id %d seq %d\n", pkt,i,k)); DEB(fprintf(stdout, "psx_chkserv: data from server: %s id=%d seq = %d\n", tuple, i, k)); DEB ( for(p=reply;p;p=p->next) { - PSX_Debug(printf("psx_queue dump: seq %d mode %c %x %x",p->seq,p->mode,p,p->next)); + PSX_Debug(printf("psx_queue dump: seq %d mode %c %x %x\n",p->seq,p->mode,p,p->next)); }) for(prev = NULL,r = reply; r; prev = r,r = r->next){ @@ -666,13 +678,13 @@ } psx_free(r); }else{ // normal reply - PSX_Debug(("psx_chkserv: copy answer r %x seq %d",r,k)); + PSX_Debug(("psx_chkserv: copy answer r %p seq %d\n",r,k)); if(mode == 'a'){ - r->answer = tuple; - }else{ - r->answer = NULL; - } - r->mode = '!'; + r->answer = tuple; + }else{ + r->answer = NULL; + } + r->mode = '!'; } break; } diff -r e622f27c2808 -r 1a5de2a29987 Renderer/Engine/lindaapi.h --- a/Renderer/Engine/lindaapi.h Sat Jul 17 15:09:48 2010 +0900 +++ b/Renderer/Engine/lindaapi.h Mon Jul 26 00:37:26 2010 +0900 @@ -69,6 +69,9 @@ extern int psx_out(unsigned int tspace_id, unsigned int id, unsigned char *data, unsigned int size); +extern int psx_callback_update(unsigned int tspace_id, unsigned int id, + unsigned char *data, unsigned int size, + void(*callback)(unsigned char *,void *),void * obj); extern int psx_ld(unsigned int tspace_id, unsigned int id, char mode, void(*callback)(unsigned char *,void *),void * obj); @@ -76,9 +79,9 @@ #define psx_rd(tid, id) psx_ld(tid, id, 'r', NULL, NULL) #define psx_ck(tid, id) psx_ld(tid, id, 'c', NULL, NULL) #define psx_wait_rd(tid, id) psx_ld(tid, id, 'w', NULL, NULL) +#define psx_update(tid, id, data, size) psx_callback_update(tid, id, data, size, NULL, NULL) #define psx_callback_in(tid, id,callback,obj) psx_ld(tid, id, 'i', callback, obj) #define psx_callback_rd(tid, id,callback,obj) psx_ld(tid, id, 'r', callback, obj) #define psx_callback_ck(tid, id,callback,obj) psx_ld(tid, id, 'c', callback, obj) #define psx_callback_wait_rd(tid, id,callback,obj) psx_ld(tid, id, 'w', callback, obj) - diff -r e622f27c2808 -r 1a5de2a29987 Renderer/Test/Makefile.macosx --- a/Renderer/Test/Makefile.macosx Sat Jul 17 15:09:48 2010 +0900 +++ b/Renderer/Test/Makefile.macosx Mon Jul 26 00:37:26 2010 +0900 @@ -13,7 +13,7 @@ %.pb.cc: $(PROTODIR)/%.proto $(PROTO) $(PROTOFLAGS) $< -ALL = ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum property_test send_linda dynamic writer chain_old SgRootChange viewer aquarium init_aquarium +ALL = ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum property_test send_linda dynamic writer chain_old SgRootChange viewer aquarium init_aquarium test_linda oFLAGS=-g -O2 CFLAGt=-g -O2 @@ -95,6 +95,10 @@ init_aquarium : $(INIT_AQUARIUM_OBJ) $(CC) -o $@ $? $(LIBS) $(PROTOLIBS) +TEST_LINDA_OBJ = aquarium.pb.o test_linda.o +test_linda : $(TEST_LINDA_OBJ) + $(CC) -o $@ $? $(LIBS) $(PROTOLIBS) + run: $(TARGET) sudo ./$(TARGET) -width 576 -height 384 -bpp 32 diff -r e622f27c2808 -r 1a5de2a29987 Renderer/Test/aquarium.cc --- a/Renderer/Test/aquarium.cc Sat Jul 17 15:09:48 2010 +0900 +++ b/Renderer/Test/aquarium.cc Mon Jul 26 00:37:26 2010 +0900 @@ -253,7 +253,7 @@ psx_sync_n(); data = psx_reply(seq); } while (data == NULL); - data[LINDA_HEADER_SIZE + psx_get_datalength(data)] = '\0'; +// data[LINDA_HEADER_SIZE + psx_get_datalength(data)] = '\0'; serial_id = atoi((char *)data + LINDA_HEADER_SIZE); psx_free(data); printf("Get serial_id: %d\n", serial_id);