void tick() { tick_counter++; printNewLine(); printString("TICK "); printUInt(tick_counter); printNewLine(); }
void keyboard() { char *keypress_message_first_half; char *keypress_message_second_half; keypress_message_first_half = "KEYPERSS ("; keypress_message_second_half = ") IGNORED"; printNewLine(); printString(keypress_message_first_half); printChar(KeyBuffer); printString(keypress_message_second_half); printNewLine(); }
//? void extern tick() void tick() { char *tick_message; tick_message = "TICK "; ++t; printNewLine(); printString(tick_message); printUInt(t); printNewLine(); //Decrement one from each TCB in Suspended list YKTickHandler(); }
void keyboard() { int delayCounter = 0; if (KeyBuffer != 'd') { printNewLine(); printString("KEPYRESS ("); printChar(KeyBuffer); printString(") IGNORED"); printNewLine(); } else { printNewLine(); printString("DELAY KEY PRESSED"); printNewLine(); while (delayCounter <= 5000) { delayCounter++; } printString("DELAY COMPLETE"); printNewLine(); } }
void printAllLists() { char* printinglists; char* rlist; char* slist; printinglists = "PRINTING LISTS"; rlist = "ReadyList:"; slist = "SuspendedList:"; printNewLine(); printString(printinglists); printNewLine(); printNewLine(); printString(rlist); printNewLine(); printList(YKReadyList); printString(slist); printNewLine(); printList(YKSuspList); }
void TaskPrime(void) /* task that actually computes primes */ { //stops at 32497 int curval = 1001; int j,flag,lncnt; int endval; while (1) { YKSemPend(NSemPtr); /* compute next range of primes */ lncnt = 0; endval = curval + 500; for ( ; curval < endval; curval += 2) { flag = 0; for (j = 3; (j*j) < curval; j += 2) { if (curval % j == 0) { flag = 1; break; } } if (!flag) { printChar(' '); printInt(curval); lncnt++; if (lncnt > 9) { printNewLine(); lncnt = 0; } } } printNewLine(); } }
void PiLink::debugMessage(const char * message, ...){ va_list args; //print 'D:' as prefix printResponse('D'); // Using print_P for the Annotation fails. Arguments are not passed correctly. Use Serial directly as a work around. va_start (args, message ); vsnprintf_P(printfBuff, PRINTF_BUFFER_SIZE, message, args); va_end (args); piStream.print(printfBuff); printNewLine(); }
int print_ready_list(void) { int count = 0; tcb_t* iter = YKRdyList; while( iter ) { printInt( iter->priority ); printNewLine(); iter = iter->next; ++count; } return count; }
/* Function declarations */ void printList(TCBptr list) { TCBptr tcb = list; int safety = 0; // printString("Active tasks: "); // printInt(activeTasks); while(tcb != NULL && safety < (activeTasks + 10)) { printString(" Task P: "); printInt(tcb->priority); // printNewLine(); tcb = tcb->next; safety++; } printNewLine(); }
void tickHandler(void) { unsigned int localCounter; tickClock(); YKEnterMutex(); localCounter = ++YKTickCounter; YKExitMutex(); printString("\nTick: "); printInt(localCounter); printNewLine(); }
void YKTickHandler(void){ TCBptr temp, temp2, next; YKEnterMutex(); YKTickNum++; print("\nTick ", 6); printInt(YKTickNum); printNewLine(); temp = YKSuspList; while (temp != NULL){ temp->delay--; if (temp->delay == 0){ // If the task has delayed the appropriate amount of ticks temp->state = READY; // Make the task ready next = temp->next; // Store the temp's next so you don't lose it // Remove from Susp List if (temp->prev == NULL){ YKSuspList = temp->next; } else{ temp->prev->next = temp->next; } if (temp->next != NULL){ temp->next->prev = temp->prev; } // Put in Rdy List temp2 = YKRdyList; while (temp2->priority < temp->priority){ temp2 = temp2->next; } if (temp2->prev == NULL){ YKRdyList = temp; } else{ temp2->prev->next = temp; } temp->prev = temp2->prev; temp->next = temp2; temp2->prev = temp; // Update the next pointer temp = next; } else{ temp = temp->next; } } YKExitMutex(); }
void printList(TCBptr list) { TCBptr current; char * priority; char * delay; current = list; priority = "\tpriority = "; delay = " delay = "; while(current != NULL) { printString(priority); printInt(current->priority); printString(delay); printInt(current->delay); printNewLine(); current = current->next; } }
int print_delay_list(void) { int count = 0; tcb_t* iter = YKBlockList; while( iter ) { printInt( iter->priority ); if (iter->state == DELAYED) { printString( " Delay: " ); printInt( iter->delay ); } else if (iter->state == SEMAPHORE) { printString( " Semaphore: " ); printInt( iter->semaphore->value ); } printNewLine(); iter = iter->next; ++count; } return count; }
void PiLink::sendJsonClose() { piStream.print('}'); printNewLine(); }
void PiLink::closeListResponse() { piStream.print(']'); printNewLine(); }
void PiLink::receive(void){ while (piStream.available() > 0) { char inByte = piStream.read(); switch(inByte){ case ' ': case '\n': case '\r': break; #if BREWPI_SIMULATE==1 case 'y': parseJson(HandleSimulatorConfig); break; case 'Y': printSimulatorSettings(); break; #endif case 'A': // alarm on soundAlarm(true); break; case 'a': // alarm off soundAlarm(false); break; case 't': // temperatures requested printTemperatures(); break; case 'C': // Set default constants tempControl.loadDefaultConstants(); display.printStationaryText(); // reprint stationary text to update to right degree unit sendControlConstants(); // update script with new settings logInfo(INFO_DEFAULT_CONSTANTS_LOADED); break; case 'S': // Set default settings tempControl.loadDefaultSettings(); sendControlSettings(); // update script with new settings logInfo(INFO_DEFAULT_SETTINGS_LOADED); break; case 's': // Control settings requested sendControlSettings(); break; case 'c': // Control constants requested sendControlConstants(); break; case 'v': // Control variables requested, send Control Object as json sendControlVariables(); break; case 'n': // v version // s shield type // y: simulator // b: board print_P(PSTR( "N:{" "\"v\":\"" PRINTF_PROGMEM "\"," "\"n\":\"" PRINTF_PROGMEM "\"," "\"s\":%d," "\"y\":%d," "\"b\":\"%c\"," "\"l\":\"%d\"" "}"), PSTR(VERSION_STRING), // v: PSTR(stringify(BUILD_NAME)), // n: getShieldVersion(), // s: BREWPI_SIMULATE, // y: BREWPI_BOARD, // b: BREWPI_LOG_MESSAGES_VERSION); // l: printNewLine(); break; case 'l': // Display content requested printResponse('L'); piStream.print('['); char stringBuffer[21]; for(uint8_t i=0;i<4;i++){ display.getLine(i, stringBuffer); print_P(PSTR("\"%s\""), stringBuffer); char close = (i<3) ? ',':']'; piStream.print(close); } printNewLine(); break; case 'j': // Receive settings as json receiveJson(); break; #if BREWPI_EEPROM_HELPER_COMMANDS case 'e': // dump contents of eeprom openListResponse('E'); for (uint16_t i=0; i<1024;) { if (i>0) { piLink.printNewLine(); piLink.print(','); } piLink.print('\"'); for (uint8_t j=0; j<64; j++) { uint8_t d = eepromAccess.readByte(i++); printNibble(d>>4); printNibble(d); } piLink.print('\"'); } closeListResponse(); break; #endif case 'E': // initialize eeprom eepromManager.initializeEeprom(); logInfo(INFO_EEPROM_INITIALIZED); settingsManager.loadSettings(); break; case 'd': // list devices in eeprom order openListResponse('d'); deviceManager.listDevices(piStream); closeListResponse(); break; case 'U': // update device deviceManager.parseDeviceDefinition(piStream); break; case 'h': // hardware query openListResponse('h'); deviceManager.enumerateHardwareToStream(piStream); closeListResponse(); break; #if (BREWPI_DEBUG > 0) case 'Z': // zap eeprom eepromManager.zapEeprom(); logInfo(INFO_EEPROM_ZAPPED); break; #endif case 'R': // reset handleReset(); break; case 'F': // flash firmware flashFirmware(); break; default: logWarningInt(WARNING_INVALID_COMMAND, inByte); } } }