int motor_test_main(int argc, char *argv[]) { unsigned long channel = 0; unsigned long lval; float value = 0.0f; int ch; if (argc != 5) { usage("please specify motor and power"); } while ((ch = getopt(argc, argv, "m:p:")) != EOF) { switch (ch) { case 'm': /* Read in motor number */ channel = strtoul(optarg, NULL, 0); break; case 'p': /* Read in power value */ lval = strtoul(optarg, NULL, 0); if (lval > 100) usage("value invalid"); value = ((float)lval)/100.f; break; default: usage(NULL); } } motor_test(channel, value); printf("motor %d set to %.2f\n", channel, (double)value); exit(0); }
/** * Function to process debugging module * Checks for debbunging commands and things like this */ void debug_process(void){ #ifdef CFG_SUART_RX // check for recieved commands if( suart_rxFlag ){ uint8_t cmd = suart_getc(); #if !defined(CFG_CODE_LEVEL_AVG) uint16_t tmp; #endif // process command switch(cmd){ case 'f': motor_set_speed(MOTOR_ADDR_L, 0x50, MOTOR_FORWARD); motor_set_speed(MOTOR_ADDR_R, 0x40, MOTOR_FORWARD); break; case'b': motor_set_speed(MOTOR_ADDR_L, 0x40, MOTOR_BACKWARD); motor_set_speed(MOTOR_ADDR_R, 0x43, MOTOR_BACKWARD); break; case 'z': motor_set_speed(MOTOR_ADDR_L, 0x00, MOTOR_BRAKE); motor_set_speed(MOTOR_ADDR_R, 0x00, MOTOR_BRAKE); break; #if !defined(CFG_CODE_LEVEL_AVG) case 'g': led_set_allcolors(); led_all_on(); break; case 'h': led_set_nocolors(); led_all_off(); break; #endif case 's': led_on(LED_STATUS); break; case 'r': led_off(LED_STATUS); break; case 'c': motor_set_speed(MOTOR_ADDR_L, MOTOR_SPEED_HALF, MOTOR_FORWARD); motor_set_speed(MOTOR_ADDR_R, MOTOR_SPEED_HALF, MOTOR_BACKWARD); break; case 'a': motor_set_speed(MOTOR_ADDR_L, MOTOR_SPEED_HALF, MOTOR_BACKWARD); motor_set_speed(MOTOR_ADDR_R, MOTOR_SPEED_HALF, MOTOR_FORWARD); break; #if !defined(CFG_CODE_LEVEL_AVG) case 'm': debug_send_c( motor_get_speed(MOTOR_ADDR_L), TRUE ); break; case 'n': debug_send_c( motor_get_speed(MOTOR_ADDR_R), TRUE ); break; case 'o': debug_send_c( motor_get_direction(MOTOR_ADDR_L), TRUE ); break; case 'p': debug_send_c( motor_get_direction(MOTOR_ADDR_R), TRUE ); break; case 'd': debug_send_c( motor_get_fault(MOTOR_ADDR_L), TRUE ); break; case 'e': debug_send_c( motor_get_fault(MOTOR_ADDR_R), TRUE ); break; case 'u': motor_clear_fault( MOTOR_ADDR_L ); break; case 'v': motor_clear_fault( MOTOR_ADDR_R ); break; #endif case 'i': debug_send_c( sys_robotID, TRUE ); break; case 'j': debug_send_msg( SYS_PUBLISHER, TRUE ); break; case 'k': debug_send_msg( SYS_VERSION, TRUE ); break; case 'l': debug_send_msg( SYS_NAME, TRUE ); break; case 'M': debug_send_c( motor_test(), TRUE ); break; #if !defined(CFG_CODE_LEVEL_AVG) case 'T': tmp = monitor_read_temp(MONITOR_ADDR_1); debug_send_c_wait( tmp>>8, FALSE ); debug_send_c_wait( tmp, FALSE ); tmp = monitor_read_temp(MONITOR_ADDR_2); debug_send_c_wait( tmp>>8, FALSE ); debug_send_c_wait( tmp, TRUE ); break; case 'U': tmp = monitor_read_voltage(MONITOR_ADDR_2, MONITOR_U1); debug_send_c_wait( tmp>>8, FALSE ); debug_send_c_wait( tmp, TRUE ); break; case 'V': tmp = monitor_read_voltage(MONITOR_ADDR_2, MONITOR_U4); debug_send_c_wait( tmp>>8, FALSE ); debug_send_c_wait( tmp, TRUE ); break; case 'W': tmp = monitor_read_voltage(MONITOR_ADDR_2, MONITOR_U2); debug_send_c_wait( tmp>>8, FALSE ); debug_send_c_wait( tmp, TRUE ); break; case 'X': tmp = monitor_read_voltage(MONITOR_ADDR_2, MONITOR_U3); debug_send_c_wait( tmp>>8, FALSE ); debug_send_c_wait( tmp, TRUE ); break; case 'I': tmp = monitor_read_current(MONITOR_ADDR_1, MONITOR_I1); debug_send_c_wait( tmp>>8, FALSE ); debug_send_c_wait( tmp, TRUE ); break; case 'J': tmp = monitor_read_current(MONITOR_ADDR_1, MONITOR_I2); debug_send_c_wait( tmp>>8, FALSE ); debug_send_c_wait( tmp, TRUE ); break; case 'A': tmp = monitor_read_voltage(MONITOR_ADDR_1, MONITOR_UVCC); debug_send_c_wait( tmp>>8, FALSE ); debug_send_c_wait( tmp, FALSE ); tmp = monitor_read_voltage(MONITOR_ADDR_2, MONITOR_UVCC); debug_send_c_wait( tmp>>8, FALSE ); debug_send_c_wait( tmp, TRUE ); break; case 'R': animation_set_mode(ANIMATION_MODE_RED_PULSED); break; case 'S': animation_set_mode(ANIMATION_MODE_STROBE); break; case 'F': animation_set_mode(ANIMATION_MODE_FADE); break; case 'L': animation_set_mode(ANIMATION_MODE_LADY); break; case 'N': animation_set_mode(ANIMATION_MODE_NONE); break; #endif case '?': debug_send_help(); break; default: debug_send_c( 0xff, TRUE ); break; } } #endif /* CFG_SUART_RX */ }