|
|
@ -52,8 +52,8 @@ double motor_drive_read_encoder() { |
|
|
|
// return -1; |
|
|
|
// } |
|
|
|
|
|
|
|
uart_flush(uart_num); |
|
|
|
// Send cmd |
|
|
|
uart_flush(uart_num); |
|
|
|
uart_write_bytes(uart_num, (const char *)buffer, encoder_buffer_size); |
|
|
|
|
|
|
|
encoder_buffer_size = 0; |
|
|
@ -87,7 +87,7 @@ void motor_drive_set_packages_ctr(double position) { |
|
|
|
uint8_t position_buffer_size = 5; //从第五位开始(低位) |
|
|
|
uint8_t checksum = 0; |
|
|
|
uint8_t buffer[10] = {0x3E, 0XA7, 0X01, 0X04, 0XEA, 0X00, 0X00, 0X00, 0X00, 0X00}; |
|
|
|
uint8_t strbuffer[20] = {0}; |
|
|
|
// uint8_t strbuffer[20] = {0}; |
|
|
|
|
|
|
|
position_int = position * 100; |
|
|
|
ESP_LOGI(MOTOR_DRIVE, "%d", position_int); |
|
|
@ -109,17 +109,23 @@ void motor_drive_set_packages_ctr(double position) { |
|
|
|
for (int i = 0; i < 10; i++) { |
|
|
|
ESP_LOGI(MOTOR_DRIVE, "%d", buffer[i]); |
|
|
|
} |
|
|
|
motor_drive_hex_to_str((char *)buffer, 10, (char *)strbuffer); |
|
|
|
ESP_LOGI(MOTOR_DRIVE, "%s", strbuffer); |
|
|
|
// ESP_LOGI(MOTOR_DRIVE, "0X%X", buffer[0]); |
|
|
|
// motor_drive_hex_to_str((const char *)buffer, 10, (char *)strbuffer); |
|
|
|
// ESP_LOGI(MOTOR_DRIVE, "%s", strbuffer); |
|
|
|
// ESP_LOGI(MOTOR_DRIVE, "0X%X", buffer[0]); |
|
|
|
|
|
|
|
// Send cmd |
|
|
|
uart_flush(uart_num); |
|
|
|
uart_write_bytes(uart_num, buffer, 10); |
|
|
|
|
|
|
|
// Wait uart receive,if time out return error and output log |
|
|
|
|
|
|
|
// Process the data |
|
|
|
} |
|
|
|
|
|
|
|
void motor_drive_hex_to_str(char *hex, int hex_len, char *str) { |
|
|
|
void motor_drive_hex_to_str(const char *hex, int hex_len, char *str) { |
|
|
|
int i, pos = 0; |
|
|
|
|
|
|
|
ESP_LOGI(MOTOR_DRIVE, "0X%X", hex[0]); |
|
|
|
for (i = 0; i < hex_len; i++) |
|
|
|
|
|
|
|
{ |
|
|
@ -127,6 +133,7 @@ void motor_drive_hex_to_str(char *hex, int hex_len, char *str) { |
|
|
|
|
|
|
|
pos += 2; |
|
|
|
} |
|
|
|
ESP_LOGI(MOTOR_DRIVE, "0X%X", hex[0]); |
|
|
|
} |
|
|
|
|
|
|
|
size_t motor_drive_buffer_cmd_generate(uint8_t *buffer, uint8_t cmd, uint8_t buffer_data_size, uint64_t buffer_data) { |
|
|
@ -184,3 +191,10 @@ void motor_drive_buffer_cmd_parse(uint8_t *buffer) { |
|
|
|
} |
|
|
|
|
|
|
|
void motor_drive_set_motor_size() {} |
|
|
|
|
|
|
|
double motor_drive_read_single_turn_angle() { |
|
|
|
double turn_angle = 0.0; |
|
|
|
uint8_t buffer[5] = {0X3E, 0X94, 0X01, 0X00, 0XD3}; |
|
|
|
|
|
|
|
return turn_angle; |
|
|
|
} |