static void init(int argc, char **argv){ int i; pp = 0xfffe; aux = 0; intReg[0] = intReg[1] = 0; reg[0] = 0; options.exitOnLoop = false; options.logExecution = false; options.initFile = NULL; isOperational = true; for (i=0; i<argc; ++i){ if (strcmp(argv[i], "--help") == 0){ printHelp(); exit(0); } if (strcmp(argv[i], "--exit-on-infloop") == 0){ options.exitOnLoop = true; } if (strcmp(argv[i], "--log-exe") == 0){ options.logExecution = true; } if (strcmp(argv[i], "--load-memory") == 0 || strcmp(argv[i], "-L") == 0){ if (i+1 < argc){ options.initFile = argv[i+1]; } else { logError("inconsistent arguments"); } } } initDevices(options.initFile); }
/** \ingroup xbcdeamon * \brief main function for the apllication */ int main() { signal(SIGINT, closeAndExit); // Create a log entry in /var/log/ openlog (DEAMON_LOG_NAME, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL0); if (daemon(0,0) != 0) { LOGERR("daemon() failed"); } initDevices(VENDOR_ID, PRODUCT_ID); initButtonSHM(SHM_NAME); initQueue(MQ_CMDS_NAME); if (pthread_create(&cmd_thread, NULL, commandListenerThread, NULL) != 0) { LOGERR("Error creating commandlistenerThread"); } if (pthread_create(&btn_thread, NULL, buttonReaderThread, NULL) != 0) { LOGERR("Error creating buttonReaderThread"); } while(1) { } return (0); // not reached }
PortAudioHelper::PortAudioHelper(QObject *parent) : QObject(parent), _supported(false), err(paNoError) { initDevices(); defaultParameters(); }
void initDevicesDescriptor() { initDeviceList(&deviceListArray, STRATEGY_BOARD_DEVICE_LENGTH); addLocalDevice(getSystemDeviceInterface(), getSystemDeviceDescriptor()); addLocalDevice(getStrategyDeviceInterface(), getStrategyDeviceDescriptor()); initDevices(&devices); }
// Initializes an OpenCL wrapper. // This includes automatically selecting a platform, automatically selecting a device, // initialing a context, command queue, and all kernels in the kernel box. CLWrapper::CLWrapper(size_t defaultGlobalSize, size_t defaultLocalSize) { error = CL_SUCCESS; initPlatformIds(); initDevices(); initContext(); initCommandQueue(); initKernelBox(); globalSize = defaultGlobalSize; localSize = defaultLocalSize; }
/** * @private */ void initDevicesDescriptor() { initDeviceList(&deviceListArray, MAIN_BOARD_DEVICE_LENGTH); // Test & System // addI2CRemoteDevice(&testDevice, getTestDeviceInterface(), MOTOR_BOARD_I2C_ADDRESS); addLocalDevice(getSystemDeviceInterface(), getSystemDeviceDescriptor()); addLocalDevice(getSystemDebugDeviceInterface(), getSystemDebugDeviceDescriptor()); addLocalDevice(getI2cMasterDebugDeviceInterface(), getI2cMasterDebugDeviceDescriptor()); // Local addLocalDevice(getClockDeviceInterface(), getClockDeviceDescriptor(&globalClock)); addLocalDevice(getLCDDeviceInterface(), getLCDDeviceDescriptor()); addLocalDevice(getTemperatureSensorDeviceInterface(), getTemperatureSensorDeviceDescriptor()); addLocalDevice(getEepromDeviceInterface(), getEepromDeviceDescriptor(&eeprom_)); addLocalDevice(getServoDeviceInterface(), getServoDeviceDescriptor()); addLocalDevice(getADCDeviceInterface(),getADCDeviceDescriptor()); addLocalDevice(getRobotConfigDeviceInterface(), getRobotConfigDeviceDescriptor(&robotConfig)); addLocalDevice(getStartMatchDetectorDeviceInterface(), getStartMatchDetectorDeviceDescriptor(&startMatchDetector)); addLocalDevice(getEndMatchDetectorDeviceInterface(), getEndMatchDetectorDeviceDescriptor()); addLocalDevice(getSonarDeviceInterface(), getSonarDeviceDescriptor()); addLocalDevice(getRobotSonarDetectorDeviceInterface(), getRobotSonarDetectorDeviceDescriptor()); // Mechanical Board 2->I2C // Device* armDevice = addI2CRemoteDevice(getArm2012DeviceInterface(), MECHANICAL_BOARD_2_I2C_ADDRESS); // Device* infraredDetectorDevice = addI2CRemoteDevice(getRobotInfraredDetectorDeviceInterface(), MECHANICAL_BOARD_2_I2C_ADDRESS); // Motor Board->I2C addI2CRemoteDevice(getPIDDeviceInterface(), MOTOR_BOARD_I2C_ADDRESS); addI2CRemoteDevice(getMotorDeviceInterface(), MOTOR_BOARD_I2C_ADDRESS); addI2CRemoteDevice(getCodersDeviceInterface(), MOTOR_BOARD_I2C_ADDRESS); Device* trajectoryDevice = addI2CRemoteDevice(getTrajectoryDeviceInterface(), MOTOR_BOARD_I2C_ADDRESS); Device* motionDevice = addI2CRemoteDevice(getMotionDeviceInterface(), MOTOR_BOARD_I2C_ADDRESS); // Beacon Receiver Board->I2C // addI2CRemoteDevice(getBeaconReceiverDeviceInterface(), BEACON_RECEIVER_I2C_ADDRESS); // Strategy Board->I2C // addI2CRemoteDevice(getStrategyDeviceInterface(), STRATEGY_BOARD_I2C_ADDRESS); // Air Conditioning Board addI2CRemoteDevice(getAirConditioningDeviceInterface(), AIR_CONDITIONING_BOARD_I2C_ADDRESS); // Init the devices initDevices(); // Manage the callback notification trajectoryDevice->deviceHandleCallbackRawData = &mainBoardCallbackRawData; // testDevice.deviceHandleCallbackRawData = &mainBoardCallbackRawData; motionDevice->deviceHandleCallbackRawData = &mainBoardCallbackRawData; // infraredDetectorDevice->deviceHandleCallbackRawData = &mainBoardCallbackRawData; }
// start of function main() int main(int argc, char* argv[]) { // Initialization initDevices(); usleep(3000000); // delay 3sec system("/root/test_app/cam_config/awb_ae_off/bg_setoff"); usleep(3000000); int thr_id[4]; pthread_t p_threads[4]; thr_id[0] = pthread_create(&p_threads[0], NULL, videoFrame, (void *)NULL); if (thr_id[0] < 0) { perror("videoFrame create error : "); exit(0); } usleep(2000000); // delay 3sec /* thr_id[2] = pthread_create(&p_threads[2], NULL, receiveMsg, (void *)NULL); if (thr_id[1] < 0) { perror("receive thread create error : "); exit(0); } */ findObjectColor(1); int status; pthread_join(p_threads[0], (void **)&status); //screenFoundObject(); // endProgram(); return 0; }
Configurer::Configurer() : config("i2cTest") { QFile file("i2cTest.xml"); if (!file.open(QIODevice::ReadOnly)) { qDebug() << "Failed to open i2cTest.xml for reading"; throw "Failed to open i2cTest.xml for reading"; } if (!config.setContent(&file)) { file.close(); qDebug() << "i2cTest.xml parsing failed"; throw "i2cTest.xml parsing failed"; } file.close(); initBusFiles(); initDevices(); }
int AudioDevice::numDevices() { initDevices(); return Pa_GetDeviceCount(); }
AudioDevice AudioDevice::defaultOutput() { initDevices(); return AudioDevice(Pa_GetDefaultOutputDevice()); }
void AudioDevice::setImpl(int deviceNum) { initDevices(); mImpl = Pa_GetDeviceInfo(deviceNum); mID=deviceNum; }
void runMotorBoardPC(bool singleMode) { singleModeActivated = singleMode; setBoardName(MOTOR_BOARD_PC_NAME); moveConsole(HALF_SCREEN_WIDTH, 0, HALF_SCREEN_WIDTH, CONSOLE_HEIGHT); // We use http://patorjk.com/software/taag/#p=testall&v=2&f=Acrobatic&t=MOTOR%20BOARD%20PC // with Font : Jerusalem printf(" __ __ ___ _____ ___ ____ ____ ___ _ ____ ____ ____ ____\r\n"); printf("| \\/ |/ _ |_ _/ _ \\| _ \\ | __ ) / _ \\ / \\ | _ \\| _ \\ | _ \\ / ___|\r\n"); printf("| |\\/| | | | || || | | | |_) | | _ \\| | | |/ _ \\ | |_) | | | | | |_) | | \r\n"); printf("| | | | |_| || || |_| | _ < | |_) | |_| / ___ \\| _ <| |_| | | __/| |___ \r\n"); printf("|_| |_|\\___/ |_| \\___/|_| \\_\\ |____/ \\___/_/ \\_|_| \\_|____/ |_| \\____|\r\n"); printf("\r\n"); initLogs(DEBUG, (LogHandler(*)[]) &logHandlerListArray, MOTOR_BOARD_PC_LOG_HANDLER_LIST_LENGTH, LOG_HANDLER_CATEGORY_ALL_MASK); initConsoleInputStream(&consoleInputStream); initConsoleOutputStream(&consoleOutputStream); addConsoleLogHandler(DEBUG, LOG_HANDLER_CATEGORY_ALL_MASK); appendStringCRLF(getDebugOutputStreamLogger(), getBoardName()); initTimerList((Timer(*)[]) &timerListArray, MOTOR_BOARD_PC_TIMER_LENGTH); initBuffer(&consoleInputBuffer, (char(*)[]) &consoleInputBufferArray, MOTOR_BOARD_PC_CONSOLE_INPUT_BUFFER_LENGTH, "inputConsoleBuffer", "IN"); initBuffer(&consoleOutputBuffer, (char(*)[]) &consoleOutputBufferArray, MOTOR_BOARD_PC_CONSOLE_OUTPUT_BUFFER_LENGTH, "outputConsoleBuffer", "IN"); // Dispatchers initDriverDataDispatcherList((DriverDataDispatcher(*)[]) &driverDataDispatcherListArray, MOTOR_BOARD_PC_DATA_DISPATCHER_LIST_LENGTH); addLocalDriverDataDispatcher(); if (!singleModeActivated) { initI2cBus(&motorI2cBus, I2C_BUS_TYPE_SLAVE, I2C_BUS_PORT_1); initI2cBusConnection(&motorI2cBusConnection, &motorI2cBus, MOTOR_BOARD_PC_I2C_ADDRESS); openSlaveI2cStreamLink(&i2cSlaveStreamLink, &i2cSlaveInputBuffer, (char(*)[]) &i2cSlaveInputBufferArray, MOTOR_BOARD_PC_IN_BUFFER_LENGTH, &i2cSlaveOutputBuffer, (char(*)[]) &i2cSlaveOutputBufferArray, MOTOR_BOARD_PC_OUT_BUFFER_LENGTH, &motorI2cBusConnection ); // I2C Debug initI2CDebugBuffers(&i2cSlaveDebugInputBuffer, (char(*)[]) &i2cSlaveDebugInputBufferArray, MOTOR_BOARD_PC_I2C_DEBUG_SLAVE_IN_BUFFER_LENGTH, &i2cSlaveDebugOutputBuffer, (char(*)[]) &i2cSlaveDebugOutputBufferArray, MOTOR_BOARD_PC_I2C_DEBUG_SLAVE_OUT_BUFFER_LENGTH); } // Eeprom initEepromPc(&eeprom, "TODO"); // Battery initBattery(&battery, getBatteryVoltage); // Clock initSoftClock(&clock); // Devices initDeviceList((Device(*)[]) &deviceListArray, MOTOR_BOARD_PC_DEVICE_LIST_LENGTH); addLocalDevice(getTestDeviceInterface(), getTestDeviceDescriptor()); addLocalDevice(getI2cSlaveDebugDeviceInterface(), getI2cSlaveDebugDeviceDescriptor(&motorI2cBusConnection)); addLocalDevice(getSystemDeviceInterface(), getSystemDeviceDescriptor()); addLocalDevice(getMotorDeviceInterface(), getMotorDeviceDescriptor()); addLocalDevice(getEepromDeviceInterface(), getEepromDeviceDescriptor(&eeprom)); addLocalDevice(getBatteryDeviceInterface(), getBatteryDeviceDescriptor(&battery)); addLocalDevice(getClockDeviceInterface(), getClockDeviceDescriptor(&clock)); addLocalDevice(getRobotKinematicsDeviceInterface(), getRobotKinematicsDeviceDescriptor(&eeprom)); addLocalDevice(getPIDDeviceInterface(), getPIDDeviceDescriptor(&eeprom, true)); addLocalDevice(getMotorDeviceInterface(), getMotorDeviceDescriptor()); addLocalDevice(getCodersDeviceInterface(), getCodersDeviceDescriptor()); addLocalDevice(getTrajectoryDeviceInterface(), getTrajectoryDeviceDescriptor()); addLocalDevice(getMotionDeviceInterface(), getMotionDeviceDescriptor(&eeprom, true)); addLocalDevice(getMotionSimulationDeviceInterface(), getMotionSimulationDeviceDescriptor()); initDevices(); startTimerList(); setDebugI2cEnabled(false); while (1) { motorBoardWaitForInstruction(); } }
TBasicManipulator( const SharedCanvasType * sharedCanvas, const uint devices = Keyboard|Mouse|Timer|Joystick ) : GenericCanvas< T >( sharedCanvas ) { initDevices(devices); }
int main(int argc, char* argv[]) { /* int write_buf; char read_buf;*/ // Initialization initDevices(); #ifndef WITHOUT_NETWORK initPeerSocket(); #endif usleep(1000000); // delay 3sec /* #ifdef SERVERMODE #ifndef WITHOUT_NETWORK // Wait for arrival waitThreeAxisChange(); sendStopSignal(); #endif #endif */ // Strart linetracing int thr_id[5]; pthread_t p_threads[5]; /* thr_id[0] = pthread_create(&p_threads[0], NULL, detectDistance, (void *)NULL); if (thr_id[0] < 0) { perror("thread1 create error : "); exit(0); } */ thr_id[1] = pthread_create(&p_threads[1], NULL, writeCommand, (void *)NULL); if (thr_id[1] < 0) { perror("command thread create error : "); exit(0); } /* thr_id[2] = pthread_create(&p_threads[2], NULL, findObj, (void *)NULL); if (thr_id[2] < 0) { perror("command thread create error : "); exit(0); } thr_id[3] = pthread_create(&p_threads[3], NULL, backboard, (void *)NULL); if (thr_id[3] < 0) { perror("command thread create error : "); exit(0); } thr_id[4] = pthread_create(&p_threads[4], NULL, map_read, (void *)NULL); if (thr_id[4] < 0) { perror("command thread create error : "); exit(0); } thr_id[5] = pthread_create(&p_threads[5], NULL, traceLine, (void *)NULL); if (thr_id[5] < 0) { perror("command thread create error : "); exit(0); } */ int status; /* pthread_join(p_threads[4], (void **)&status); pthread_join(p_threads[3], (void **)&status); pthread_join(p_threads[0], (void **)&status); pthread_join(p_threads[2], (void **)&status); pthread_join(p_threads[5], (void **)&status); */ map_read(); //pthread_join(p_threads[0], (void **)&status); pthread_join(p_threads[1], (void **)&status); endProgram(); return 0; }
int main(int argc, char* argv[]) { /* int write_buf; char read_buf;*/ // Initialization initDevices(); #ifndef WITHOUT_NETWORK // initPeerSocket(); #endif usleep(3000000); // delay 3sec #ifdef SERVERMODE #ifndef WITHOUT_NETWORK // Wait for arrival sendStopSignal(); #endif #endif // Strart linetracing int thr_id[4]; pthread_t p_threads[4]; thr_id[3] = pthread_create(&p_threads[3], NULL, videoFrame, (void *)NULL); if (thr_id[3] < 0) { perror("thread1 create error : "); exit(0); } confirm_Response(); usleep(1000000); waitThreeAxisChange(); thr_id[0] = pthread_create(&p_threads[0], NULL, traceLine, (void *)NULL); if (thr_id[0] < 0) { perror("thread1 create error : "); exit(0); } thr_id[1] = pthread_create(&p_threads[1], NULL, writeCommand, (void *)NULL); if (thr_id[1] < 0) { perror("command thread create error : "); exit(0); } /* #ifdef CLIENTMODE #ifndef WITHOUT_NETWORK thr_id[2] = pthread_create(&p_threads[2], NULL, recieveStopSignal, (void *)NULL); if (thr_id[2] < 0) { perror("command thread create error : "); exit(0); } #endif #endif */ int status; #ifdef CLIENTMODE // pthread_join(p_threads[2], (void **)&status); #endif pthread_join(p_threads[0], (void **)&status); pthread_join(p_threads[1], (void **)&status); pthread_join(p_threads[3], (void **)&status); endProgram(); return 0; }
/** * @brief Main function * @return Exit code */ int main() { int ninyections = askInyections(); int latency = askLatency(); // s int tbase = askTimeBase(latency); // s int size = tbase / latency; int timespan; // ms int interval; // ms int i, j, n; double mean; // v double min, max; // v double prevMax, prevMin; // v double baseline; // v double voltage; // v double areaPartial; // v*s double *voltages = (double*)malloc(sizeof(double) * size); double *areas = (double*)malloc(sizeof(double) * ninyections); int warningShown = 0; FILE *file; atexit((void(*)())getchar); initDevices(); file = fopen(OUT_FILE, "w"); if (file == NULL) fprintf(stderr, "Couldn't open %s\n", OUT_FILE); // Extract base line printf("Waiting to reach baseline...\n"); fillVoltages(voltages, size, latency, file); mean = getMean(voltages, size); min = getMin(voltages, size); max = getMax(voltages, size); printf("Mean: %.5e volts. Min: %.5e volts. Max: %.5e volts.\n", mean, min, max); do { prevMin = min; prevMax = max; fillVoltages(voltages, size, latency, file); mean = getMean(voltages, size); min = getMin(voltages, size); max = getMax(voltages, size); printf("Mean: %.5e volts. Min: %.5e volts. Max: %.5e volts.\n", mean, min, max); printf("Wait range: [%.5e - %.5e]\n", prevMin - BASELINE_VARIATION, prevMax + BASELINE_VARIATION); } while (mean <= prevMin - BASELINE_VARIATION || mean >= prevMax + BASELINE_VARIATION); baseline = mean; printf("Baseline reached: %.5e volts.\n", baseline); for (n = 0; n < ninyections; n++) { areas[n] = 0.0; // Waiting injection printf("\aYou can start the injection...\n"); printf("Waiting [%.5e - %.5e]\n", baseline + INJECTION_VARIATION, baseline - INJECTION_VARIATION); timespan = measureVoltage(&voltage); while (ABS(voltage - baseline) < INJECTION_VARIATION) { Sleep(latency * 1000); timespan = measureVoltage(&voltage); printf("\tRead: %.9f volts.\n", voltage); fprintf(file, "%.9f\n", voltage); } // Area and compensation printf("\a\nMeasuring area...\n\n"); fprintf(file, "\nMeasuring peak area %d\n\n", n + 1); // We'll take two measuring stages in order to avoid the first peak for (j = 0; j < 2; j++) { for (i = 0; i < size; i++) { fprintf(file, "%.9f\n", voltage); areaPartial = (voltage - baseline) * latency; areas[n] += ABS(areaPartial); voltages[i] = voltage; printf("\tRead: %.9f volts.\n", voltage); interval = latency * 1000 - timespan; if (interval < 0 && !warningShown) { fprintf(stderr, "Warning: latency too small.\n"); warningShown = 1; } Sleep(interval); timespan = measureVoltage(&voltage); } } mean = getMean(voltages, size); min = getMin(voltages, size); max = getMax(voltages, size); printf("Mean: %.5e volts. Min: %.5e volts. Max: %.5e volts.\n", mean, min, max); do { prevMin = min; prevMax = max; for (i = 0; i < size; i++) { fprintf(file, "%.9f\n", voltage); areaPartial = (voltage - baseline) * latency; areas[n] += ABS(areaPartial); voltages[i] = voltage; printf("\tRead: %.9f volts.\n", voltage); interval = latency * 1000 - timespan; if (interval < 0 && !warningShown) { fprintf(stderr, "Warning: latency too small.\n"); warningShown = 1; } Sleep(interval); timespan = measureVoltage(&voltage); } mean = getMean(voltages, size); min = getMin(voltages, size); max = getMax(voltages, size); printf("Mean: %.5e volts. Min: %.5e volts. Max: %.5e volts.\n", mean, min, max); printf("Wait range: [%.5e - %.5e]\n", prevMin - BASELINE_VARIATION, prevMax + BASELINE_VARIATION); } while (mean <= prevMin - BASELINE_VARIATION || mean >= prevMax + BASELINE_VARIATION); baseline = mean; printf("\aArea: %.9e V*s\n", areas[n]); printf("\aEnergy: %.9e J\n\n", areas[n] * K); fprintf(file, "\tArea: %.9f\n", areas[n]); fprintf(file, "\tEnergy: %.9f\n\n", areas[n] * K); } for (n = 0; n < ninyections; n++) { printf("\aArea %d: %.9e V*s\n", n + 1, areas[n]); printf("\aEnergy %d: %.9e J\n\n", n + 1, areas[n] * K); } fclose(file); free(voltages); return EXIT_SUCCESS; }
webots::Robot::Robot() { initDarwinOP(); initDevices(); gettimeofday(&mStart, NULL); mPreviousStepTime = 0.0; }
void runMainBoardPC(bool connectToRobotManagerMode) { connectToRobotManager = connectToRobotManagerMode; setBoardName(MAIN_BOARD_PC_NAME); moveConsole(0, 0, HALF_SCREEN_WIDTH, CONSOLE_HEIGHT); // We use http://patorjk.com/software/taag/#p=testall&v=2&f=Acrobatic&t=MOTOR%20BOARD%20PC // with Font : Jerusalem printf(" __ __ _ ___ _ _ ____ ___ _ ____ ____ ____ ____ \r\n"); printf("| \\/ | / \\ |_ _| \\ | | | __ ) / _ \\ / \\ | _ \\| _ \\ | _ \\ / ___|\r\n"); printf("| |\\/| | / _ \\ | || \\| | | _ \\| | | |/ _ \\ | |_) | | | | | |_) | | \r\n"); printf("| | | |/ ___ \\ | || |\\ | | |_) | |_| / ___ \\| _ <| |_| | | __/| |___ \r\n"); printf("|_| |_/_/ \\_|___|_| \\_| |____/ \\___/_/ \\_|_| \\_|____/ |_| \\____|\r\n"); printf("\r\n"); initLogs(DEBUG, (LogHandler(*)[]) &logHandlerListArray, MAIN_BOARD_PC_LOG_HANDLER_LIST_LENGTH, LOG_HANDLER_CATEGORY_ALL_MASK); initConsoleInputStream(&consoleInputStream); initConsoleOutputStream(&consoleOutputStream); addConsoleLogHandler(DEBUG, LOG_HANDLER_CATEGORY_ALL_MASK); appendStringCRLF(getDebugOutputStreamLogger(), getBoardName()); initTimerList((Timer(*)[]) &timerListArray, MAIN_BOARD_PC_TIMER_LENGTH); initBuffer(&consoleInputBuffer, (char(*)[]) &consoleInputBufferArray, MAIN_BOARD_PC_CONSOLE_INPUT_BUFFER_LENGTH, "inputConsoleBuffer", "IN"); initBuffer(&consoleOutputBuffer, (char(*)[]) &consoleOutputBufferArray, MAIN_BOARD_PC_CONSOLE_OUTPUT_BUFFER_LENGTH, "outputConsoleBuffer", "IN"); // Dispatchers initDriverDataDispatcherList((DriverDataDispatcher(*)[]) &driverDataDispatcherListArray, MAIN_BOARD_PC_DATA_DISPATCHER_LIST_LENGTH); addLocalDriverDataDispatcher(); initI2cBus(&motorBoardI2cBus, I2C_BUS_TYPE_MASTER, I2C_BUS_PORT_1); initI2cBusConnection(&motorBoardI2cBusConnection, &motorBoardI2cBus, MOTOR_BOARD_PC_I2C_ADDRESS); addI2CDriverDataDispatcher("MOTOR_BOARD_DISPATCHER", &motorBoardInputBuffer, (char(*)[]) &motorBoardInputBufferArray, MAIN_BOARD_PC_DATA_MOTOR_BOARD_DISPATCHER_BUFFER_LENGTH, &motorBoardOutputStream, &motorBoardInputStream, &motorBoardI2cBusConnection ); if (connectToRobotManager) { // Open the serial Link between RobotManager (C# Project) and the MainBoardPc openSerialLink(&robotManagerSerialStreamLink, &robotManagerInputBuffer, (char(*)[]) &robotManagerInputBufferArray, ROBOT_MANAGER_INPUT_BUFFER_LENGTH, &robotManagerOutputBuffer, (char(*)[]) &robotManagerOutputBufferArray, ROBOT_MANAGER_OUTPUT_BUFFER_LENGTH, &robotManagerOutputStream, SERIAL_PORT_ROBOT_MANAGER, 0); } // CONFIG initRobotConfigPc(&robotConfig); // EEPROM initEepromPc(&eeprom, "TODO"); initEepromFile(&eeprom); // Clock initPcClock(&clock); // Temperature initTemperaturePc(&temperature); // I2C Debug initI2CDebugBuffers(&i2cMasterDebugInputBuffer, (char(*)[]) &i2cMasterDebugInputBufferArray, MAIN_BOARD_PC_I2C_DEBUG_MASTER_IN_BUFFER_LENGTH, &i2cMasterDebugOutputBuffer, (char(*)[]) &i2cMasterDebugOutputBufferArray, MAIN_BOARD_PC_I2C_DEBUG_MASTER_OUT_BUFFER_LENGTH); // Init the drivers initDrivers(&driverRequestBuffer, (char(*)[]) &driverRequestBufferArray, MAIN_BOARD_PC_REQUEST_DRIVER_BUFFER_LENGTH, &driverResponseBuffer, (char(*)[]) &driverResponseBufferArray, MAIN_BOARD_PC_RESPONSE_DRIVER_BUFFER_LENGTH); // Get test driver for debug purpose addDriver(testDriverGetDescriptor(), TRANSMIT_LOCAL); // Devices initDeviceList((Device(*)[]) &deviceListArray, MAIN_BOARD_PC_DEVICE_LIST_LENGTH); // addLocalDevice(getTestDeviceInterface(), getTestDeviceDescriptor()); testDevice = addI2cRemoteDevice(getTestDeviceInterface(), MOTOR_BOARD_PC_I2C_ADDRESS); testDevice->deviceHandleNotification = mainBoardDeviceHandleNotification; // LOCAL BOARD addLocalDevice(getADCDeviceInterface(), getADCDeviceDescriptor()); addLocalDevice(getStrategyDeviceInterface(), getStrategyDeviceDescriptor()); addLocalDevice(getSystemDeviceInterface(), getSystemDeviceDescriptor()); addLocalDevice(getRobotConfigDeviceInterface(), getRobotConfigDeviceDescriptor(&robotConfig)); addLocalDevice(getI2cMasterDebugDeviceInterface(), getI2cMasterDebugDeviceDescriptor()); addLocalDevice(getDataDispatcherDeviceInterface(), getDataDispatcherDeviceDescriptor()); addLocalDevice(getServoDeviceInterface(), getServoDeviceDescriptor()); addLocalDevice(getTimerDeviceInterface(), getTimerDeviceDescriptor()); addLocalDevice(getClockDeviceInterface(), getClockDeviceDescriptor(&clock)); // addLocalDevice(getFileDeviceInterface(), getFileDeviceDescriptor()); addLocalDevice(getEepromDeviceInterface(), getEepromDeviceDescriptor(&eeprom)); addLocalDevice(getLogDeviceInterface(), getLogDeviceDescriptor()); addLocalDevice(getLCDDeviceInterface(), getLCDDeviceDescriptor()); addLocalDevice(getTemperatureSensorDeviceInterface(), getTemperatureSensorDeviceDescriptor(&temperature)); addLocalDevice(getNavigationDeviceInterface(), getNavigationDeviceDescriptor()); initStartMatch(&startMatch, isMatchStartedPc, mainBoardPcWaitForInstruction, &eeprom); addLocalDevice(getStartMatchDeviceInterface(), getStartMatchDeviceDescriptor(&startMatch)); // MOTOR BOARD addI2cRemoteDevice(getBatteryDeviceInterface(), MOTOR_BOARD_PC_I2C_ADDRESS); // addI2cRemoteDevice(getEepromDeviceInterface(), MOTOR_BOARD_PC_I2C_ADDRESS); addI2cRemoteDevice(getPIDDeviceInterface(), MOTOR_BOARD_PC_I2C_ADDRESS); addI2cRemoteDevice(getMotorDeviceInterface(), MOTOR_BOARD_PC_I2C_ADDRESS); addI2cRemoteDevice(getCodersDeviceInterface(), MOTOR_BOARD_PC_I2C_ADDRESS); addI2cRemoteDevice(getTrajectoryDeviceInterface(), MOTOR_BOARD_PC_I2C_ADDRESS); addI2cRemoteDevice(getMotionDeviceInterface(), MOTOR_BOARD_PC_I2C_ADDRESS); addI2cRemoteDevice(getRobotKinematicsDeviceInterface(), MOTOR_BOARD_PC_I2C_ADDRESS); addI2cRemoteDevice(getMotionSimulationDeviceInterface(), MOTOR_BOARD_PC_I2C_ADDRESS); initDevices(); delaymSec(100); setDebugI2cEnabled(false); // Ping if (!pingDriverDataDispatcherList()) { printf("PING PROBLEM !"); } // Set Clock for Motor Board ! // Read Clock ClockData* clockData = clock.readClock(&clock); // TODO : Change Dispatcher Index ... writeDateRemoteClockData(clockData, 0x01); writeHourRemoteClockData(clockData, 0x01); // testDriverIntensive(100); startTimerList(); while (1) { mainBoardPcWaitForInstruction(&startMatch); } // TODO : ShowEnd }
midiMessageManager::midiMessageManager() { m.clear(); initDevices(); midiOutputList.clear(); }
void MIDISender::Init(void) { initDevices(); }
void runMechanicalBoard1PC(bool singleMode) { singleModeActivated = singleMode; setBoardName(MECHANICAL_BOARD_1_PC_NAME); setConsoleSizeAndBuffer(CONSOLE_CHARS_WIDTH, CONSOLE_CHARS_HEIGHT, CONSOLE_BUFFER_WIDTH, CONSOLE_BUFFER_HEIGHT); moveConsole(HALF_SCREEN_WIDTH, CONSOLE_HEIGHT / 2, HALF_SCREEN_WIDTH, CONSOLE_HEIGHT / 2); // We use http://patorjk.com/software/taag/#p=display&v=2&f=Jerusalem&t=MECA%20%20%201%20%20%20PC // with Font : Jerusalem printf(" __ __ _____ ____ _ _ ____ ____\r\n"); printf("| \\/ | ____ / ___| / \\ / | | _ \\ / ___|\r\n"); printf("| |\\/| | _|| | / _ \\ | | | |_) | |\r\n"); printf("| | | | |__| |___ / ___ \\ | | | __/| |___\r\n"); printf("|_| |_| _____\\____/ _ / \\_\\ |_| |_| \\____ |\r\n"); initLogs(LOG_LEVEL_DEBUG, (LogHandler(*)[]) &logHandlerListArray, MECHANICAL_BOARD_1_PC_LOG_HANDLER_LIST_LENGTH, LOG_HANDLER_CATEGORY_ALL_MASK); initConsoleInputStream(&consoleInputStream); initConsoleOutputStream(&consoleOutputStream); addConsoleLogHandler(LOG_LEVEL_DEBUG, LOG_HANDLER_CATEGORY_ALL_MASK); initSerialLinkList((SerialLink(*)[]) &serialLinkListArray, MECHANICAL_BOARD_1_PC_SERIAL_LINK_LIST_LENGTH); initTimerList((Timer(*)[]) &timerListArray, MECHANICAL_BOARD_1_PC_TIMER_LENGTH); initBuffer(&consoleInputBuffer, (char(*)[]) &consoleInputBufferArray, MECHANICAL_BOARD_1_PC_CONSOLE_INPUT_BUFFER_LENGTH, "inputConsoleBuffer", "IN"); initBuffer(&consoleOutputBuffer, (char(*)[]) &consoleOutputBufferArray, MECHANICAL_BOARD_1_PC_CONSOLE_OUTPUT_BUFFER_LENGTH, "outputConsoleBuffer", "IN"); // Dispatchers initDriverDataDispatcherList((DriverDataDispatcher(*)[]) &driverDataDispatcherListArray, MECHANICAL_BOARD_1_PC_DATA_DISPATCHER_LIST_LENGTH); addLocalDriverDataDispatcher(); if (!singleModeActivated) { // I2c initI2cBusList((I2cBus(*)[]) &i2cBusListArray, MECHANICAL_BOARD_1_PC_I2C_BUS_LIST_LENGTH); mechanical1I2cBus = addI2cBus(I2C_BUS_TYPE_SLAVE, I2C_BUS_PORT_1); initI2cBusConnectionList((I2cBusConnection(*)[]) &i2cBusConnectionListArray, MECHANICAL_BOARD_1_PC_I2C_BUS_CONNECTION_LIST_LENGTH); mechanical1I2cBusConnection = addI2cBusConnection(mechanical1I2cBus, MECHANICAL_BOARD_1_I2C_ADDRESS, false); mechanical1I2cBusConnection->i2cBus = mechanical1I2cBus; mechanical1I2cBusConnectionPc.i2cPipeMasterName = MAIN_BOARD_TO_MECA1_BOARD_PC_PIPE_I2C_MASTER_NAME; mechanical1I2cBusConnectionPc.i2cPipeSlaveName = MECHANICAL_BOARD_1_PC_PIPE_I2C_SLAVE_NAME; mechanical1I2cBusConnection->object = &mechanical1I2cBusConnectionPc; openSlaveI2cStreamLink(&i2cSlaveStreamLink, &i2cSlaveInputBuffer, (char(*)[]) &i2cSlaveInputBufferArray, MECHANICAL_BOARD_1_PC_IN_BUFFER_LENGTH, &i2cSlaveOutputBuffer, (char(*)[]) &i2cSlaveOutputBufferArray, MECHANICAL_BOARD_1_PC_OUT_BUFFER_LENGTH, mechanical1I2cBusConnection ); // I2C Debug initI2CDebugBuffers(&i2cSlaveDebugInputBuffer, (char(*)[]) &i2cSlaveDebugInputBufferArray, MECHANICAL_BOARD_1_PC_I2C_DEBUG_SLAVE_IN_BUFFER_LENGTH, &i2cSlaveDebugOutputBuffer, (char(*)[]) &i2cSlaveDebugOutputBufferArray, MECHANICAL_BOARD_1_PC_I2C_DEBUG_SLAVE_OUT_BUFFER_LENGTH); } // Eeprom initEepromPc(&eeprom, "MECHANICAL_BOARD_1_PC_EEPROM"); // Battery initBattery(&battery, getBatteryVoltage); // Clock initSoftClock(&clock); // HBridge Fake Motor MD22 initDualHBridgeMotorPc(&md22); // 2018 // IO Expander initIOExpanderList(&ioExpanderList, (IOExpander(*)[]) &ioExpanderArray, MECHANICAL_BOARD_1_PC_IO_EXPANDER_LIST_LENGTH); initIOExpanderPc(getIOExpanderByIndex(&ioExpanderList, MECHANICAL_BOARD_1_PC_IO_EXPANDER_LAUNCHER_INDEX), &ioExpanderValue0); IOExpander* launcherIoExpander = getIOExpanderByIndex(&ioExpanderList, MECHANICAL_BOARD_1_PC_IO_EXPANDER_LAUNCHER_INDEX); // TODO : Add tof ! // initLauncher2018(&launcher2018, launcherIoExpander, &relay, &md22, NULL); // Relay initRelayPc(&relay, &relayValue); // Devices initDeviceList((Device(*)[]) &deviceListArray, MECHANICAL_BOARD_1_PC_DEVICE_LIST_LENGTH); addLocalDevice(getTestDeviceInterface(), getTestDeviceDescriptor()); addLocalDevice(getTimerDeviceInterface(), getTimerDeviceDescriptor()); addLocalDevice(getI2cCommonDebugDeviceInterface(), getI2cCommonDebugDeviceDescriptor()); addLocalDevice(getI2cSlaveDebugDeviceInterface(), getI2cSlaveDebugDeviceDescriptor(mechanical1I2cBusConnection)); addLocalDevice(getSystemDeviceInterface(), getSystemDeviceDescriptor()); addLocalDevice(getLogDeviceInterface(), getLogDeviceDescriptor()); addLocalDevice(getEepromDeviceInterface(), getEepromDeviceDescriptor(&eeprom)); addLocalDevice(getClockDeviceInterface(), getClockDeviceDescriptor(&clock)); // 2018 addLocalDevice(getIOExpanderDeviceInterface(), getIOExpanderDeviceDescriptor(&ioExpanderList)); addLocalDevice(getRelayDeviceInterface(), getRelayDeviceDescriptor(&relay)); addLocalDevice(getMD22DeviceInterface(), getMD22DeviceDescriptor(&md22)); initDevices(); startTimerList(true); setDebugI2cEnabled(false); while (1) { mechanicalBoard1PcWaitForInstruction(); } }
/** * @private */ void initMainBoardDevicesDescriptor() { initDeviceList(&deviceListArray, MAIN_BOARD_DEVICE_LENGTH); // SYSTEM & DEBUG addLocalDevice(getSystemDeviceInterface(), getSystemDeviceDescriptor()); addLocalDevice(getLogDeviceInterface(), getLogDeviceDescriptor()); addLocalDevice(getSerialDebugDeviceInterface(), getSerialDebugDeviceDescriptor()); addLocalDevice(getTimerDeviceInterface(), getTimerDeviceDescriptor()); addLocalDevice(getTest2DeviceInterface(), getTest2DeviceDescriptor()); addLocalDevice(getDataDispatcherDeviceInterface(), getDataDispatcherDeviceDescriptor()); addLocalDevice(getI2cMasterDebugDeviceInterface(), getI2cMasterDebugDeviceDescriptor()); // LOCAL addLocalDevice(getLCDDeviceInterface(), getLCDDeviceDescriptor()); addLocalDevice(getRobotConfigDeviceInterface(), getRobotConfigDeviceDescriptor(&robotConfig)); initStartMatch(&startMatch, isMatchStarted32, mainBoardWaitForInstruction, &eeprom); addLocalDevice(getStartMatchDeviceInterface(), getStartMatchDeviceDescriptor(&startMatch)); addLocalDevice(getEndMatchDetectorDeviceInterface(), getEndMatchDetectorDeviceDescriptor()); addLocalDevice(getEepromDeviceInterface(), getEepromDeviceDescriptor(&eeprom)); addLocalDevice(getClockDeviceInterface(), getClockDeviceDescriptor(&clock)); addLocalDevice(getADCDeviceInterface(), getADCDeviceDescriptor()); addLocalDevice(getServoDeviceInterface(), getServoDeviceDescriptor()); addLocalDevice(getLedDeviceInterface(), getLedDeviceDescriptor()); addLocalDevice(getTestDeviceInterface(), getTestDeviceDescriptor()); /* addLocalDevice(getSonarDeviceInterface(), getSonarDeviceDescriptor(&i2cBus)); addLocalDevice(getRobotSonarDetectorDeviceInterface(), getRobotSonarDetectorDeviceDescriptor(&i2cBus)); addLocalDevice(getTemperatureSensorDeviceInterface(), getTemperatureSensorDeviceDescriptor(&i2cBus)); */ // Mechanical Board 2->I2C // Device* armDevice = addI2cRemoteDevice(getArm2012DeviceInterface(), MECHANICAL_BOARD_2_I2C_ADDRESS); // Device* infraredDetectorDevice = addI2cRemoteDevice(getRobotInfraredDetectorDeviceInterface(), MECHANICAL_BOARD_2_I2C_ADDRESS); // addI2cRemoteDevice(getServoDeviceInterface(), MECHANICAL_BOARD_2_I2C_ADDRESS); // addUartRemoteDevice(getRobotInfraredDetectorDeviceInterface(), SERIAL_PORT_MECA2); // Motor Board->I2C /* addI2cRemoteDevice(getTestDeviceInterface(), MOTOR_BOARD_I2C_ADDRESS); addI2cRemoteDevice(getMotorDeviceInterface(), MOTOR_BOARD_I2C_ADDRESS); addI2cRemoteDevice(getCodersDeviceInterface(), MOTOR_BOARD_I2C_ADDRESS); addI2cRemoteDevice(getPIDDeviceInterface(), MOTOR_BOARD_I2C_ADDRESS); addI2cRemoteDevice(getTrajectoryDeviceInterface(), MOTOR_BOARD_I2C_ADDRESS); addI2cRemoteDevice(getMotionDeviceInterface(), MOTOR_BOARD_I2C_ADDRESS); */ // MOTOR BOARD -> UART // addUartRemoteDevice(getTestDeviceInterface(), SERIAL_PORT_MOTOR); addUartRemoteDevice(getMotorDeviceInterface(), SERIAL_PORT_MOTOR); addUartRemoteDevice(getCodersDeviceInterface(), SERIAL_PORT_MOTOR); addUartRemoteDevice(getPIDDeviceInterface(), SERIAL_PORT_MOTOR); addUartRemoteDevice(getTrajectoryDeviceInterface(), SERIAL_PORT_MOTOR); addUartRemoteDevice(getMotionDeviceInterface(), SERIAL_PORT_MOTOR); addUartRemoteDevice(getRobotKinematicsDeviceInterface(), SERIAL_PORT_MOTOR); // Beacon Receiver Board->I2C // addI2cRemoteDevice(getBeaconReceiverDeviceInterface(), BEACON_RECEIVER_I2C_ADDRESS); // Strategy Board->I2C // addI2cRemoteDevice(getStrategyDeviceInterface(), STRATEGY_BOARD_I2C_ADDRESS); // Air Conditioning Board addI2cRemoteDevice(getAirConditioningDeviceInterface(), AIR_CONDITIONING_BOARD_I2C_ADDRESS); // Init the devices initDevices(); // Manage the callback notification // trajectoryDevice->deviceHandleCallbackRawData = &mainBoardCallbackRawData; // testDevice.deviceHandleCallbackRawData = &mainBoardCallbackRawData; // motionDevice->deviceHandleCallbackRawData = &mainBoardCallbackRawData; // infraredDetectorDevice->deviceHandleCallbackRawData = &mainBoardCallbackRawData; }
/** * @brief Constructor */ TBasicManipulator( const uint devices = Keyboard|Mouse|Timer|Joystick ) { initDevices(devices); }
JNIEXPORT jint JNICALL Java_org_jitsi_impl_neomedia_CoreAudioDevice_initDevices (JNIEnv *env, jclass clazz) { return initDevices(); }
void initNtop(char *devices) { char value[32]; revertSlashIfWIN32(myGlobals.dbPath, 0); revertSlashIfWIN32(myGlobals.spoolPath, 0); initIPServices(); handleProtocols(); myGlobals.l7.numSupportedProtocols = IPOQUE_MAX_SUPPORTED_PROTOCOLS; if(myGlobals.numIpProtosToMonitor == 0) addDefaultProtocols(); /* * Initialize memory and data. */ initDevices(devices); init_events(); if(myGlobals.runningPref.enableSessionHandling) initPassiveSessions(); initL7Discovery(); /* ********************************** */ initGdbm(myGlobals.dbPath, myGlobals.spoolPath, 0); /* We just initialized gdbm: let's now dump serials */ dumpHostSerial(&myGlobals.broadcastEntry->hostSerial, myGlobals.broadcastEntry->serialHostIndex); dumpHostSerial(&myGlobals.otherHostEntry->hostSerial, myGlobals.otherHostEntry->serialHostIndex); if(myGlobals.runningPref.daemonMode) { /* Before bacoming a daemon we need o make sure that ntop has been installed properly and that all the html files are on the right place */ int idx, found = 0; for(idx=0; (!found) && (myGlobals.dataFileDirs[idx] != NULL); idx++) { char tmpStr[256]; struct stat statbuf; if(strcmp(myGlobals.dataFileDirs[idx], ".") /* ignore local paths */ ) { safe_snprintf(__FILE__, __LINE__, tmpStr, sizeof(tmpStr), "%s/html/%s", myGlobals.dataFileDirs[idx], "ntop.gif" /* This file must always exist */); if(stat(tmpStr, &statbuf) == 0) { found = 1; break; } } } if(!found) { traceEvent(CONST_TRACE_WARNING, "ntop will not become a daemon as it has not been"); traceEvent(CONST_TRACE_WARNING, "installed properly (did you do 'make install')"); } else daemonizeUnderUnix(); } /* Handle local addresses (if any) */ handleLocalAddresses(myGlobals.runningPref.localAddresses); /* Handle known subnetworks (if any) */ handleKnownAddresses(myGlobals.runningPref.knownSubnets); if((myGlobals.pcap_file_list != NULL) && (myGlobals.runningPref.localAddresses == NULL)) { char *any_net = "0.0.0.0/0"; traceEvent(CONST_TRACE_WARNING, "-m | local-subnets must be specified when the -f option is used" "Assuming %s", any_net); myGlobals.runningPref.localAddresses = strdup(any_net); } if(myGlobals.runningPref.currentFilterExpression != NULL) parseTrafficFilter(); else myGlobals.runningPref.currentFilterExpression = strdup(""); /* so that it isn't NULL! */ /* Handle flows (if any) */ handleFlowsSpecs(); createPortHash(); initCounters(); initApps(); initThreads(); #ifndef MAKE_MICRO_NTOP traceEvent(CONST_TRACE_NOISY, "Starting Plugins"); startPlugins(); traceEvent(CONST_TRACE_NOISY, "Plugins started... continuing with initialization"); #endif #if defined(MEMORY_DEBUG) && defined(MAKE_WITH_SAFER_ROUTINES) resetLeaks(); #endif addNewIpProtocolToHandle("IGMP", 2, 0 /* no proto */); addNewIpProtocolToHandle("OSPF", 89, 0 /* no proto */); addNewIpProtocolToHandle("IPsec", 50, 51); init_maps(); loadGeoIP(); /* Note that by default ntop will merge network interfaces */ if(myGlobals.runningPref.mergeInterfaces == 0) traceEvent(CONST_TRACE_ALWAYSDISPLAY, "NOTE: Interface merge disabled by default"); else traceEvent(CONST_TRACE_ALWAYSDISPLAY, "NOTE: Interface merge enabled by default"); if(fetchPrefsValue("globals.displayPolicy", value, sizeof(value)) == -1) { myGlobals.hostsDisplayPolicy = showAllHosts /* 0 */; storePrefsValue("globals.displayPolicy", "0"); } else { myGlobals.hostsDisplayPolicy = atoi(value); /* Out of range check */ if((myGlobals.hostsDisplayPolicy < showAllHosts) || (myGlobals.hostsDisplayPolicy > showOnlyRemoteHosts)) myGlobals.hostsDisplayPolicy = showAllHosts; } if(fetchPrefsValue("globals.localityPolicy", value, sizeof(value)) == -1) { myGlobals.localityDisplayPolicy = showSentReceived /* 0 */; storePrefsValue("globals.localityPolicy", "0"); } else { myGlobals.localityDisplayPolicy = atoi(value); /* Out of range check */ if((myGlobals.localityDisplayPolicy < showSentReceived) || (myGlobals.localityDisplayPolicy > showOnlyReceived)) myGlobals.localityDisplayPolicy = showSentReceived; } if(myGlobals.runningPref.skipVersionCheck != TRUE) { pthread_t myThreadId; createThread(&myThreadId, checkVersion, NULL); } }
void MIDISender::rescanDevices() { _outputDevices.clear(true); initDevices(); }