Changeset 115
- Timestamp:
- 05/16/07 17:57:31 (2 years ago)
- Files:
-
- trunk/libcwiid/connect.c (modified) (5 diffs)
- trunk/libcwiid/cwiid_internal.h (modified) (3 diffs)
- trunk/libcwiid/process.c (modified) (2 diffs)
- trunk/libcwiid/thread.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libcwiid/connect.c
r112 r115 16 16 * 17 17 * ChangeLog: 18 * 2007-05-16 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * remove error_pipe init and destruct 20 * 18 21 * 2007-04-24 L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * rewrite for API overhaul … … 59 62 struct wiimote *wiimote = NULL; 60 63 struct sockaddr_l2 remote_addr; 61 char mesg_pipe_init = 0, status_pipe_init = 0, error_pipe_init = 0,62 rw_pipe_init = 0, state_mutex_init = 0, rw_mutex_init = 0,63 r pt_mutex_init = 0, router_thread_init = 0, status_thread_init = 0;64 char mesg_pipe_init = 0, status_pipe_init = 0, rw_pipe_init = 0, 65 state_mutex_init = 0, rw_mutex_init = 0, rpt_mutex_init = 0, 66 router_thread_init = 0, status_thread_init = 0; 64 67 void *pthread_ret; 65 68 … … 136 139 } 137 140 status_pipe_init = 1; 138 if (pipe(wiimote->error_pipe)) {139 cwiid_err(wiimote, "Pipe creation error (error pipe)");140 goto ERR_HND;141 }142 error_pipe_init = 1;143 141 if (pipe(wiimote->rw_pipe)) { 144 142 cwiid_err(wiimote, "Pipe creation error (rw pipe)"); … … 248 246 } 249 247 } 250 if (error_pipe_init) {251 if (close(wiimote->error_pipe[0]) ||252 close(wiimote->error_pipe[1])) {253 cwiid_err(wiimote, "Pipe close error (error pipe)");254 }255 }256 248 if (rw_pipe_init) { 257 249 if (close(wiimote->rw_pipe[0]) || close(wiimote->rw_pipe[1])) { … … 329 321 cwiid_err(wiimote, "Pipe close error (status pipe)"); 330 322 } 331 if (close(wiimote->error_pipe[0]) || close(wiimote->error_pipe[1])) {332 cwiid_err(wiimote, "Pipe close error (error pipe)");333 }334 323 if (close(wiimote->rw_pipe[0]) || close(wiimote->rw_pipe[1])) { 335 324 cwiid_err(wiimote, "Pipe close error (rw pipe)"); trunk/libcwiid/cwiid_internal.h
r112 r115 16 16 * 17 17 * ChangeLog: 18 * 2007-05-16 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * remove error_pipe 20 * * add struct mesg_array to process_error 21 * 18 22 * 2007-05-14 L. Donnie Smith <cwiid@abstrakraft.org> 19 23 * * added timestamp to mesg_array … … 176 180 int mesg_pipe[2]; 177 181 int status_pipe[2]; 178 int error_pipe[2];179 182 int rw_pipe[2]; 180 183 struct cwiid_state state; … … 208 211 209 212 /* process.c */ 210 int process_error(struct wiimote *, ssize_t );213 int process_error(struct wiimote *, ssize_t, struct mesg_array *); 211 214 int process_status(struct wiimote *, const unsigned char *, 212 215 struct mesg_array *); trunk/libcwiid/process.c
r101 r115 16 16 * 17 17 * ChangeLog: 18 * 2007-05-16 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * process_err adds error_mesg to mesg_array 20 * 18 21 * 2007-04-24 L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * created for API overhaul (moved from old event.c) … … 23 26 #include "cwiid_internal.h" 24 27 25 int process_error(struct wiimote *wiimote, ssize_t len )26 { 27 struct cwiid_error_mesg error_mesg;28 int ret = 0; 29 30 error_mesg .type = CWIID_MESG_ERROR;28 int process_error(struct wiimote *wiimote, ssize_t len, struct mesg_array *ma) 29 { 30 struct cwiid_error_mesg *error_mesg; 31 32 error_mesg = &ma->array[ma->count++].error_mesg; 33 error_mesg->type = CWIID_MESG_ERROR; 31 34 if (len == 0) { 32 error_mesg .error = CWIID_ERROR_DISCONNECT;35 error_mesg->error = CWIID_ERROR_DISCONNECT; 33 36 } 34 37 else { 35 error_mesg.error = CWIID_ERROR_COMM; 36 } 37 38 if (write(wiimote->error_pipe[1], &error_mesg, sizeof error_mesg) 39 != sizeof error_mesg) { 40 cwiid_err(wiimote, "Error pipe write error"); 41 ret = -1; 38 error_mesg->error = CWIID_ERROR_COMM; 42 39 } 43 40 44 41 if (cancel_rw(wiimote)) { 45 42 cwiid_err(wiimote, "RW cancel error"); 46 ret = -1; 47 } 48 49 return ret; 43 } 44 45 return 0; 50 46 } 51 47 trunk/libcwiid/thread.c
r112 r115 16 16 * 17 17 * ChangeLog: 18 * 2007-05-16 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * send error_mesg from process_error 20 * 18 21 * 2007-05-14 L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * added timestamp to message array … … 68 71 /* Read packet */ 69 72 len = read(wiimote->int_socket, buf, READ_BUF_LEN); 73 ma.count = 0; 74 if (clock_gettime(CLOCK_REALTIME, &ma.timestamp)) { 75 if (print_clock_err) { 76 cwiid_err(wiimote, "clock_gettime error"); 77 print_clock_err = 0; 78 } 79 } 80 err = 0; 70 81 if ((len == -1) || (len == 0)) { 71 process_error(wiimote, len); 82 process_error(wiimote, len, &ma); 83 write_mesg_array(wiimote, &ma); 72 84 /* Quit! */ 73 85 break; … … 78 90 cwiid_err(wiimote, "Invalid packet type"); 79 91 } 80 ma.count = 0;81 if (clock_gettime(CLOCK_REALTIME, &ma.timestamp)) {82 if (print_clock_err) {83 cwiid_err(wiimote, "clock_gettime error");84 print_clock_err = 0;85 }86 }87 err = 0;88 92 89 93 /* Main switch */ … … 155 159 } 156 160 if (wiimote->flags & CWIID_FLAG_MESG_IFC) { 157 if (write_mesg_array(wiimote, &ma)) { 158 /* prints its own errors */ 159 } 161 /* prints its own errors */ 162 write_mesg_array(wiimote, &ma); 160 163 } 161 164 }
