static int run_spec(int i, xusb_filter_t filter, char *devpath, int timeout) { const struct xusb_spec *s = &known_devices[i].spec; int interface_num = known_devices[i].interface_num; struct xlist_node *xlist; struct xlist_node *curr; struct xusb_device *xusb_device; int success = 1; if (!s->name) return 0; xlist = xusb_find_byproduct(s, 1, filter, devpath); if (!xlist_length(xlist)) return 1; INFO("total %zd devices of type %s\n", xlist_length(xlist), s->name); for (curr = xlist_shift(xlist); curr; curr = xlist_shift(xlist)) { struct xusb_iface *xusb_iface; int ret; xusb_device = curr->data; xusb_showinfo(xusb_device); INFO("Testing interface %d\n", interface_num); ret = xusb_claim(xusb_device, interface_num, &xusb_iface); if (ret == 0) { ret = test_device(xusb_iface, timeout); if (ret < 0) success = 0; } xusb_destroy(xusb_device); } xlist_destroy(xlist, xusb_destructor); return success; }
int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::set_thread_priority_safe(); //variables to be set by po std::string args; double duration; double rate; //setup the program options po::options_description desc("Allowed options"); desc.add_options() ("help", "help message") ("args", po::value<std::string>(&args)->default_value(""), "single uhd device address args") ("duration", po::value<double>(&duration)->default_value(10.0), "duration for each test in seconds") ("rate", po::value<double>(&rate), "specify to perform a single test as this rate (sps)") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); //print the help message if (vm.count("help")){ std::cout << boost::format("UHD Benchmark RX Rate %s") % desc << std::endl; return ~0; } //verify that rate was specified if (not vm.count("rate")){ std::cerr << "Please specify the sample rate with --rate" << std::endl; return ~0; } //create a usrp device std::cout << std::endl; uhd::device_addrs_t device_addrs = uhd::device::find(args); if (device_addrs.empty()){ std::cerr << "Could not find any devices for: " << args << std::endl; return ~0; } if (device_addrs.at(0).get("type", "") == "usrp1"){ std::cerr << "*** Warning! ***" << std::endl; std::cerr << "Benchmark RX results will be inaccurate on USRP1 due to soft-time control.\n" << std::endl; } std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl; uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(device_addrs.at(0)); std::cout << boost::format("Using Device: %s") % usrp->get_pp_string() << std::endl; //start the test usrp->set_rx_rate(rate); rate = usrp->get_rx_rate(); test_device(usrp, rate, duration); //finished std::cout << std::endl << "Done!" << std::endl << std::endl; return 0; }
void SDL_EnumUnixAudioDevices(int iscapture, int classic, int (*test)(int fd), SDL_AddAudioDevice addfn) { const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT); const char *audiodev; char audiopath[1024]; if (test == NULL) test = test_stub; /* Figure out what our audio device is */ if (((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) && ((audiodev = SDL_getenv("AUDIODEV")) == NULL)) { if (classic) { audiodev = _PATH_DEV_AUDIO; } else { struct stat sb; /* Added support for /dev/sound/\* in Linux 2.4 */ if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) && ((stat(_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode))) { audiodev = _PATH_DEV_DSP24; } else { audiodev = _PATH_DEV_DSP; } } } test_device(audiodev, flags, test, addfn); if (SDL_strlen(audiodev) < (sizeof(audiopath) - 3)) { int instance = 0; while (instance++ <= 64) { SDL_snprintf(audiopath, SDL_arraysize(audiopath), "%s%d", audiodev, instance); test_device(audiopath, flags, test, addfn); } } }
void test_platforms() { int i, j; char desc[256]; struct cl_exec exec = { 0, 0, 1 }; //Initialize the runtime cl_runtime rt = new_cl_runtime(false); printf("Testing %d platforms\n\n", get_num_platforms()); for(i = 0; i < get_num_platforms(); i++) { exec.platform = i; clGetPlatformInfo(get_platform(rt, i), CL_PLATFORM_NAME, sizeof(desc), desc, NULL); printf("Testing devices for %s platform\n", desc); for(j = 0; j < get_num_devices(i); j++) { exec.device = j; test_device(rt, exec, get_device(rt, i, j)); } printf("\n"); } delete_cl_runtime(rt); }
int main(int argc, char** argv) { bool show_help = false; bool debug_mode = false; const struct libusb_version* version; int j, r; size_t i, arglen; unsigned tmp_vid, tmp_pid; uint16_t endian_test = 0xBE00; char *error_lang = NULL, *old_dbg_str = NULL, str[256]; // Default to generic, expecting VID:PID VID = 0; PID = 0; test_mode = USE_GENERIC; if (((uint8_t*)&endian_test)[0] == 0xBE) { printf("Despite their natural superiority for end users, big endian\n" "CPUs are not supported with this program, sorry.\n"); return 0; } if (argc >= 2) { for (j = 1; j<argc; j++) { arglen = strlen(argv[j]); if ( ((argv[j][0] == '-') || (argv[j][0] == '/')) && (arglen >= 2) ) { switch(argv[j][1]) { case 'd': debug_mode = true; break; case 'i': extra_info = true; break; case 'w': force_device_request = true; break; case 'b': if ((j+1 >= argc) || (argv[j+1][0] == '-') || (argv[j+1][0] == '/')) { printf(" Option -b requires a file name\n"); return 1; } binary_name = argv[++j]; binary_dump = true; break; case 'l': if ((j+1 >= argc) || (argv[j+1][0] == '-') || (argv[j+1][0] == '/')) { printf(" Option -l requires an ISO 639-1 language parameter\n"); return 1; } error_lang = argv[++j]; break; case 'j': // OLIMEX ARM-USB-TINY JTAG, 2 channel composite device - 2 interfaces if (!VID && !PID) { VID = 0x15BA; PID = 0x0004; } break; case 'k': // Generic 2 GB USB Key (SCSI Transparent/Bulk Only) - 1 interface if (!VID && !PID) { VID = 0x0204; PID = 0x6025; } break; // The following tests will force VID:PID if already provided case 'p': // Sony PS3 Controller - 1 interface VID = 0x054C; PID = 0x0268; test_mode = USE_PS3; break; case 's': // Microsoft Sidewinder Precision Pro Joystick - 1 HID interface VID = 0x045E; PID = 0x0008; test_mode = USE_HID; break; case 'x': // Microsoft XBox Controller Type S - 1 interface VID = 0x045E; PID = 0x0289; test_mode = USE_XBOX; break; default: show_help = true; break; } } else { for (i=0; i<arglen; i++) { if (argv[j][i] == ':') break; } if (i != arglen) { if (sscanf(argv[j], "%x:%x" , &tmp_vid, &tmp_pid) != 2) { printf(" Please specify VID & PID as \"vid:pid\" in hexadecimal format\n"); return 1; } VID = (uint16_t)tmp_vid; PID = (uint16_t)tmp_pid; } else { show_help = true; } } } } if ((show_help) || (argc == 1) || (argc > 7)) { printf("usage: %s [-h] [-d] [-i] [-k] [-b file] [-l lang] [-j] [-x] [-s] [-p] [-w] [vid:pid]\n", argv[0]); printf(" -h : display usage\n"); printf(" -d : enable debug output\n"); printf(" -i : print topology and speed info\n"); printf(" -j : test composite FTDI based JTAG device\n"); printf(" -k : test Mass Storage device\n"); printf(" -b file : dump Mass Storage data to file 'file'\n"); printf(" -p : test Sony PS3 SixAxis controller\n"); printf(" -s : test Microsoft Sidewinder Precision Pro (HID)\n"); printf(" -x : test Microsoft XBox Controller Type S\n"); printf(" -l lang : language to report errors in (ISO 639-1)\n"); printf(" -w : force the use of device requests when querying WCID descriptors\n"); printf("If only the vid:pid is provided, xusb attempts to run the most appropriate test\n"); return 0; } // xusb is commonly used as a debug tool, so it's convenient to have debug output during libusb_init(), // but since we can't call on libusb_set_debug() before libusb_init(), we use the env variable method old_dbg_str = getenv("LIBUSB_DEBUG"); if (debug_mode) { putenv("LIBUSB_DEBUG=4"); // LIBUSB_LOG_LEVEL_DEBUG } version = libusb_get_version(); printf("Using libusb v%d.%d.%d.%d\n\n", version->major, version->minor, version->micro, version->nano); r = libusb_init(NULL); if (r < 0) return r; // If not set externally, and no debug option was given, use info log level if ((old_dbg_str == NULL) && (!debug_mode)) libusb_set_debug(NULL, LIBUSB_LOG_LEVEL_INFO); if (error_lang != NULL) { r = libusb_setlocale(error_lang); if (r < 0) printf("Invalid or unsupported locale '%s': %s\n", error_lang, libusb_strerror((enum libusb_error)r)); } test_device(VID, PID); libusb_exit(NULL); if (debug_mode) { snprintf(str, sizeof(str), "LIBUSB_DEBUG=%s", (old_dbg_str == NULL)?"":old_dbg_str); str[sizeof(str) - 1] = 0; // Windows may not NUL terminate the string } return 0; }
int main(int argc, char** argv) { bool show_help = false; bool debug_mode = false; const struct libusb_version* version; int j, r; size_t i, arglen; unsigned tmp_vid, tmp_pid; uint16_t endian_test = 0xBE00; // Default to generic, expecting VID:PID VID = 0; PID = 0; test_mode = USE_GENERIC; if (((uint8_t*)&endian_test)[0] == 0xBE) { printf("Despite their natural superiority for end users, big endian\n" "CPUs are not supported with this program, sorry.\n"); return 0; } if (argc >= 2) { for (j = 1; j<argc; j++) { arglen = strlen(argv[j]); if ( ((argv[j][0] == '-') || (argv[j][0] == '/')) && (arglen >= 2) ) { switch(argv[j][1]) { case 'd': debug_mode = true; break; case 'b': if (j+1 < argc) { strncpy(binary_name, argv[j+1], 64); j++; } binary_dump = true; break; case 'g': break; case 'j': // OLIMEX ARM-USB-TINY JTAG, 2 channel composite device - 2 interfaces if (!VID && !PID) { VID = 0x15BA; PID = 0x0004; } break; case 'k': // Generic 2 GB USB Key (SCSI Transparent/Bulk Only) - 1 interface if (!VID && !PID) { VID = 0x0204; PID = 0x6025; } break; // The following tests will force VID:PID if already provided case 'p': // Sony PS3 Controller - 1 interface VID = 0x054C; PID = 0x0268; test_mode = USE_PS3; break; case 's': // Microsoft Sidewinder Precision Pro Joystick - 1 HID interface VID = 0x045E; PID = 0x0008; test_mode = USE_HID; break; case 'x': // Microsoft XBox Controller Type S - 1 interface VID = 0x045E; PID = 0x0289; test_mode = USE_XBOX; break; default: show_help = true; break; } } else { for (i=0; i<arglen; i++) { if (argv[j][i] == ':') break; } if (i != arglen) { if (sscanf_s(argv[j], "%x:%x" , &tmp_vid, &tmp_pid) != 2) { printf(" Please specify VID & PID as \"vid:pid\" in hexadecimal format\n"); return 1; } VID = (uint16_t)tmp_vid; PID = (uint16_t)tmp_pid; } else { show_help = true; } } } } if ((show_help) || (argc == 1) || (argc > 7)) { printf("usage: %s [-d] [-b [file]] [-h] [-i] [-j] [-k] [-x] [vid:pid]\n", argv[0]); printf(" -h: display usage\n"); printf(" -d: enable debug output (if library was compiled with debug enabled)\n"); printf(" -b: dump Mass Storage first block to binary file\n"); printf(" -g: short generic test (default)\n"); printf(" -k: test generic Mass Storage USB device (using WinUSB)\n"); printf(" -j: test FTDI based JTAG device (using WinUSB)\n"); printf(" -p: test Sony PS3 SixAxis controller (using WinUSB)\n"); printf(" -s: test Microsoft Sidewinder Precision Pro (using HID)\n"); printf(" -x: test Microsoft XBox Controller Type S (using WinUSB)\n"); return 0; } version = libusb_get_version(); printf("Using libusbx v%d.%d.%d.%d\n\n", version->major, version->minor, version->micro, version->nano); r = libusb_init(NULL); if (r < 0) return r; libusb_set_debug(NULL, debug_mode?LOG_LEVEL_DEBUG:LOG_LEVEL_INFO); test_device(VID, PID); libusb_exit(NULL); return 0; }
int execute(void) { long long tmp; int cmp; switch(opcode) { //add case 0x18: ra += load_mem(&memory[path],3); break; //and case 0x40: ra &= load_mem(&memory[path],3); break; //comp // = -> 0b001 // > -> 0b010 // < -> 0b100 // save status in register sw case 0x28: cmp = load_mem(&memory[path],3); if(ra==cmp) rsw = 0x1; else if (ra>cmp) rsw = 0x2; else if (ra<cmp) rsw = 0x4; else rsw = 0; break; //div case 0x24: ra /= load_mem(&memory[path],3); break; //j case 0x3C: rpc = path; break; //jeq case 0x30: if(rsw==0x1) rpc = path; break; //jgt case 0x34: if(rsw==0x2) rpc = path; break; //jlt case 0x38: if(rsw==0x4) rpc = path; break; //jsub case 0x48: rl = rpc; rpc = path; break; //lda case 0x00: ra = load_mem(&memory[path],3); break; //ldch case 0x50: ra = (ra&0xFFFF00) + load_mem(&memory[path], 1); break; //ldl case 0x08: rl = load_mem(&memory[path],3); break; //ldx case 0x04: rx = load_mem(&memory[path],3); break; //mul case 0x20: tmp = (long long) ra * load_mem(&memory[path],3); ra = (int) (0xFFFFFF & tmp); break; //or case 0x44: ra |= load_mem(&memory[path],3); break; //rsub case 0x4C: rpc = rl; break; //sta case 0x0C: //incomplete save_mem(ra, &memory[path], 3); break; //stch case 0x54: save_mem(ra, &memory[path], 1); break; //stl case 0x14: save_mem(rl, &memory[path], 3); break; //stsw case 0xE8: save_mem(rsw, &memory[path], 3); break; //stx case 0x10: save_mem(rx, &memory[path], 3); break; //sub case 0x1C: ra -= load_mem(&memory[path], 3); break; //tix case 0x2C: cmp = load_mem(&memory[path],3); rx++; if(rx==cmp) rsw = 0x1; else if (rx>cmp) rsw = 0x2; else if (rx<cmp) rsw = 0x4; else rsw = 0; break; //td case 0xE0: rsw = test_device(memory[path]); break; //rd case 0xD8: ra = (ra&0xFFFF00) + read_device(memory[path]); break; //wd case 0xDC: write_device(memory[path], (ra&0x0000FF)); break; //break case 0xFF: return 10; break; default: printf("CPU Error: Could not found opcode\n"); printf("rpc= %06X\n", rpc); return 11; break; } return 0; }
int main() { pj_caching_pool cp; pj_bool_t done = PJ_FALSE; pj_status_t status; /* Init pjlib */ status = pj_init(); PJ_ASSERT_RETURN(status==PJ_SUCCESS, 1); pj_log_set_decor(PJ_LOG_HAS_NEWLINE); /* Must create a pool factory before we can allocate any memory. */ pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0); status = pjmedia_aud_subsys_init(&cp.factory); if (status != PJ_SUCCESS) { app_perror("pjmedia_aud_subsys_init()", status); pj_caching_pool_destroy(&cp); pj_shutdown(); return 1; } list_devices(); while (!done) { char line[80]; print_menu(); if (fgets(line, sizeof(line), stdin)==NULL) break; switch (line[0]) { case 'l': list_devices(); break; case 'R': pjmedia_aud_dev_refresh(); puts("Audio device list refreshed."); break; case 'i': { unsigned dev_index; if (sscanf(line+2, "%u", &dev_index) != 1) { puts("error: device ID required"); break; } show_dev_info(dev_index); } break; case 't': { pjmedia_dir dir; int rec_id, play_id; unsigned clock_rate, ptime, chnum; int cnt; cnt = sscanf(line+2, "%d %d %u %u %u", &rec_id, &play_id, &clock_rate, &ptime, &chnum); if (cnt < 4) { puts("error: not enough parameters"); break; } if (clock_rate < 8000 || clock_rate > 128000) { puts("error: invalid clock rate"); break; } if (ptime < 10 || ptime > 500) { puts("error: invalid ptime"); break; } if (cnt==5) { if (chnum < 1 || chnum > 4) { puts("error: invalid number of channels"); break; } } else { chnum = 1; } if (rec_id >= 0 && rec_id < (int)dev_count) { if (play_id >= 0 && play_id < (int)dev_count) dir = PJMEDIA_DIR_CAPTURE_PLAYBACK; else dir = PJMEDIA_DIR_CAPTURE; } else if (play_id >= 0 && play_id < (int)dev_count) { dir = PJMEDIA_DIR_PLAYBACK; } else { puts("error: at least one valid device index required"); break; } test_device(dir, rec_id, play_id, clock_rate, ptime, chnum); } break; case 'r': /* record */ { int index; char filename[80]; int count; count = sscanf(line+2, "%d %s", &index, filename); if (count==1) record(index, NULL); else if (count==2) record(index, filename); else puts("error: invalid command syntax"); } break; case 'p': /* playback */ { int index; char filename[80]; int count; count = sscanf(line+2, "%d %s", &index, filename); if (count==1) play_file(index, NULL); else if (count==2) play_file(index, filename); else puts("error: invalid command syntax"); } break; case 'd': /* latencies */ { int rec_lat, play_lat; if (sscanf(line+2, "%d %d", &rec_lat, &play_lat) == 2) { capture_lat = (unsigned) (rec_lat>=0? rec_lat:PJMEDIA_SND_DEFAULT_REC_LATENCY); playback_lat = (unsigned) (play_lat >= 0? play_lat : PJMEDIA_SND_DEFAULT_PLAY_LATENCY); printf("Recording latency=%ums, playback latency=%ums", capture_lat, playback_lat); } else { printf("Current latencies: record=%ums, playback=%ums", capture_lat, playback_lat); } puts(""); } break; case 'v': if (pj_log_get_level() <= 3) { pj_log_set_level(5); puts("Logging set to detail"); } else { pj_log_set_level(3); puts("Logging set to quiet"); } break; case 'q': done = PJ_TRUE; break; } } pj_caching_pool_destroy(&cp); pj_shutdown(); return 0; }
int main(int argc, char *argv[]) { int t, i; int maxdev; int flags = 0; int status = 0; int numdev; extern int optind; testcfg_t *tcfg; (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); tcfg = &test_stereo; /* * Simple command line switch handling. */ while ((i = getopt(argc, argv, "l2457")) != EOF) { switch (i) { case 'l': flags |= TF_LOOP; break; case '2': tcfg = &test_stereo; break; case '4': tcfg = &test_quad; break; case '5': tcfg = &test_51; break; case '7': tcfg = &test_71; break; default: (void) printf(_("Usage: %s [options...] [device]\n" " -2 Stereo test\n" " -4 Quadraphonic 4.0 test\n" " -5 Surround 5.1 test\n" " -7 Surround 7.1 test\n" " -l Loop test\n"), argv[0]); exit(-1); } } /* * Open the mixer device used for calling SNDCTL_SYSINFO and * SNDCTL_AUDIOINFO. */ if ((mixerfd = open("/dev/mixer", O_RDWR, 0)) == -1) { int err = errno; perror("/dev/mixer"); errno = err; describe_error(errno); exit(-1); } prepare(tcfg); /* Prepare the wave data */ /* * Enumerate all devices and play the test sounds. */ maxdev = find_num_devices(); if (maxdev < 1) { (void) printf(_("\n*** No audio hardware available ***\n")); exit(-1); } numdev = (argc - optind); do { char *dn; oss_audioinfo ainfo; if (numdev > 0) { for (t = 0; t < numdev; t++) { dn = argv[optind + t]; if (!test_device(dn, flags, tcfg)) status++; } } else { for (t = 0; t < maxdev; t++) { ainfo.dev = t; if (ioctl(mixerfd, SNDCTL_AUDIOINFO, &ainfo) == -1) { perror("SNDCTL_AUDIOINFO"); status++; continue; } dn = ainfo.devnode; if (!test_device(dn, flags, tcfg)) status++; } } if (status == 0) (void) printf(_("\n*** All tests completed OK ***\n")); else (void) printf(_("\n*** Errors were detected ***\n")); } while (flags & TF_LOOP); (void) close(mixerfd); return (status); }