//------------------------------------------------------------------------------ int main(void) { tOplkError ret = kErrorOk; const UINT8 aMacAddr[] = {MAC_ADDR}; UINT8 nodeid; // Initialize helper modules gpio_init(); lcd_init(); // get node ID from input nodeid = gpio_getNodeid(); // initialize instance memset(&instance_l, 0, sizeof(instance_l)); instance_l.cycleLen = CYCLE_LEN; instance_l.nodeId = (nodeid != 0) ? nodeid : NODEID; instance_l.fShutdown = FALSE; instance_l.fGsOff = FALSE; // set mac address (last byte is set to node ID) memcpy(instance_l.aMacAddr, aMacAddr, sizeof(aMacAddr)); instance_l.aMacAddr[5] = instance_l.nodeId; initEvents(&eventCbPowerlink); arp_init((UINT8)instance_l.nodeId); PRINTF("----------------------------------------------------\n"); PRINTF("openPOWERLINK embedded CN DEMO application\n"); PRINTF("using openPOWERLINK Stack: %s\n", PLK_DEFINED_STRING_VERSION); PRINTF("----------------------------------------------------\n"); PRINTF("NODEID=0x%02X\n", instance_l.nodeId); lcd_printNodeId(instance_l.nodeId); if ((ret = initPowerlink(&instance_l)) != kErrorOk) goto Exit; if ((ret = initApp()) != kErrorOk) goto Exit; if ((ret = oplk_setNonPlkForward(TRUE)) != kErrorOk) goto Exit; loopMain(&instance_l); Exit: arp_exit(); shutdownPowerlink(&instance_l); shutdownApp(); // Shutdown helper modules lcd_exit(); gpio_exit(); return 0; }
//------------------------------------------------------------------------------ int main(void) { tOplkError ret = kErrorOk; const UINT8 aMacAddr[] = {MAC_ADDR}; UINT8 nodeid; lcd_init(); // get node ID from input nodeid = gpio_getNodeid(); // initialize instance OPLK_MEMSET(&instance_l, 0, sizeof(instance_l)); instance_l.cycleLen = CYCLE_LEN; instance_l.nodeId = (nodeid != 0) ? nodeid : NODEID; instance_l.fShutdown = FALSE; instance_l.fGsOff = FALSE; instance_l.pCdcBuffer = (unsigned char*)aCdcBuffer; instance_l.cdcBufferSize = sizeof(aCdcBuffer); // set mac address (last byte is set to node ID) OPLK_MEMCPY(instance_l.aMacAddr, aMacAddr, sizeof(aMacAddr)); instance_l.aMacAddr[5] = instance_l.nodeId; initEvents(&instance_l.fGsOff); PRINTF("----------------------------------------------------\n"); PRINTF("openPOWERLINK console MN DEMO application\n"); PRINTF("using openPOWERLINK Stack: %s\n", PLK_DEFINED_STRING_VERSION); PRINTF("----------------------------------------------------\n"); PRINTF("NODEID=0x%02X\n", instance_l.nodeId); lcd_printNodeId((WORD)instance_l.nodeId); if ((ret = initPowerlink(&instance_l)) != kErrorOk) goto Exit; if ((ret = initApp()) != kErrorOk) goto Exit; loopMain(&instance_l); Exit: shutdownPowerlink(&instance_l); shutdownApp(); return 0; }
//------------------------------------------------------------------------------ int main(int argc, char** argv) { tOplkError ret = kErrorOk; tOptions opts; getOptions(argc, argv, &opts); #if defined(__COBALT__) mlockall(MCL_CURRENT | MCL_FUTURE); #endif if (system_init() != 0) { fprintf(stderr, "Error initializing system!"); return 0; } initEvents(&fGsOff_l); printf("----------------------------------------------------\n"); printf("openPOWERLINK console MN DEMO application\n"); printf("using openPOWERLINK Stack: %s\n", PLK_DEFINED_STRING_VERSION); printf("----------------------------------------------------\n"); if ((ret = initPowerlink(CYCLE_LEN, opts.cdcFile, aMacAddr_g)) != kErrorOk) goto Exit; if ((ret = initApp()) != kErrorOk) goto Exit; loopMain(); Exit: shutdownPowerlink(); shutdownApp(); system_exit(); return 0; }
//------------------------------------------------------------------------------ int main (int argc, char** argv) { tOplkError ret = kErrorOk; tOptions opts; getOptions(argc, argv, &opts); if (system_init() != 0) { fprintf(stderr, "Error initializing system!"); return 0; } initEvents(&fGsOff_l); printf("----------------------------------------------------\n"); printf("openPOWERLINK console CN DEMO application\n"); printf("using openPOWERLINK Stack: %s\n", PLK_DEFINED_STRING_VERSION); printf("----------------------------------------------------\n"); if ((ret = initPowerlink(CYCLE_LEN, aMacAddr_l, opts.nodeId)) != kErrorOk) goto Exit; if ((ret = initApp()) != kErrorOk) goto Exit; loopMain(); Exit: shutdownPowerlink(); shutdownApp(); system_exit(); return 0; }
//------------------------------------------------------------------------------ int main(void) { tOplkError ret = kErrorOk; const UINT8 aMacAddr[] = {MAC_ADDR}; UINT8 nodeid; #if (CONFIG_CDC_ON_SD != FALSE) tCdcBuffInfo cdcBuffInfo; #endif // Initialize helper modules gpio_init(); lcd_init(); // get node ID from input nodeid = gpio_getNodeid(); // initialize instance memset(&instance_l, 0, sizeof(instance_l)); instance_l.cycleLen = CYCLE_LEN; instance_l.nodeId = (nodeid != 0) ? nodeid : NODEID; instance_l.fShutdown = FALSE; instance_l.fGsOff = FALSE; #if (CONFIG_CDC_ON_SD != FALSE) if (sdcard_getCdcOnSd(pszCdcFilename_g, &cdcBuffInfo) != 0) { goto Exit; } instance_l.pCdcBuffer = (unsigned char*)cdcBuffInfo.pCdcBuffer; instance_l.cdcBufferSize = cdcBuffInfo.cdcSize; #else instance_l.pCdcBuffer = (unsigned char*)aCdcBuffer; instance_l.cdcBufferSize = sizeof(aCdcBuffer); #endif // set mac address (last byte is set to node ID) memcpy(instance_l.aMacAddr, aMacAddr, sizeof(aMacAddr)); instance_l.aMacAddr[5] = instance_l.nodeId; initEvents(&instance_l.fGsOff, &eventCbPowerlink); arp_init((UINT8)instance_l.nodeId); PRINTF("----------------------------------------------------\n"); PRINTF("openPOWERLINK console MN DEMO application\n"); PRINTF("using openPOWERLINK Stack: %s\n", PLK_DEFINED_STRING_VERSION); PRINTF("----------------------------------------------------\n"); PRINTF("NODEID=0x%02X\n", instance_l.nodeId); lcd_printNodeId(instance_l.nodeId); if ((ret = initPowerlink(&instance_l)) != kErrorOk) goto Exit; if ((ret = initApp()) != kErrorOk) goto Exit; if ((ret = oplk_setNonPlkForward(TRUE)) != kErrorOk) goto Exit; loopMain(&instance_l); Exit: #if (CONFIG_CDC_ON_SD != FALSE) sdcard_freeCdcBuffer(&cdcBuffInfo); #endif arp_exit(); shutdownPowerlink(&instance_l); shutdownApp(); // Shutdown helper modules lcd_exit(); gpio_exit(); return 0; }
int sageDisplayManager::parseMessage(sageMessage *msg) { if (!msg) { sage::printLog("sageDisplayManager::parseMessage : message is NULL"); return -1; } switch (msg->getCode()) { case RCV_INIT : { //std::cout << "rcv init : " << (char *)msg->getData() << std::endl; if (init((char *)msg->getData()) < 0) rcvEnd = true; break; } case RCV_UPDATE_DISPLAY : { updateDisplay((char *)msg->getData()); break; } case RCV_CLEAR_DISPLAY : { clearDisplay(atoi((char *)msg->getData())); break; } case SHUTDOWN_RECEIVERS : { shutdownApp(-1); //std::cout << "all apps are shutdown" << std::endl; //sage::sleep(1); rcvEnd = true; //delete shared->displayObj; //_exit(0); break; } case RCV_CHANGE_BGCOLOR : { changeBGColor(msg); break; } case RCV_CHANGE_DEPTH : { changeDepth(msg); break; } case RCV_SHUTDOWN_APP : { shutdownApp(atoi((char *)msg->getData())); break; } case RCV_PERF_INFO_REQ : { startPerformanceReport(msg); break; } case RCV_PERF_INFO_STOP : { stopPerformanceReport(msg); break; } case ADD_OBJECT : { shared->displayObj->addDrawObjectInstance((char *)msg->getData()); break; } case UPDATE_OBJECT_POSITION : { shared->displayObj->updateObjectPosition((char *)msg->getData()); break; } case REMOVE_OBJECT : { shared->displayObj->removeDrawObject((char *)msg->getData()); break; } case OBJECT_MESSAGE : { shared->displayObj->forwardObjectMessage((char *)msg->getData()); break; } case SHOW_OBJECT : { shared->displayObj->showObject((char *)msg->getData()); break; } } msg->destroy(); delete msg; return 0; }