static void mg_task(void *arg) { struct mg_mgr mgr; mg_init_cb mg_init = (mg_init_cb) arg; mg_mgr_init(&mgr, NULL); mg_init(&mgr); while (1) { struct mg_q_msg msg; mg_mgr_poll(&mgr, 1); if (osi_MsgQRead(&s_mg_q, &msg, 1) != OSI_OK) continue; switch (msg.type) { case MG_Q_MSG_CB: { msg.cb(&mgr, msg.arg); } } } }
int main( int argc, char *argv[] ) { int i; matfp = stdout; /* print out parser version */ printf("## Translated from MGF Version %d.%d\n", MG_VMAJOR, MG_VMINOR); /* initialize dispatch table */ mg_ehand[MG_E_COMMENT] = r_comment; /* we pass comments */ mg_ehand[MG_E_COLOR] = c_hcolor; /* they get color */ mg_ehand[MG_E_CONE] = r_cone; /* we do cones */ mg_ehand[MG_E_CMIX] = c_hcolor; /* they mix colors */ mg_ehand[MG_E_CSPEC] = c_hcolor; /* they get spectra */ mg_ehand[MG_E_CXY] = c_hcolor; /* they get chromaticities */ mg_ehand[MG_E_CCT] = c_hcolor; /* they get color temp's */ mg_ehand[MG_E_CYL] = r_cyl; /* we do cylinders */ mg_ehand[MG_E_ED] = c_hmaterial; /* they get emission */ mg_ehand[MG_E_FACE] = r_face; /* we do faces */ mg_ehand[MG_E_IES] = r_ies; /* we do IES files */ mg_ehand[MG_E_IR] = c_hmaterial; /* they get refractive index */ mg_ehand[MG_E_MATERIAL] = c_hmaterial; /* they get materials */ mg_ehand[MG_E_NORMAL] = c_hvertex; /* they get normals */ mg_ehand[MG_E_OBJECT] = obj_handler; /* they track object names */ mg_ehand[MG_E_POINT] = c_hvertex; /* they get points */ mg_ehand[MG_E_RD] = c_hmaterial; /* they get diffuse refl. */ mg_ehand[MG_E_RING] = r_ring; /* we do rings */ mg_ehand[MG_E_RS] = c_hmaterial; /* they get specular refl. */ mg_ehand[MG_E_SIDES] = c_hmaterial; /* they get # sides */ mg_ehand[MG_E_SPH] = r_sph; /* we do spheres */ mg_ehand[MG_E_TD] = c_hmaterial; /* they get diffuse trans. */ mg_ehand[MG_E_TS] = c_hmaterial; /* they get specular trans. */ mg_ehand[MG_E_VERTEX] = c_hvertex; /* they get vertices */ mg_ehand[MG_E_XF] = xf_handler; /* they track transforms */ mg_init(); /* initialize the parser */ /* get our options & print header */ printf("## %s", argv[0]); for (i = 1; i < argc && argv[i][0] == '-'; i++) { printf(" %s", argv[i]); switch (argv[i][1]) { case 'g': /* glow distance (meters) */ if (argv[i][2] || badarg(argc-i-1, argv+i+1, "f")) goto userr; glowdist = atof(argv[++i]); printf(" %s", argv[i]); break; case 'e': /* emitter multiplier */ if (argv[i][2] || badarg(argc-i-1, argv+i+1, "f")) goto userr; emult = atof(argv[++i]); printf(" %s", argv[i]); break; case 'm': /* materials file */ matfp = fopen(argv[++i], "a"); if (matfp == NULL) { fprintf(stderr, "%s: cannot append\n", argv[i]); exit(1); } printf(" %s", argv[i]); break; default: goto userr; } } putchar('\n'); if (i == argc) { /* convert stdin */ if (mg_load(NULL) != MG_OK) exit(1); if (mg_nunknown) printf("## %s: %u unknown entities\n", argv[0], mg_nunknown); } else /* convert each file */ for ( ; i < argc; i++) { printf("## %s %s ##############################\n", argv[0], argv[i]); if (mg_load(argv[i]) != MG_OK) exit(1); if (mg_nunknown) { printf("## %s %s: %u unknown entities\n", argv[0], argv[i], mg_nunknown); mg_nunknown = 0; } } exit(0); userr: fprintf(stderr, "Usage: %s [-g dist][-e mult][-m matf] [file.mgf] ..\n", argv[0]); exit(1); }
static enum cc3200_init_result cc3200_init(void *arg) { mongoose_init(); if (miot_uart_init(0, miot_uart_default_config(), NULL, NULL) == NULL) { return CC3200_INIT_UART_INIT_FAILED; } if (miot_uart_init(1, miot_uart_default_config(), NULL, NULL) == NULL) { return CC3200_INIT_UART_INIT_FAILED; } if (strcmp(MIOT_APP, "mongoose-iot") != 0) { LOG(LL_INFO, ("%s %s (%s)", MIOT_APP, build_version, build_id)); } LOG(LL_INFO, ("Mongoose IoT Firmware %s (%s)", mg_build_version, mg_build_id)); LOG(LL_INFO, ("RAM: %d total, %d free", miot_get_heap_size(), miot_get_free_heap_size())); int r = start_nwp(); if (r < 0) { LOG(LL_ERROR, ("Failed to start NWP: %d", r)); return CC3200_INIT_FAILED_TO_START_NWP; } g_boot_cfg_idx = get_active_boot_cfg_idx(); if (g_boot_cfg_idx < 0 || read_boot_cfg(g_boot_cfg_idx, &g_boot_cfg) < 0) { return CC3200_INIT_FAILED_TO_READ_BOOT_CFG; } LOG(LL_INFO, ("Boot cfg %d: 0x%llx, 0x%u, %s @ 0x%08x, %s", g_boot_cfg_idx, g_boot_cfg.seq, g_boot_cfg.flags, g_boot_cfg.app_image_file, g_boot_cfg.app_load_addr, g_boot_cfg.fs_container_prefix)); if (g_boot_cfg.flags & BOOT_F_FIRST_BOOT) { /* Tombstone the current config. If anything goes wrong between now and * commit, next boot will use the old one. */ uint64_t saved_seq = g_boot_cfg.seq; g_boot_cfg.seq = BOOT_CFG_TOMBSTONE_SEQ; write_boot_cfg(&g_boot_cfg, g_boot_cfg_idx); g_boot_cfg.seq = saved_seq; } r = cc3200_fs_init(g_boot_cfg.fs_container_prefix); if (r < 0) { LOG(LL_ERROR, ("FS init error: %d", r)); return CC3200_INIT_FS_INIT_FAILED; } else { /* * We aim to maintain at most 3 FS containers at all times. * Delete inactive FS container in the inactive boot configuration. */ struct boot_cfg cfg; int inactive_idx = (g_boot_cfg_idx == 0 ? 1 : 0); if (read_boot_cfg(inactive_idx, &cfg) >= 0) { fs_delete_inactive_container(cfg.fs_container_prefix); } } #if MIOT_ENABLE_UPDATER if (g_boot_cfg.flags & BOOT_F_FIRST_BOOT) { LOG(LL_INFO, ("Applying update")); r = miot_upd_apply_update(); if (r < 0) { LOG(LL_ERROR, ("Failed to apply update: %d", r)); return CC3200_INIT_UPDATE_FAILED; } } #endif enum miot_init_result ir = mg_init(); if (ir != MIOT_INIT_OK) { LOG(LL_ERROR, ("%s init error: %d", "MG", ir)); return CC3200_INIT_MG_INIT_FAILED; } #if MIOT_ENABLE_JS struct v7 *v7 = s_v7 = init_v7(&arg); ir = miot_init_js_all(v7); if (ir != MIOT_INIT_OK) { LOG(LL_ERROR, ("%s init error: %d", "JS", ir)); return CC3200_INIT_MG_INIT_JS_FAILED; } #endif #if MIOT_ENABLE_JS miot_prompt_init(v7, get_cfg()->debug.stdout_uart); #endif return CC3200_INIT_OK; }
int main( int argc, char *argv[] ) { int i; /* initialize dispatch table */ mg_ehand[MG_E_COMMENT] = i_comment; /* we pass comments */ mg_ehand[MG_E_COLOR] = c_hcolor; /* they get color */ mg_ehand[MG_E_CMIX] = c_hcolor; /* they mix colors */ mg_ehand[MG_E_CSPEC] = c_hcolor; /* they get spectra */ mg_ehand[MG_E_CXY] = c_hcolor; /* they get chromaticities */ mg_ehand[MG_E_CCT] = c_hcolor; /* they get color temp's */ mg_ehand[MG_E_CYL] = i_cyl; /* we do cylinders */ mg_ehand[MG_E_ED] = c_hmaterial; /* they get emission */ mg_ehand[MG_E_FACE] = i_face; /* we do faces */ mg_ehand[MG_E_MATERIAL] = c_hmaterial; /* they get materials */ mg_ehand[MG_E_NORMAL] = c_hvertex; /* they get normals */ mg_ehand[MG_E_OBJECT] = i_object; /* we track object names */ mg_ehand[MG_E_POINT] = c_hvertex; /* they get points */ mg_ehand[MG_E_RD] = c_hmaterial; /* they get diffuse refl. */ mg_ehand[MG_E_RS] = c_hmaterial; /* they get specular refl. */ mg_ehand[MG_E_SIDES] = c_hmaterial; /* they get # sides */ mg_ehand[MG_E_SPH] = i_sph; /* we do spheres */ mg_ehand[MG_E_TD] = c_hmaterial; /* they get diffuse trans. */ mg_ehand[MG_E_TS] = c_hmaterial; /* they get specular trans. */ mg_ehand[MG_E_VERTEX] = c_hvertex; /* they get vertices */ mg_ehand[MG_E_XF] = i_xf; /* we track transforms */ mg_init(); /* initialize the parser */ /* get options and print format line */ for (i = 1; i < argc && argv[i][0] == '-'; i++) if (!strcmp(argv[i], "-vrml")) outtype = O_VRML1; else if (!strcmp(argv[i], "-1")) outtype = O_INV1; else if (!strcmp(argv[i], "-2")) outtype = O_INV2; else goto userr; switch (outtype) { case O_INV1: printf("#Inventor V1.0 ascii\n"); break; case O_INV2: printf("#Inventor V2.0 ascii\n"); break; case O_VRML1: printf("#VRML V1.0 ascii\n"); break; } printf("## Translated from MGF Version %d.%d\n", MG_VMAJOR, MG_VMINOR); printf("Separator {\n"); /* begin root node */ /* general properties */ printf("MaterialBinding { value OVERALL }\n"); printf("NormalBinding { value PER_VERTEX_INDEXED }\n"); if (outtype != O_INV1) { printf("ShapeHints {\n"); printf("\tvertexOrdering CLOCKWISE\n"); printf("\tfaceType UNKNOWN_FACE_TYPE\n"); printf("}\n"); } if (i == argc) { /* load standard input */ if (mg_load(NULL) != MG_OK) exit(1); if (mg_nunknown) printf("## %s: %u unknown entities\n", argv[0], mg_nunknown); } /* load MGF files */ for ( ; i < argc; i++) { printf("## %s %s ##############################\n", argv[0], argv[i]); mg_nunknown = 0; if (mg_load(argv[i]) != MG_OK) exit(1); if (mg_nunknown) printf("## %s %s: %u unknown entities\n", argv[0], argv[i], mg_nunknown); } flush_cache(); /* flush face cache, just in case */ printf("}\n"); /* close root node */ exit(0); userr: fprintf(stderr, "%s: [-1|-2|-vrml] [file] ..\n", argv[0]); exit(1); }