SharedObjectP SharedObjectHandler::getOSGSharedObject( const TChar *szName) { SharedObjectP returnValue = NULL; tstring tmpString; #ifndef WIN32 tmpString.append(OSGT("lib")); tmpString.append(szName); tmpString.append(PluginExt ); #else tmpString.append(szName); #ifdef OSG_DEBUG # ifdef OSG_DEBUGRT tmpString.append(OSGT("D")); # else tmpString.append(OSGT("RN")); # endif #else # ifdef OSG_DEBUGRT tmpString.append(OSGT("DO")); # endif #endif tmpString.append(OSGT(".dll")); #endif returnValue = getSharedObject(tmpString.c_str()); return returnValue; }
orient_process (uint8_t priority) : scheduler_task("process", 2048, priority) { qid = getSharedObject(shared_SensorQueueId); /* Initialize GPIO1[0] to control LED9 */ LPC_GPIO1->FIODIR |= BITS(0); /* Turn off LED initially */ LPC_GPIO1->FIOPIN |= BITS(0); }
bool producer::run(void *p) { /** * Note that we produce the data as fast as possible. It is the queue size * that limits our production. When the queue is full, our task will sleep * because it can no longer queue additional data due to MAX_DELAY block time. */ int data = AS.getX(); QueueHandle_t qh = getSharedObject(shared_SensorQueue); return xQueueSend(qh, &data, portMAX_DELAY); }
bool consumer::run(void *p) { int data = 0; /* We should never block here by using portMAX_DELAY because the producer should * produce all the time. In fact, it is waiting for us to pull an item from the * queue and it is already "sleeping" until the queue space is available. */ xQueueReceive(getSharedObject(shared_SensorQueue), &data, portMAX_DELAY); printf("Acceleration sensor X-Axis: %i\n", data); return true; }
bool queue_rx::run(void *p) { int sample = 0; QueueHandle_t queue_handle = getSharedObject("my_queue"); if (!queue_handle) { return false; } if (xQueueReceive(queue_handle, &sample, portMAX_DELAY)) { printf("Got %i from queue", sample); } return true; }
bool SharedObjectHandler::initialize(void) { SharedObjectP pAppHandle = getSharedObject(NULL); for(UInt32 i = 0; i < _vLoadedNames.size(); ++i) { FLOG(("Preloaded %s %p\n", _vLoadedNames[i].c_str(), pAppHandle)); _mSharedObjects[_vLoadedNames[i]] = pAppHandle; OSG::addRef(pAppHandle); } _vLoadedNames.clear(); return true; }
bool queue_tx::run(void *p) { // Send only 10 samples, then suspend both tasks. static int sample = 0; // Get the pointer of the "ex_qrx" task scheduler_task *qrx_task = getTaskPtrByName("ex_qrx"); QueueHandle_t queue_handle = getSharedObject("my_queue"); if (!qrx_task || !queue_handle) { return false; } // Suspend the other task and ourselves after 10 samples if (++sample > 10) { qrx_task->suspend(); suspend(); } // Send to "my_queue" our integer return xQueueSend(queue_handle, &sample, 2000); }
bool terminalTask::taskEntry() { /* remoteTask() creates shared object in its init(), so we can get it now */ xSemaphoreHandle learn_sem = getSharedObject("learn_sem"); CommandProcessor &cp = mCmdProc; // System information handlers cp.addHandler(taskListHandler, "info", "Task/CPU Info. Use 'info 200' to get CPU during 200ms"); cp.addHandler(memInfoHandler, "meminfo", "See memory info"); cp.addHandler(healthHandler, "health", "Output system health"); cp.addHandler(timeHandler, "time", "'time' to view time. 'time set MM DD YYYY HH MM SS Wday' to set time"); // File I/O handlers: cp.addHandler(catHandler, "cat", "Read a file. Ex: 'cat 0:file.txt' or " "'cat 0:file.txt -noprint' to test if file can be read"); cp.addHandler(cpHandler, "cp", "Copy files from/to Flash/SD Card. Ex: 'cp 0:file.txt 1:file.txt'"); cp.addHandler(dcpHandler, "dcp", "Copy all files of a directory to another directory. Ex: 'dcp 0:src 1:dst'"); cp.addHandler(lsHandler, "ls", "Use 'ls 0:' for Flash, or 'ls 1:' for SD Card"); cp.addHandler(mkdirHandler, "mkdir", "Create a directory. Ex: 'mkdir test'"); cp.addHandler(mvHandler, "mv", "Rename a file. Ex: 'rm 0:file.txt 0:new.txt'"); cp.addHandler(newFileHandler,"nf", "Write a new file. Ex: 'nf <file.txt>"); cp.addHandler(rmHandler, "rm", "Remove a file. Ex: 'rm 0:file.txt'"); // Misc. handlers cp.addHandler(i2cIoHandler, "i2c", "'i2c read 0x01 0x02' : Reads device 0x01, and register 0x02\n" "'i2c write 0x01 0x02 0x03' : Writes device 0x01, reg 0x02, data 0x03\n" "'i2c discover' : Discover I2C devices"); cp.addHandler(storageHandler, "storage", "Parameters: 'format sd', 'format flash', 'mount sd', 'mount flash'"); cp.addHandler(rebootHandler, "reboot", "Reboots the system"); cp.addHandler(logHandler, "log", "'log <hello>' to log info. 'log flush' to flush logs"); cp.addHandler(learnIrHandler, "learn", "Begin to learn IR codes for numbers 0-9", learn_sem); cp.addHandler(wirelessHandler, "wireless", "Use 'wireless' to see the nested commands"); cp.addHandler(producerTask, "producerTask","Parameters: 'suspend', 'resume'"); /* Firmware upgrade handlers * Please read "netload_readme.txt" at ref_and_datasheets directory. */ CMD_HANDLER_FUNC(getFileHandler); CMD_HANDLER_FUNC(flashProgHandler); cp.addHandler(getFileHandler, "file", "Get a file using netload.exe or by using the following protocol:\n" "Write buffer: buffer <offset> <num bytes> ...\n" "Write buffer to file: commit <filename> <file offset> <num bytes from buffer>"); cp.addHandler(flashProgHandler, "flash", "'flash <filename>' Will flash CPU with this new binary file"); #if (ENABLE_TELEMETRY) cp.addHandler(telemetryHandler, "telemetry", "Outputs registered telemetry: " "'telemetry save' : Saves disk tel\n" "'telemetry <comp. name> <name> <value>' to set a telemetry variable\n" "'telemetry get <comp. name> <name>' to get variable value\n"); #endif // Initialize Interrupt driven version of getchar & putchar Uart0& uart0 = Uart0::getInstance(); bool success = uart0.init(38400, 32, UART0_TXQ_SIZE); uart0.setReady(true); sys_set_inchar_func(uart0.getcharIntrDriven); sys_set_outchar_func(uart0.putcharIntrDriven); /* Add UART0 to command input/output */ addCommandChannel(&uart0, true); #if TERMINAL_USE_NRF_WIRELESS { NordicStream& nrf = NordicStream::getInstance(); nrf.setReady(true); addCommandChannel(&nrf, false); } #endif #if ENABLE_TELEMETRY /* Telemetry should be registered at this point, so initialize the binary * telemetry space that we periodically check to save data to disk */ tlm_component *disk = tlm_component_get_by_name(DISK_TLM_NAME); mDiskTlmSize = tlm_binary_get_size_one(disk); mpBinaryDiskTlm = new char[mDiskTlmSize]; if (success) { success = (NULL != mpBinaryDiskTlm); } /* Now update our copy of disk telemetry */ tlm_binary_get_one(disk, mpBinaryDiskTlm); #endif /* Display "help" command on UART0 */ STR_ON_STACK(help, 8); help = "help"; mCmdProc.handleCommand(help, uart0); return success; }