/*..........................................................................*/ void Q_onAssert(char const * const module, int_t loc) { char message[80]; QF_stop(); /* stop ticking */ QS_ASSERTION(module, loc, (uint32_t)10000U); /* report assertion to QS */ SNPRINTF_S(message, Q_DIM(message) - 1, "Assertion failed in module %s location %d", module, loc); MessageBox(l_hWnd, message, "!!! ASSERTION !!!", MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL); BSP_terminate(-1); }
/* Win32 serial communication with the Target */ QSpyStatus PAL_openTargetSer(char const *comName, int baudRate) { DCB dcb; char comPortName[40]; char comSettings[120]; /* setup the PAL virtual table for the Serial communication... */ PAL_vtbl.getEvt = &ser_getEvt; PAL_vtbl.send2Target = &ser_send2Target; PAL_vtbl.cleanup = &ser_cleanup; /* open serial port (use \\.\COM<num> name to allow large <num>)... */ SNPRINTF_S(comPortName, sizeof(comPortName), "\\\\.\\%s", comName); l_serHNDL = CreateFile(comPortName, GENERIC_READ | GENERIC_WRITE, 0U, /* exclusive access */ NULL, /* no security attrs */ OPEN_EXISTING, 0U, /* standard (not-overlapped) I/O */ NULL); if (l_serHNDL == INVALID_HANDLE_VALUE) { fprintf(stderr, "*** PAL: Error by opening COM port: %s at %d\n", comName, baudRate); return QSPY_ERROR; } /* configure the serial port... */ SNPRINTF_S(comSettings, sizeof(comSettings), "baud=%d parity=N data=8 stop=1 odsr=off dtr=on octs=off rts=on", baudRate); dcb.DCBlength = sizeof(DCB); if (!GetCommState(l_serHNDL, &dcb)) { fprintf(stderr, "*** PAL: Error retreiving COM port settings\n"); return QSPY_ERROR; } /* dill in the DCB... */ dcb.fAbortOnError = 0U; /* don't abort on error */ if (!BuildCommDCB(comSettings, &dcb)) { fprintf(stderr, "*** PAL: Error parsing COM port settings\n"); return QSPY_ERROR; } if (!SetCommState(l_serHNDL, &dcb)) { fprintf(stderr, "*** PAL: Error setting up the COM port\n"); return QSPY_ERROR; } /* setup the serial port buffers... */ SetupComm(l_serHNDL, 4*1024, /* 4K input buffer */ 4*1024); /* 4K output buffer */ /* purge any information in the buffers */ PurgeComm(l_serHNDL, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR); /* the read timeouts for the serial communication are set accorging * to the following remark from the Win32 help documentation: * * If an application sets ReadIntervalTimeout and * ReadTotalTimeoutMultiplier to MAXDWORD and sets * ReadTotalTimeoutConstant to a value greater than zero and less than * MAXDWORD, one of the following occurs when the ReadFile function * is called: * 1. If there are any characters in the input buffer, ReadFile * returns immediately with the characters in the buffer. * 2. If there are no characters in the input buffer, ReadFile waits * until a character arrives and then returns immediately. * 3. If no character arrives within the time specified by * ReadTotalTimeoutConstant, ReadFile times out. */ l_timeouts.ReadIntervalTimeout = MAXDWORD; l_timeouts.ReadTotalTimeoutMultiplier = MAXDWORD; l_timeouts.ReadTotalTimeoutConstant = PAL_TOUT_MS; /* the write timeouts for the serial communication are set accorging * to the following remark from the Win32 help documentation: * * A value of zero for both the WriteTotalTimeoutMultiplier and * WriteTotalTimeoutConstant members indicates that total time-outs * are not used for write operations. * * This means that the WriteFile() returns immediately and the * serial driver must cache any bytes that have not been sent yet. * (see also the output buffer setting for SetupComm() earlier). * * Exceeding the write buffer capacity indicates that the Target * cannot accept all the bytes at this rate. This error will produce * an error message to the screen. */ l_timeouts.WriteTotalTimeoutMultiplier = 0; l_timeouts.WriteTotalTimeoutConstant = 0; SetCommTimeouts(l_serHNDL, &l_timeouts); return QSPY_SUCCESS; }