void server_loop(void) { int client_connected; msgType dialog_type; char *message = (char *) malloc(512); // did the disc change? if (bd_contains_sacd_disc && bd_disc_changed) { bd_contains_sacd_disc = 0; } // by default we have no user controls dialog_type = (MSG_DIALOG_NORMAL | MSG_DIALOG_DISABLE_CANCEL_ON); if (!bd_contains_sacd_disc) { union net_ctl_info info; if(netCtlGetInfo(NET_CTL_INFO_IP_ADDRESS, &info) == 0) { sprintf(message, " SACD Daemon %s\n\n" "Status: Active\n" "IP Address: %s (port 2002)\n" "Client: %s\n" "Disc: %s", SACD_RIPPER_VERSION_STRING, info.ip_address, (is_client_connected() ? "connected" : "none"), (bd_disc_changed == -1 ? "empty" : "inserted")); } else { sprintf(message, "No active network connection was detected.\n\nPress OK to refresh."); dialog_type |= MSG_DIALOG_BTN_TYPE_OK; } } msgDialogOpen2(dialog_type, message, dialog_handler, NULL, NULL); dialog_action = 0; bd_disc_changed = 0; client_connected = is_client_connected(); while (!dialog_action && !user_requested_exit() && bd_disc_changed == 0 && client_connected == is_client_connected()) { sysUtilCheckCallback(); flip(); } msgDialogAbort(); free(message); }
int main4() { int cnt = 1000000; start_pres_server(); struct sched_pres *sp = (struct sched_pres*)buf; uint8 no = 0; while(1) { INFO("\033[1;33mtcp server... main4\033[0m \n"); if(!is_client_connected() && !have_packet()) { no = 0; DEBUG("no client!\n"); usleep(1000000); } if(have_packet()) { int len = get_packet(buf, MAX_LEN); CHECK2(len >=23 && len == sp->pkt_len); INFO("Get a packet!\n dst_tel_code:%x\nsrc_tel_code:%x\n" "pkt_len:%d\nno%d\ntime:%s\ndata_type:%x\ndata_sub_type:%x\n" "test_len:%d\n", sp->dst_tel_code, sp->src_tel_code, sp->pkt_len, sp->no, ctime(&sp->time), sp->data_type, sp->data_sub_type, sp->text_len); int i; uint8 c = 0; no++; // DEBUG("should no:%d RECV_NO:%d\n", no, sp->no); // CHECK2(no==sp->no); for(i = 0; i < sp->text_len; i++) { if(sp->data[i] != c) { DEBUG("i = %d sp->data[i]==%d c==%d\n", i, sp->data[i], c); CHECK2(sp->data[i]==c); } c++; } } usleep(10000); } stop_pres_server(); }