int main (int argc, char ** argv) { Int status = 0; UInt numLoops = NUM_LOOPS_DFLT; UInt16 procId = PROC_ID_DFLT; /* Parse Args: */ switch (argc) { case 1: /* use defaults */ break; case 2: numLoops = atoi(argv[1]); break; case 3: numLoops = atoi(argv[1]); procId = atoi(argv[2]); break; default: printf("Usage: %s [<numLoops>] [<ProcId>]\n", argv[0]); printf("\tDefaults: numLoops: %d; ProcId: %d\n", NUM_LOOPS_DFLT, PROC_ID_DFLT); exit(0); } /* configure the transport factory */ Ipc_transportConfig(&TransportRpmsg_Factory); /* IPC initialization */ status = Ipc_start(); if (status < 0) { printf("Error: Ipc_start failed, error=%d\n", status); goto exit; } if ((procId == 0) || (procId >= MultiProc_getNumProcessors())) { printf("ProcId (%d) must be nonzero and less than %d\n", procId, MultiProc_getNumProcessors()); Ipc_stop(); exit(0); } printf("Using numLoops: %d; procId : %d\n", numLoops, procId); if (status >= 0) { MessageQApp_execute(numLoops, procId); Ipc_stop(); } else { printf("Ipc_start failed: status = %d\n", status); } exit: return (status); }
int main (int argc, char * argv[]) { Int32 status = 0; UInt32 numLoops = NUM_LOOPS_DFLT; UInt32 payloadSize = MINPAYLOADSIZE; UInt16 procId = PROC_ID_DFLT; /* Parse args: */ if (argc > 1) { numLoops = strtoul(argv[1], NULL, 0); } if (argc > 2) { payloadSize = MAX(strtoul(argv[2], NULL, 0), MINPAYLOADSIZE); } if (argc > 3) { procId = atoi(argv[3]); } if (argc > 4) { printf("Usage: %s [<numLoops>] [<payloadSize>] [<ProcId>]\n", argv[0]); printf("\tDefaults: numLoops: %d; payloadSize: %d, ProcId: %d\n", NUM_LOOPS_DFLT, MINPAYLOADSIZE, PROC_ID_DFLT); exit(0); } status = Ipc_start(); if (procId >= MultiProc_getNumProcessors()) { printf("ProcId must be less than %d\n", MultiProc_getNumProcessors()); Ipc_stop(); exit(0); } printf("Using numLoops: %d; payloadSize: %d, procId : %d\n", numLoops, payloadSize, procId); if (status >= 0) { MessageQApp_execute(numLoops, payloadSize, procId); Ipc_stop(); } else { printf("Ipc_start failed: status = %d\n", status); } return (status); }
int main (int argc, char ** argv) { Int32 status = 0; UInt32 numLoops = NUM_LOOPS_DFLT; UInt16 procId = PROC_ID_DFLT; /* Parse Args: */ switch (argc) { case 1: /* use defaults */ break; case 2: numLoops = atoi(argv[1]); break; case 3: numLoops = atoi(argv[1]); procId = atoi(argv[2]); break; default: printf("Usage: %s [<numLoops>] [<ProcId>]\n", argv[0]); printf("\tDefaults: numLoops: %d; ProcId: %d\n", NUM_LOOPS_DFLT, PROC_ID_DFLT); exit(0); } status = Ipc_start(); if (procId >= MultiProc_getNumProcessors()) { printf("ProcId must be less than %d\n", MultiProc_getNumProcessors()); Ipc_stop(); exit(0); } printf("Using numLoops: %d; procId : %d\n", numLoops, procId); if (status >= 0) { MessageQApp_execute(numLoops, procId); Ipc_stop(); } else { printf("Ipc_start failed: status = %d\n", status); } return(0); }
int main (int argc, char ** argv) { Int status = 0; int opt; UInt numLoops = NUM_LOOPS_DFLT; UInt16 procId = PROC_ID_DFLT; UInt32 faultId = 0; while ((opt = getopt(argc, argv, "f:")) != -1) { switch (opt) { case 'f': /* * Argument for -f corresponds to remote-side "fault" commands. * Negative commands cause remote fault before remote MessageQ_put. * Positive commands cause remote fault after remote MessageQ_put. */ faultId = atoi(optarg); printf("fault %d will be sent in 1st msg\n", faultId); break; default: fprintf(stderr, "Unknown arg '%s'\n", optarg); return 1; } } /* Parse Args: */ switch (argc - optind + 1) { case 1: /* use defaults */ break; case 2: numLoops = atoi(argv[optind]); break; case 3: numLoops = atoi(argv[optind]); procId = atoi(argv[optind + 1]); break; default: printf("Usage: %s [<numLoops>] [<ProcId>]\n", argv[0]); printf("\tDefaults: numLoops: %d; ProcId: %d\n", NUM_LOOPS_DFLT, PROC_ID_DFLT); exit(0); } /* configure the transport factory */ Ipc_transportConfig(&TransportRpmsg_Factory); /* IPC initialization */ status = Ipc_start(); if (status < 0) { printf("Error: Ipc_start failed, error=%d\n", status); goto exit; } if ((procId == 0) || (procId >= (MultiProc_getBaseIdOfCluster() + MultiProc_getNumProcessors()))) { printf("ProcId (%d) must be nonzero and less than %d\n", procId, MultiProc_getBaseIdOfCluster() + MultiProc_getNumProcessors()); Ipc_stop(); exit(0); } printf("Using numLoops: %d; procId : %d\n", numLoops, procId); if (MessageQApp_execute(numLoops, procId, faultId) < 0) { int nAttachAttempts = 1; printf("MessageQApp_execute failed, attempting detach/attach...\n"); Ipc_detach(procId); while (Ipc_attach(procId) != Ipc_S_SUCCESS) { nAttachAttempts++; if ((nAttachAttempts % 1000) == 0) { printf("Ipc_attach(%d) failed\n", procId); } } printf("Ipc_attach(%d) succeeded (after %d tries)\n", procId, nAttachAttempts); /* call without fault this time */ MessageQApp_execute(numLoops, procId, 0); } Ipc_stop(); exit: return (status); }