int main(int argc, char **argv) { struct sigaction action; int exitCode; parseArgs(argc,argv); initLogs(); if (keepAsDaemon) { LOG_N("Trying to keep as a daemon..."); if (daemon(false,false)<0) { LOG_E(strerror(errno)); LOG_W("... continuing daemonless"); } else { LOG_N("... Success "); } } memset(&action,0,sizeof(action)); action.sa_handler =signalHandler; sigaction(SIGHUP,&action,NULL); sigaction(SIGTERM,&action,NULL); // signal(SIGHUP,signalHandler); /* catch hangup signal */ // signal(SIGTERM,signalHandler); /* catch kill signal */ exitCode = runMonitor(); return exitCode; //return EXIT_SUCCESS; }
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(); } }
void mainBoardCommonInitLogs(void) { // LOG Global Configuration initLogs(LOG_LEVEL_INFO, &logHandlerListArray, MAIN_BOARD_LOG_HANDLER_LIST_LENGTH, LOG_HANDLER_CATEGORY_ALL_MASK); }
void * key_thread(void * args) { struct key_thread_args* key_args = (struct key_thread_args*)args; char *char_ptr, buf1[32], buf2[32], *keys, *saved; int i, delay = 10000; char* logfilename = key_args->logfilename; char* statfilename = key_args->statfilename; logfile = fopen(logfilename, "w"); statfile = fopen(statfilename, "w"); signal(SIGINT, cleaner); signal(SIGTERM, cleaner); initLogs(); /* setup Xwindows */ disp = XOpenDisplay(NULL); if (disp == NULL) { fprintf(stderr, "Cannot open display\n"); exit(1); } XSynchronize(disp, TRUE); /* setup buffers */ saved = buf1; keys = buf2; XQueryKeymap(disp, saved); while (1) { /* find changed keys */ XQueryKeymap(disp, keys); for (i = 0; i < 32*8; i++) { /* if the key data is different that the default we saved before */ int kbit = BIT(keys, i); int sbit = BIT(saved, i); if(kbit > 0) kbit = 1; if(sbit > 0) sbit = 1; if (BIT(keys, i) != BIT(saved, i)) { register char* str; str = (char*) KeyCodeToStr(i); int j = lettertoi(str); if(j >= 0 && j < 26) { if (!sbit && kbit) { StrTimer(str, "start"); } if (sbit && !kbit) { StrTimer(str, "end"); out(str, logs[j]->time, logs[j]->numpressed); } } fflush(stdout); /* in case user is writing to a pipe */ } } char_ptr = saved; saved = keys; keys = char_ptr; if(key_args->exit) { outputStats(); fclose(statfile); fclose(logfile); return; } } }
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 }
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(); } }
int main(void) { setBoardName("MAIN BOARD"); setRobotMustStop(false); // LOG Global Configuration initLogs(DEBUG, &logHandlerListArray, MAIN_BOARD_LOG_HANDLER_LIST_LENGTH, LOG_HANDLER_CATEGORY_ALL_MASK); // LCD (LCD via Parallel interface) initLCDOutputStream(&lcdOutputStream); addLogHandler("LCD", &lcdOutputStream, LOG_LEVEL_ERROR, LOG_HANDLER_CATEGORY_ALL_MASK); // CONFIG initRobotConfigPic32(&robotConfig); // Open the serial Link for debug and LOG ! openSerialLink(&debugSerialStreamLink, &debugInputBuffer, &debugInputBufferArray, MAIN_BOARD_DEBUG_INPUT_BUFFER_LENGTH, &debugOutputBuffer, &debugOutputBufferArray, MAIN_BOARD_DEBUG_OUTPUT_BUFFER_LENGTH, &debugOutputStream, SERIAL_PORT_DEBUG, DEFAULT_SERIAL_SPEED); // Serial Debug LOG addLogHandler("UART", &debugOutputStream, DEBUG, LOG_HANDLER_CATEGORY_ALL_MASK); // LOG the BoardName appendString(getAlwaysOutputStreamLogger(), getBoardName()); println(getAlwaysOutputStreamLogger()); // SERIAL // Open the serial Link for the Motor Board openSerialLink(&motorSerialStreamLink, &motorInputBuffer, &motorInputBufferArray, MAIN_BOARD_MOTOR_INPUT_BUFFER_LENGTH, &motorOutputBuffer, &motorOutputBufferArray, MAIN_BOARD_MOTOR_OUTPUT_BUFFER_LENGTH, &motorOutputStream, SERIAL_PORT_MOTOR, DEFAULT_SERIAL_SPEED); // Open the serial Link for the Mechanical Board openSerialLink(&mechanicalBoard2SerialStreamLink, &mechanicalBoard2InputBuffer, &mechanicalBoard2InputBufferArray, MAIN_BOARD_MECA2_INPUT_BUFFER_LENGTH, &mechanicalBoard2OutputBuffer, &mechanicalBoard2OutputBufferArray, MAIN_BOARD_MECA2_OUTPUT_BUFFER_LENGTH, &mechanicalBoard2OutputStream, SERIAL_PORT_MECA2, DEFAULT_SERIAL_SPEED); // Open the serial Link for the PC openSerialLink(&pcSerialStreamLink, &pcInputBuffer, &pcInputBufferArray, MAIN_BOARD_PC_INPUT_BUFFER_LENGTH, &pcOutputBuffer, &pcOutputBufferArray, MAIN_BOARD_PC_OUTPUT_BUFFER_LENGTH, &pcOutputStream, SERIAL_PORT_PC, DEFAULT_SERIAL_SPEED); // MAIN I2C initI2cBus(&i2cBus, I2C_BUS_TYPE_MASTER, I2C_BUS_PORT_1); i2cMasterInitialize(&i2cBus); initI2cBusConnection(&motorI2cBusConnection, &i2cBus, MOTOR_BOARD_I2C_ADDRESS); initI2cBusConnection(&mechanicalBoard2I2cBusConnection, &i2cBus, MECHANICAL_BOARD_2_I2C_ADDRESS); // I2C Debug initI2CDebugBuffers(&i2cMasterDebugInputBuffer, &i2cMasterDebugInputBufferArray, MAIN_BOARD_I2C_DEBUG_MASTER_IN_BUFFER_LENGTH, &i2cMasterDebugOutputBuffer, &i2cMasterDebugOutputBufferArray, MAIN_BOARD_I2C_DEBUG_MASTER_OUT_BUFFER_LENGTH); setDebugI2cEnabled(false); // -> Eeproms initI2cBusConnection(&eepromI2cBusConnection, &i2cBus, ST24C512_ADDRESS_0); init24C512Eeprom(&eeprom, &eepromI2cBusConnection); // -> Clock initI2cBusConnection(&clockI2cBusConnection, &i2cBus, PCF8563_WRITE_ADDRESS); initClockPCF8563(&clock, &clockI2cBusConnection); // -> Temperature initI2cBusConnection(&temperatureI2cBusConnection, &i2cBus, LM75A_ADDRESS); initTemperatureLM75A(&temperature, &temperatureI2cBusConnection); // TIMERS initTimerList(&timerListArray, MAIN_BOARD_TIMER_LENGTH); // DEVICES, DRIVERS, DISPATCHERS initMainBoardDevicesDescriptor(); initMainBoardDriversDescriptor(); initMainBoardDriverDataDispatcherList(); // Start interruptions startTimerList(); loopUntilStart(&startMatch); counter = 1; clearBuffer(&mechanicalBoard2InputBuffer); // enableNotificationRobotInfraredDetector(DETECTOR_GROUP_TYPE_FORWARD); while (1) { if (!mainBoardWaitForInstruction(&startMatch)) { break; } } showEnd(getAlwaysOutputStreamLogger()); while (1) { // Avoid reboot even at end } }