comparison Renderer/Test/dynamic_create.cc @ 610:529188ae604d

change htonl to xdr_float (checked working on mac)
author kazz@kazzone.st.ie.u-ryukyu.ac.jp
date Sun, 08 Nov 2009 03:30:06 +0900
parents 8782cc4171b7
children 000a3bd205d1
comparison
equal deleted inserted replaced
609:6b865e046710 610:529188ae604d
5 #include <sys/types.h> 5 #include <sys/types.h>
6 #include <sys/mman.h> 6 #include <sys/mman.h>
7 #include <sys/stat.h> 7 #include <sys/stat.h>
8 #include <unistd.h> 8 #include <unistd.h>
9 #include <arpa/inet.h> 9 #include <arpa/inet.h>
10 #include <rpc/types.h>
11 #include <rpc/xdr.h>
10 #include "SceneGraphRoot.h" 12 #include "SceneGraphRoot.h"
11 #include "lindaapi.h" 13 #include "lindaapi.h"
12 #include "dynamic_create.h" 14 #include "dynamic_create.h"
13 15
14 #define PORT 10000 16 #define PORT 10000
15 17
16 #define SERIAL_REGIST_TUPLE_NO 1 18 #define SERIAL_REGIST_TUPLE_NO 1
19
20 #define RECV_DATA_SIZE sizeof(float) * 6
17 21
18 /* 22 /*
19 typedef struct { 23 typedef struct {
20 caddr_t file_mmap; 24 caddr_t file_mmap;
21 off_t size; 25 off_t size;
82 86
83 static void 87 static void
84 moon_move(SceneGraphPtr node, int screen_w, int screen_h) 88 moon_move(SceneGraphPtr node, int screen_w, int screen_h)
85 { 89 {
86 // LindaServerから座標データを取得してオブジェクトに反映させる。 90 // LindaServerから座標データを取得してオブジェクトに反映させる。
87 // static int seq = 0;
88 // float *reply;
89
90 // if (seq == 0)
91 // seq = psx_wait_rd(sgroot->tid, node->id * 10 + 1);
92 unsigned char *reply = psx_reply(node->seq); 91 unsigned char *reply = psx_reply(node->seq);
93 if (reply != NULL) { 92 if (reply != NULL) {
94 float *data = (float *)(reply + LINDA_HEADER_SIZE); 93 char *data = (char *)(reply + LINDA_HEADER_SIZE);
94 // XDRの準備
95 XDR xdrs;
96 xdrmem_create(&xdrs, data, RECV_DATA_SIZE, XDR_DECODE);
95 // ntoh_float(&data[0]); ntoh_float(&data[1]); 97 // ntoh_float(&data[0]); ntoh_float(&data[1]);
96 for (int i = 0; i < 3; i++) { 98 for (int i = 0; i < 3; i++) {
97 node->xyz[i] = ntohl(data[i]); 99 xdr_float(&xdrs, &node->xyz[i]);
98 } 100 }
99 node->seq = psx_wait_rd(sgroot->tid, node->id * 10 + 1); 101 node->seq = psx_wait_rd(sgroot->tid, node->id * 10 + 1);
100 } 102 }
101 } 103 }
102 104
146 148
147 // 最初の4byteデータは使わない 149 // 最初の4byteデータは使わない
148 data = taple + LINDA_HEADER_SIZE; 150 data = taple + LINDA_HEADER_SIZE;
149 // clientのSerialIDを取得 151 // clientのSerialIDを取得
150 serial_id = ntohl(*(int *)data); 152 serial_id = ntohl(*(int *)data);
151 printf("serial id = %d\n", serial_id); 153 printf("serial id = %d\n", serial_id); // タプルを解放
152 // タプルを解放
153 //psx_del(carg->tid, SERIAL_REGIST_TUPLE_NO); 154 //psx_del(carg->tid, SERIAL_REGIST_TUPLE_NO);
154 155
155 // xml fileを取得する もうすでにxml fileが送信済みである事を期待 156 // xml fileを取得する もうすでにxml fileが送信済みである事を期待
156 // つまり、送信者がserial_idを送る前にxml fileを送信していなくてはならない 157 // つまり、送信者がserial_idを送る前にxml fileを送信していなくてはならない
157 xml_id = serial_id * 10; 158 xml_id = serial_id * 10;