static int avrdoper_send(union filedescriptor *fdp, unsigned char *buf, size_t buflen) { if(verbose > 3) dumpBlock("Send", buf, buflen); while(buflen > 0){ unsigned char buffer[256]; int rval, lenIndex = chooseDataSize(buflen); int thisLen = buflen > reportDataSizes[lenIndex] ? reportDataSizes[lenIndex] : buflen; buffer[0] = lenIndex + 1; /* report ID */ buffer[1] = thisLen; memcpy(buffer + 2, buf, thisLen); if(verbose > 3) fprintf(stderr, "Sending %d bytes data chunk\n", thisLen); rval = usbSetReport(fdp, USB_HID_REPORT_TYPE_FEATURE, (char *)buffer, reportDataSizes[lenIndex] + 2); if(rval != 0){ fprintf(stderr, "%s: avrdoper_send(): %s\n", progname, usbErrorText(rval)); exit(1); } buflen -= thisLen; buf += thisLen; } return 0; }
/** @internal @brief Process a function. If the required parts are detected (see flushParser()), this function is called to process the collected information and output the function in the tBuffer. @param[in,out] buf the tBuffer to process */ static void processFunction(tBuffer *buf) { tRange name; char type[200]; bool isStatic; /* fixup the description range, if there isn't one. makes subsequent code simpler. */ if (buf->description.count == 0) { buf->description.start = buf->function.start - 1; buf->description.end = buf->description.start; } /* emit up to the beginning of the description */ dumpBlock(buf, buf->data, buf->description.start); name.start = buf->function.start; name.end = buf->function.end; processTyped(type, sizeof(type), &isStatic, NULL, &name); fprintf(buf->file, "\n/**\n%s\t", isStatic ? "\t@internal\n\n" : ""); processDescription(buf); processArgList(buf); if (strcmp(type,"void") != 0) { fprintf(buf->file, "\n\t@return %s", type); dumpStringList(buf->file, buf->retvals, "\t@retval "); fprintf(buf->file, "\n"); } dumpStringList(buf->file, buf->todos,"\t@todo "); fprintf(buf->file, "\n\t@todo edit me (automatically generated by insertdox)\n*/"); if (gOptions.onlyPrototypes) { dumpBlock(buf, buf->description.end, buf->arglist.end); fprintf(buf->file, ";\n\n"); } else { dumpBlock(buf, buf->description.end, buf->ptr); } }
task main() { initializeRobot(); RNRR_waitForStart(); init_path(); add_segment(28, 0, 100); add_segment(27, 45, 100); stop_path(); dead_reckon(); dumpBlock(); while (true) { } }
/** @internal @brief Process a function's argument list. Generates a list of \@param tags from the list of arguments to a function. @note Does not emit 'void'. @param[in,out] buf the tBuffer to process @see processTyped() */ static void processArgList(tBuffer *buf) { tRange name; char type[200]; char *s = buf->arglist.start; char *e = buf->arglist.end; char *p; bool inOnly; bool saidSomething = false; while (s < e && (isspace(*s) || *s == '(')) { ++s; } p = s; while (p < e) { switch (*p) { case ',': /* list seperator */ case ')': /* list terminator */ name.start = s; name.end = p; processTyped(type, sizeof(type), NULL, &inOnly, &name); if ((name.end - name.start) != 4 || strncmp(name.start, "void", 4) != 0) { /* not 'void', so output it */ fprintf(buf->file, "\n\t@param[in%s] \t", inOnly? "" : ",out"); dumpBlock(buf, name.start, name.end); fprintf(buf->file," \t%s",type); saidSomething = true; } s = p + 1; break; } ++p; } if (saidSomething) fprintf(buf->file, "\n"); }
task main() { int basketNumber; bool done = false; initializeRobot(); waitForStart(); // Wait for the beginning of autonomous phase. wait1Msec(10000); disableDiagnosticsDisplay(); eraseDisplay(); basketNumber = findIRBeacon(); nxtDisplayTextLine(5, "Beacon #%d", basketNumber); wait1Msec(300); if (basketNumber != -1) { if (compensation[basketNumber] < 0) { moveForward(abs(compensation[basketNumber]), 60); } else { moveBackward(compensation[basketNumber], 60); } /*for (int i = 0; i <= basketNumber; i++) { displayCaution(); wait1Msec(500); displayBackward(); wait1Msec(500); } displayRestingPulse(); */ dumpBlock(); } else { basketNumber = 3; } //moveToRamp(basketNumber); while (true) {} }
/** @internal @brief Process an existing file comment. If the file starts with a comment, this routine is called to process and output it. Mostly it just strips any extraneous punctuation (like rows of astrisks), injects the boilerplate, and wraps it with the right markers to make it a Doxygen comment block. @param[in,out] buf the tBuffer to process */ static void processFileComment(tBuffer *buf) { char *s, *e; /* trim off any punctuation and whitespace */ s = buf->data; e = buf->ptr; s = skipComment(s,e); e = trimComment(e,s); /* emit the original comment */ fprintf(buf->file, "/**\n\t"); dumpBlock(buf, s, e); fprintf(buf->file, "\n"); /* emit boilerplate, if any */ processBoilerplate(buf); fprintf(buf->file, "\n*/\n"); }
static int avrdoper_recv(union filedescriptor *fdp, unsigned char *buf, size_t buflen) { unsigned char *p = buf; int remaining = buflen; while(remaining > 0){ int len, available = avrdoperRxLength - avrdoperRxPosition; if(available <= 0){ /* buffer is empty */ avrdoperFillBuffer(fdp); continue; } len = remaining < available ? remaining : available; memcpy(p, avrdoperRxBuffer + avrdoperRxPosition, len); p += len; remaining -= len; avrdoperRxPosition += len; } if(verbose > 3) dumpBlock("Receive", buf, buflen); return 0; }
/** @internal @brief Flush a tBuffer, and check for special processing. This function determines if the tBuffer contains something that requires special processing, calls it if it does, or just outputs it unmodified if not. @param[in,out] buf the tBuffer to process */ static void flushBuffer(tBuffer *buf) { if (buf->ptr > buf->data) { if (buf->fileComment) { processFileComment(buf); } else if (buf->function.count == 1 && buf->arglist.count == 1 && buf->body.count == 1) { processFunction(buf); } else if (!gOptions.onlyPrototypes) { dumpBlock(buf, buf->data, buf->ptr); } } clearBuffer(buf); }
/** @internal @brief Processes the function's original comment (if any) This function just trims the original comment, or generates a placeholder if there wasn't one. @note If you have an pre-existing comment formatting convention and want to automatically convert it, this is the place to do it. @param[in,out] buf the tBuffer to process */ static void processDescription(tBuffer *buf) { char *s, *e; if (buf->description.count > 0) { /* trim off any punctuation and whitespace */ s = buf->description.start; e = buf->description.end; s = skipComment(s,e); e = trimComment(e,s); if ( s == e) { /* there's nothing left after trimming, thus it's an empty comment! so we change our mind, and generate a placeholder after all */ buf->description.count = 0; } else { /*>>> detect and convert any pre-existing comment formatting convention here <<<*/ /* emit the original comment */ dumpBlock(buf, s, e); } } if (buf->description.count == 0) { /* inject a placeholder */ fprintf(buf->file, "Brief description needed."); fprintf(buf->file, "\n\n\tFollowed by a more complete description."); } fprintf(buf->file, "\n"); }
void dumpData(MLan *mlan, uchar *serial) { uchar data[DATA_SIZE]; uchar buffer[33]; int i=0, j=0, k=0; assert(mlan); assert(serial); for(i=START_PAGE; i<START_PAGE+16; i++) { memset(buffer, 0x00, sizeof(buffer)); /* Read the page */ mlan->getBlock(mlan, serial, i, 1, buffer); /* Do the actual copy */ for(k=0; k<32; k++) { assert(j<DATA_SIZE); data[j++]=buffer[k]; } } dumpBlock(data, DATA_SIZE); }
status_t device_write(void *data, off_t pos, const void *buffer, size_t *_length) { struct sis_info *info; status_t status; uint16 frameSize; int16 current; uint32 check; if (checkDeviceInfo(info = data) != B_OK) return EINVAL; //TRACE(("****\t%5ld: write... %lx, %ld (%d) thread: %ld, counter = %ld\n", counter++, buf, *len, info->txLock, threadID, intrCounter)); atomic_add(&info->txLock, 1); if (*_length > MAX_FRAME_SIZE) *_length = MAX_FRAME_SIZE; frameSize = *_length; current = info->txCurrent; //dprintf("\t%5ld: \twrite: tx: isr = %d, sent = %d, current = %d\n",counter++, // info->txInterruptIndex,info->txSent,info->txCurrent); // block until a free tx descriptor is available if ((status = acquire_sem_etc(info->txSem, 1, B_TIMEOUT, ETHER_TRANSMIT_TIMEOUT)) < B_NO_ERROR) { write32(info->registers + SiS900_MAC_COMMAND, SiS900_MAC_CMD_Tx_ENABLE); TRACE(("write: acquiring sem failed: %lx, %s\n", status, strerror(status))); atomic_add(&info->txLock, -1); return status; } check = info->txDescriptor[current].status; if (check & SiS900_DESCR_OWN) { // descriptor is still in use dprintf(DEVICE_NAME ": card owns buffer %d\n", current); atomic_add(&info->txLock, -1); return B_ERROR; } /* Copy data to tx buffer */ memcpy((void *)info->txBuffer[current], buffer, frameSize); info->txCurrent = (current + 1) & NUM_Tx_MASK; { cpu_status former; former = disable_interrupts(); acquire_spinlock(&info->txSpinlock); info->txDescriptor[current].status = SiS900_DESCR_OWN | frameSize; info->txSent++; #if 0 { struct buffer_desc *b = (void *)read32(info->registers + SiS900_MAC_Tx_DESCR); int16 that; dprintf("\twrite: status %d = %lx, sent = %d\n", current, info->txDescriptor[current].status,info->txSent); dprintf("write: %d: mem = %lx : hardware = %lx\n", current, physicalAddress(&info->txDescriptor[current],sizeof(struct buffer_desc)),read32(info->registers + SiS900_MAC_Tx_DESCR)); for (that = 0;that < NUM_Tx_DESCR && (void *)physicalAddress(&info->txDescriptor[that],sizeof(struct buffer_desc)) != b;that++); if (that == NUM_Tx_DESCR) { //dprintf("not in ring!\n"); that = 0; } dprintf("(hardware status %d = %lx)!\n", that, info->txDescriptor[that].status); } #endif release_spinlock(&info->txSpinlock); restore_interrupts(former); } // enable transmit state machine write32(info->registers + SiS900_MAC_COMMAND, SiS900_MAC_CMD_Tx_ENABLE); #ifdef EXCESSIVE_DEBUG acquire_sem(gIOLock); bug("\t\twrite last interrupts:\n"); { int ii; for (ii = (intrCounter-2) % 100; ii < intrCounter; ii = (ii + 1) % 100) bug("\t\t\t%ld: %08lx\n", ii, lastIntr[ii % 100]); } bug("\t\twrite block (%ld bytes) thread = %ld:\n", frameSize, threadID); dumpBlock(buf,frameSize, "\t\t\t"); release_sem(gIOLock); #endif atomic_add(&info->txLock, -1); return B_OK; }