/************************************************************************* * *N printer_ok * *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Purpose: *P * This function determines whether the printer is ready and allows * the user to keep retrying or cancel. Must be in graphics mode to call * this function. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Parameters: *A * return <output> == (int) TRUE if ready, FALSE if cancel. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * History: *H * Barry Michaels November 1990 Original Version DOS Turbo C *E *************************************************************************/ int printer_ok( void ) { int retry; char *msg[] = {"Printer not ready"}; while (!printer_ready()) { hidemousecursor(); retry = displayerror(msg,1); showmousecursor(); if (!retry) return FALSE; } return TRUE; }
NetSpyThread::NetSpyThread(TCPNetClient *m_pNetClient) { pClient=NULL; if(m_pNetClient!=NULL) pClient=m_pNetClient; m_bIsRunFlag=false; IsNetConnect = false; NetTimer = new QTimer; connect(pClient->Client,SIGNAL(error(QAbstractSocket::SocketError)), this,SLOT(displayerror(QAbstractSocket::SocketError))); //#显示错误 connect(pClient->Client,SIGNAL(connected()),this,SLOT(NetConnected())); //#连接上时,发射connected()信号 connect(pClient->Client,SIGNAL(disconnected()),this,SLOT(NetNotConnceted())); connect(this->NetTimer,SIGNAL(timeout()),this,SLOT(ReConnect())); connect(this,SIGNAL(NoDataReconnectSig()),this,SLOT(NoDataReconnectSlot())); }
/* * Read the content of the RX queuee * but only evaluate so called error-messages from the driver * which can id is coded as -1. * Such messages are than interpretet by displayerror() */ void read_can(int can_fd) { canmsg_t rx; int i; /* now read the rx queue, it may contain * frames with id -1, which signals an error * read() does block */ do { i = (int)read(can_fd, &rx, 1); if(-1 == i) { perror("read error"); } else if((i > 0) && (CANDRIVERERROR == rx.id)) { displayerror(&rx); } } while(i > 0); /* do {} while(); */ }
void display() { if(err==1) { displayerror(); } else { uchar i; //显示 for(i=0;i<seat;i++) { if(i==dotx) P0=leddot[load[i]];//第dotx位带小数点 else P0=leddp[load[i]]; P2=wey[i]; delay(2); P0=0; } } }
/************************************************************************* * *N vpfopencheck * *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Purpose: *P * This function tries its darndest to open a file. It initially calls * fopen with the given filename and mode. If that doesn't work and * the file is not on the hard disk, it displays a message asking the * user to enter the correct disk in the drive, waits for either a retry * or a cancel response, and, if told to retry, tries again. This * process is repeated until either the file is opened or the user * requests cancel. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Parameters: *A * filename <input> == (char *) full path name of the file to be opened. * mode <input> == (char *) mode of the file. * diskname <input> == (char *) descriptive name of the disk the file is * on. * return <output> == (FILE *) file pointer newly associated with * filename. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * History: *H * Barry Michaels May 1991 DOS Turbo C * Dave Flinn July 1991 Updated for UNIX *E *************************************************************************/ FILE *vpfopencheck( const char *filename, const char *mode, const char * diskname ) { FILE *fp; char* tmpFilename = (char*) malloc ( strlen(filename) + 1 ); /* char *text[] = {"Please insert", " ", "in data drive", " "}; */ ossim_int32 retry = 0; #ifdef __MSDOS__ extern char home[255]; void interrupt (*doshandler)(); doshandler = getvect(36); harderr(vpfhandler); strncpy(text[1],diskname,strlen(text[1])); strcpy(text[3],filename); #endif fp = NULL; /* copy the filename because we might modify it. */ tmpFilename[strlen(filename)] = '\0'; /* just in case */ strcpy(tmpFilename, filename); while (fp == NULL) { fp = fopen(tmpFilename,mode); if (fp == NULL) { #ifdef __MSDOS__ if ( toupper(home[0]) != toupper(tmpFilename[0]) ) retry = displayerror(text, 4); else #else /* give names ending in dot another chance without the dot */ if (tmpFilename[strlen(tmpFilename)-1] == '.') { tmpFilename[strlen(tmpFilename)-1] = '\0'; retry = TRUE; } else #endif retry = FALSE; if (!retry) break; } } free(tmpFilename); tmpFilename = 0; #ifdef __MSDOS__ setvect(36,doshandler); #endif return fp; }
void format_message(int dev, canmsg_t *rx) { int j; char *format; /* switch on line color */ printf("%s", (color && (color < 3)) ? col_on[dev%MAXCOL] : ""); if(rx->id == CANDRIVERERROR) { fprintf(stderr, "%10s: CAN Error, ", devname[dev]); displayerror(dev, rx); } else { /* no error */ printf("%10s: %12lu.%06lu %8ld/0x%08lx", devname[dev], rx->timestamp.tv_sec, rx->timestamp.tv_usec, rx->id, rx->id); if(rx->flags & MSG_CANFD ) { format = " : %c%c [%2d]:"; } else { format = " : %c%c (%2d):"; } printf(format, (rx->flags & MSG_EXT) ? 'e' : 'b', (rx->flags & MSG_RTR) ? 'R' : 'D', rx->length ); if( !(rx->flags & MSG_RTR) ) { /* For CAN FD we have to calculate the number of bytes to display according the information of the data length code (dlc) */ if(!(rx->flags & MSG_CANFD) && (rx->length > 8)) { rx->length = 8; /* restrict to 8 byte */ } if(rx->flags & MSG_CANFD) { switch(rx->length) { case 9: rx->length = 12; break; case 10: rx->length = 16; break; case 11: rx->length = 20; break; case 12: rx->length = 24; break; case 13: rx->length = 32; break; case 14: rx->length = 48; break; case 15: rx->length = 64; break; default: fprintf(stderr, "unknown dlc %d\n", rx->length); break; } } for(j = 0; j < rx->length; j++) { printf(" %02x", rx->data[j]); } } } /* switch back color */ printf("%s\n", (color > 0) ? col_off :""); fflush(stdout); }