void com_cmd_analogRead(int argc, char **argv) { uint16 val; char num[32]; // arm_uint2hexstr(num, argc); // arm_puts("com_cmd_analogRead : "); // arm_puts(num); // arm_puts("\n"); if (argc != 4) { arm_puts ("analogRead: need 2 parameters\n"); } else { if (arm_strcmp(argv[2], "A0") == 0) { // Valeur dans argv[2] arm_puts("A0 "); // val = arm_str2int(argv[3]); // arm_uint2hexstr(num, val); // arm_puts(num); // arm_puts("\n"); lights[0] = (int)*argv[3]; arm_uint2hexstr(num, lights[0]); arm_puts(num); arm_puts("\n"); } else if (arm_strcmp(argv[2], "A1") == 0) { // Valeur dans argv[2] arm_puts("A1 "); // val = arm_str2int(argv[3]); // arm_uint2hexstr(num, val); // arm_puts(num); // arm_puts("\n"); lights[1] = (int)*argv[3]; arm_uint2hexstr(num, lights[1]); arm_puts(num); arm_puts("\n"); } else { arm_puts ("analogRead: parameter 1 unknown\n"); } } }
void arm_cmd_linux_memory_size(int argc, char **argv) { char str[32]; if (argc == 2) { memory_size = (u32)arm_hexstr2uint(argv[1]); } arm_puts ("linux_memory_size = 0x"); arm_uint2hexstr(str, memory_size); arm_puts(str); arm_puts (" Bytes\n"); return; }
void arm_cmd_hexdump(int argc, char **argv) { char str[32]; u32 *addr; u32 i, count, len; if (argc != 3) { arm_puts ("hexdump: must provide <addr> and <count>\n"); return; } addr = (u32 *)arm_hexstr2ulonglong(argv[1]); count = arm_hexstr2uint(argv[2]); for (i = 0; i < (count / 4); i++) { if (i % 4 == 0) { arm_ulonglong2hexstr(str, (u64)&addr[i]); len = arm_strlen(str); while (len < 8) { arm_puts("0"); len++; } arm_puts(str); arm_puts(": "); } arm_uint2hexstr(str, addr[i]); len = arm_strlen(str); while (len < 8) { arm_puts("0"); len++; } arm_puts(str); if (i % 4 == 3) { arm_puts("\n"); } else { arm_puts(" "); } } arm_puts("\n"); }
void com_exec(T_txBuffer *buffer) { int argc = 0, pos = 0, cnt = 0; char *argv[ARM_MAX_ARG_SIZE]; char *data; char num[32]; while (pos < buffer->index && (argc < ARM_MAX_ARG_SIZE)) { // arm_puts("car : "); num[0] = buffer->data[pos]; // arm_board_serial_putc(num[0]); // arm_puts("\n"); if ((buffer->data[pos] == '\r') || (buffer->data[pos] == '\n')) { buffer->data[pos] = '\0'; break; } if (buffer->data[pos] == ' ') { if (cnt > 0) { buffer->data[pos] = '\0'; cnt = 0; } } else { if (cnt == 0) { argv[argc] = &buffer->data[pos]; argc++; } cnt++; } pos++; } // arm_puts("argv : \n"); // for (int i=0; i<argc; i++) { // arm_uint2hexstr(num, i); // arm_puts(num); // arm_puts(" : "); // arm_puts(argv[i]); // arm_puts("\n"); // } if (argc > 0) { // arm_puts("buffer : "); // arm_puts(buffer->data); // arm_puts("\n"); if (arm_strcmp(argv[1], "analogRead") == 0) { com_cmd_analogRead(argc, argv); } else { arm_puts("Unknown command : "); arm_uint2hexstr(num, argc); arm_puts(num); arm_puts(" : "); arm_puts(argv[0]); arm_puts(" : "); arm_puts(argv[1]); arm_puts(" : "); arm_puts(argv[2]); arm_puts("\n"); } for (pos = 0; pos < buffer->index; pos++) { buffer->data[pos] = '\0'; } buffer->index = 0; } }