THREAD_PROC user_thread(void *arg) { char sdata[4096]; Client *C; THREAD_DETACH; if (debug>1) fprintf(stderr, "new user_thread\n"); for (;;) { if (!fgets(sdata, 4095, stdin)) { perror("stdin"); exit (1); } if (debug>1) fprintf(stderr,"term: %s\n", sdata); if (!strncmp(sdata,"crl ",4)) { char *p, *e; for (p=sdata+4; *p==' '; p++); if (e=strchr(p, '\n')) *e = '\0'; ezs_add_crl(p); } else if (!strcmp(sdata,"verbose")) { debug = 1; } else if (!strcmp(sdata,"debug")) { debug = 2; } else if (!strcmp(sdata,"quiet")) { debug = 0; } else if (!strcmp(sdata,"ncc")) { count_clients = 1; } else if (!strcmp(sdata,"cc")) { count_clients = 1; show_client_count(); } else { /* send message to clients */ MUTEX_LOCK(client_lock); for (C=clients; C; C=C->next) { if (debug>1) fprintf(stderr,"add to %d: %s\n", C->no, sdata); add_client_msg(C, sdata); } MUTEX_UNLOCK(client_lock); } if (count_clients) show_client_count(); } exit (1); }
int main (int args, char *argv[]) { if (wiringPiSetup () == -1) exit (1) ; int fd = lcdInit (2, 16, 4, RS, EN, D0,D1,D2,D3,D0,D1,D2,D3) ; if (fd == -1) { printf ("lcdInit 1 failed\n") ; return 1 ; } sleep (1) ; //显示屏初始化 lcdPosition (fd, 0, 0); lcdPuts (fd, " Raspberry Pi!"); //启动信息 sleep(1); if(argv[1]) { lcdPosition (fd, 0, 0) ; lcdPuts (fd, " ") ; //清空第一行 lcdPosition (fd, 0, 0) ; lcdPuts (fd, argv[1]) ; //命令行参数显示至第一行 } int start,now; while(1) { show_date(fd); cls(fd); show_sys_info(fd); sleep(5); cls(fd); start = show_run_time(fd); while(now - start < 5){ now = show_run_time(fd); sleep(1); } cls(fd); show_net_info(fd); sleep(5); cls(fd); show_client_count(fd); sleep(3); cls(fd); show_client_info(fd); cls(fd); show_temp(fd); sleep(5); cls(fd); } return 0; }