void CLCD::init(const char * fontfile, const char * fontname, const char * fontfile2, const char * fontname2, const char * fontfile3, const char * fontname3) { InitNewClock(); if (!lcdInit(fontfile, fontname, fontfile2, fontname2, fontfile3, fontname3 )) { printf("[lcdd] LCD-Init failed!\n"); return; } if (pthread_create (&thrTime, NULL, TimeThread, NULL) != 0 ) { perror("[lcdd]: pthread_create(TimeThread)"); return ; } }
void CLCD::init(const char *fontfile, const char *fontfile2, const char *fontfile3) { InitNewClock(); if (!lcdInit(fontfile, fontfile2, fontfile3)) { printf("[lcdd] LCD-Init failed!\n"); #ifndef BOXMODEL_DM500 // on the dm500, we need the timethread for the front LEDs return; #endif } if (pthread_create (&thrTime, NULL, TimeThread, NULL) != 0 ) { perror("[lcdd]: pthread_create(TimeThread)"); return ; } }
int CLCDD::main(int argc, char **argv) { debugoutput = true; printf("Network LCD-Driver $Id: lcdd.cpp,v 1.57 2002/10/17 10:16:35 thegoodguy Exp $\n\n"); InitNewClock(); loadConfig(); if(!lcdPainter.init()) { //fehler beim lcd-init aufgetreten return -1; } //network-setup int listenfd, connfd; struct sockaddr_un servaddr; int clilen; std::string filename = LCDD_UDS_NAME; memset(&servaddr, 0, sizeof(struct sockaddr_un)); servaddr.sun_family = AF_UNIX; strcpy(servaddr.sun_path, filename.c_str()); clilen = sizeof(servaddr.sun_family) + strlen(servaddr.sun_path); unlink(filename.c_str()); //network-setup if ((listenfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { perror("socket"); return -1; } if ( bind(listenfd, (struct sockaddr*) &servaddr, clilen) <0 ) { perror("[lcdd] bind failed...\n"); return -1; } if (listen(listenfd, 5) !=0) { perror("[lcdd] listen failed...\n"); return -1; } switch (fork()) { case -1: /* can't fork */ perror("[lcdd] fork"); return -1; case 0: /* child, process becomes a daemon */ if (setsid() == -1) { perror("[lcdd] setsid"); return -1; } break; default: /* parent returns to calling process */ return 0; } signal(SIGHUP,sig_catch); signal(SIGINT,sig_catch); signal(SIGQUIT,sig_catch); signal(SIGTERM, sig_catch); /* Thread erst nach dem forken erstellen, da sonst Abbruch */ if (pthread_create (&thrTime, NULL, TimeThread, NULL) != 0 ) { perror("[lcdd]: pthread_create(TimeThread)"); return -1; } shall_exit = false; while(!shall_exit) { connfd = accept(listenfd, (struct sockaddr*) &servaddr, (socklen_t*) &clilen); CLcddMsg::Header rmsg; read(connfd,&rmsg,sizeof(rmsg)); parse_command(connfd, rmsg); close(connfd); } close(listenfd); saveConfig(); return 0; }