static void show_params(t_hydra_console *con) { int i, cnt; mode_config_proto_t* proto = &con->mode->proto; cprintf(con, "Device: SPI%d\r\nGPIO resistor: %s\r\nMode: %s\r\n" "Frequency: ", proto->dev_num + 1, proto->dev_gpio_pull == MODE_CONFIG_DEV_GPIO_PULLUP ? "pull-up" : proto->dev_gpio_pull == MODE_CONFIG_DEV_GPIO_PULLDOWN ? "pull-down" : "floating", proto->dev_mode == DEV_SPI_MASTER ? "master" : "slave"); print_freq(con, speeds[proto->dev_num][proto->dev_speed]); cprintf(con, " ("); for (i = 0, cnt = 0; i < SPEED_NB; i++) { if (proto->dev_speed == i) continue; if (cnt++) cprintf(con, ", "); print_freq(con, speeds[proto->dev_num][i]); } cprintf(con, ")\r\n"); cprintf(con, "Polarity: %d\r\nPhase: %d\r\nBit order: %s first\r\n", proto->dev_polarity, proto->dev_phase, proto->dev_bit_lsb_msb == DEV_SPI_FIRSTBIT_MSB ? "MSB" : "LSB"); }
int main(void){ int count, v, i, j, start; pi = atan(1)*4; count = 0; while (scanf("%d\n", &num_edges) == 1 && num_edges > 0) { if (count > 0) printf("\n"); printf("Case %d\n", ++count); clear_all(); build_graph(); while ((v = next_node(&start)) != -1) { traverse(v, 1, start, start); /* DEBUG */ printf("\nGraph:\n\n"); for (i = 0; i < num_nodes; i++) { for (j = 0; j < num_nodes; j++) { printf("%3d", graph[i][j]); } printf("\n"); } printf("\n"); /* End of DEBUG */ } print_freq(); } return 0; }
static void show_params(t_hydra_console *con) { int i, cnt; mode_config_proto_t* proto = &con->mode->proto; cprintf(con, "GPIO resistor: %s\r\nFrequency: ", proto->dev_gpio_pull == MODE_CONFIG_DEV_GPIO_PULLUP ? "pull-up" : proto->dev_gpio_pull == MODE_CONFIG_DEV_GPIO_PULLDOWN ? "pull-down" : "floating"); print_freq(con, speeds[proto->dev_speed]); cprintf(con, " ("); for (i = 0, cnt = 0; i < SPEED_NB; i++) { if (proto->dev_speed == (int)i) continue; if (cnt++) cprintf(con, ", "); print_freq(con, speeds[i]); } cprintf(con, ")\r\n"); }
/* * Check options and call the proper handler */ static int print_one_device(int skfd, int format, int wtype, const char* ifname) { int ret; /* Check wtype */ switch(wtype) { case WTYPE_AP: /* Try to print an AP */ ret = print_ap(skfd, ifname, format); break; case WTYPE_CHANNEL: /* Try to print channel */ ret = print_channel(skfd, ifname, format); break; case WTYPE_FREQ: /* Try to print frequency */ ret = print_freq(skfd, ifname, format); break; case WTYPE_MODE: /* Try to print the mode */ ret = print_mode(skfd, ifname, format); break; case WTYPE_PROTO: /* Try to print the protocol */ ret = print_protocol(skfd, ifname, format); break; default: /* Try to print an ESSID */ ret = print_essid(skfd, ifname, format); if(ret < 0) { /* Try to print a nwid */ ret = print_nwid(skfd, ifname, format); } } return(ret); }
int print_cpuinfo(void) { const char *cpu_model; int len; /* For SoC with no real CPU ID in naming convention. */ cpu_model = fdt_getprop(gd->fdt_blob, 0, "cpu-model", &len); if (cpu_model) printf("CPU: %.*s @ ", len, cpu_model); else printf("CPU: %s%X @ ", s5p_get_cpu_name(), s5p_cpu_id); print_freq(get_arm_clk(), "\n"); return 0; }
int SYSTEM_HW_CPU(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) { int ret = SYSINFO_RET_FAIL, filter, cpu, cur_cpu = -1, offset = 0; zbx_uint64_t maxfreq = FAIL, curfreq = FAIL; char line[MAX_STRING_LEN], name[MAX_STRING_LEN], tmp[MAX_STRING_LEN], buffer[MAX_BUFFER_LEN]; FILE *f; if (2 < num_param(param)) return ret; if (0 != get_param(param, 1, tmp, sizeof(tmp)) || '\0' == *tmp || 0 == strcmp(tmp, "all")) cpu = HW_CPU_ALL_CPUS; /* show all CPUs by default */ else if (FAIL == is_uint(tmp)) return ret; else cpu = atoi(tmp); if (0 != get_param(param, 2, tmp, sizeof(tmp)) || '\0' == *tmp || 0 == strcmp(tmp, "full")) filter = HW_CPU_SHOW_ALL; /* show full info by default */ else if (0 == strcmp(tmp, "maxfreq")) filter = HW_CPU_SHOW_MAXFREQ; else if (0 == strcmp(tmp, "vendor")) filter = HW_CPU_SHOW_VENDOR; else if (0 == strcmp(tmp, "model")) filter = HW_CPU_SHOW_MODEL; else if (0 == strcmp(tmp, "curfreq")) filter = HW_CPU_SHOW_CURFREQ; else return ret; if (NULL == (f = fopen(HW_CPU_INFO_FILE, "r"))) return ret; *buffer = '\0'; while (NULL != fgets(line, sizeof(line), f)) { if (2 != sscanf(line, "%[^:]: %[^\n]", name, tmp)) continue; if (0 == strncmp(name, "processor", 9)) { if (-1 != cur_cpu && (HW_CPU_ALL_CPUS == cpu || cpu == cur_cpu)) /* print info about the previous cpu */ offset += print_freq(buffer + offset, sizeof(buffer) - offset, filter, cpu, maxfreq, curfreq); curfreq = FAIL; cur_cpu = atoi(tmp); if (HW_CPU_ALL_CPUS != cpu && cpu != cur_cpu) continue; if (HW_CPU_ALL_CPUS == cpu || HW_CPU_SHOW_ALL == filter) offset += zbx_snprintf(buffer + offset, sizeof(buffer) - offset, "\nprocessor %d:", cur_cpu); if ((HW_CPU_SHOW_ALL == filter || HW_CPU_SHOW_MAXFREQ == filter) && FAIL != (maxfreq = get_cpu_max_freq(cur_cpu))) { ret = SYSINFO_RET_OK; } } if (HW_CPU_ALL_CPUS != cpu && cpu != cur_cpu) continue; if (0 == strncmp(name, "vendor_id", 9) && (HW_CPU_SHOW_ALL == filter || HW_CPU_SHOW_VENDOR == filter)) { ret = SYSINFO_RET_OK; offset += zbx_snprintf(buffer + offset, sizeof(buffer) - offset, " %s", tmp); } else if (0 == strncmp(name, "model name", 10) && (HW_CPU_SHOW_ALL == filter || HW_CPU_SHOW_MODEL == filter)) { ret = SYSINFO_RET_OK; offset += zbx_snprintf(buffer + offset, sizeof(buffer) - offset, " %s", tmp); } else if (0 == strncmp(name, "cpu MHz", 7) && (HW_CPU_SHOW_ALL == filter || HW_CPU_SHOW_CURFREQ == filter)) { ret = SYSINFO_RET_OK; ZBX_STR2UINT64(curfreq, tmp); } } zbx_fclose(f); if (SYSINFO_RET_OK == ret) { if (-1 != cur_cpu && (HW_CPU_ALL_CPUS == cpu || cpu == cur_cpu)) /* print info about the last cpu */ offset += print_freq(buffer + offset, sizeof(buffer) - offset, filter, cpu, maxfreq, curfreq); SET_TEXT_RESULT(result, zbx_strdup(NULL, buffer + 1)); /* buf has a leading space or '\n' */ } return ret; }