|
16 | 16 | #include "util/debug.h"
|
17 | 17 | #include "util/time_util.h"
|
18 | 18 | #include "util/fs_util.h"
|
| 19 | +#include "./msp/msp_vtx.c" |
19 | 20 |
|
20 | 21 | #define CPU_TEMP_PATH "/sys/devices/platform/soc/f0a00000.apb/f0a71000.omc/temp1"
|
21 | 22 | #define AU_VOLTAGE_PATH "/sys/devices/platform/soc/f0a00000.apb/f0a71000.omc/voltage4"
|
@@ -153,9 +154,21 @@ static void send_vtx_config_request(int serial_fd) {
|
153 | 154 |
|
154 | 155 | static void send_vtx_set_config_request(int serial_fd) {
|
155 | 156 | DEBUG_PRINT("Sending VTX READY message...\n");
|
156 |
| - uint8_t buffer[6]; |
157 |
| - construct_msp_command(buffer, MSP_CMD_SET_VTX_CONFIG, NULL, 0, MSP_OUTBOUND); |
158 |
| - write(serial_fd, &buffer, sizeof(buffer)); |
| 157 | + |
| 158 | + uint8_t *buffer = resetVTXTableMessage(); |
| 159 | + write(serial_fd, buffer, sizeof(buffer)); |
| 160 | + |
| 161 | + buffer = setupVTXPowerMessage(0, 25, "25 "); |
| 162 | + write(serial_fd, buffer, sizeof(buffer)); |
| 163 | + buffer = setupVTXPowerMessage(0, 200, "200 "); |
| 164 | + write(serial_fd, buffer, sizeof(buffer)); |
| 165 | + buffer = setupVTXPowerMessage(0, 500, "500 "); |
| 166 | + write(serial_fd, buffer, sizeof(buffer)); |
| 167 | + buffer = setupVTXPowerMessage(0, 700, "700 "); |
| 168 | + write(serial_fd, buffer, sizeof(buffer)); |
| 169 | + |
| 170 | + buffer = setupVTXBandMessage(); |
| 171 | + write(serial_fd, buffer, sizeof(buffer)); |
159 | 172 | }
|
160 | 173 |
|
161 | 174 | static void copy_to_msp_frame_buffer(void *buffer, uint16_t size) {
|
@@ -236,7 +249,7 @@ static void rx_msp_callback(msp_msg_t *msp_message)
|
236 | 249 | default: {
|
237 | 250 | uint16_t size = msp_data_from_msg(message_buffer, msp_message);
|
238 | 251 | if(serial_passthrough || cache_msp_message(msp_message)) {
|
239 |
| - // Either serial passthrough was on, or the cache was enabled but missed (a response was not available). |
| 252 | + // Either serial passthrough was on, or the cache was enabled but missed (a response was not available). |
240 | 253 | // Either way, this means we need to send the message through to DJI.
|
241 | 254 | write(pty_fd, message_buffer, size);
|
242 | 255 | }
|
@@ -390,8 +403,8 @@ int main(int argc, char *argv[]) {
|
390 | 403 | printf("Allocated PTY %s\n", pty_name_ptr);
|
391 | 404 | if ((argc - optind) > 2) {
|
392 | 405 | unlink(argv[optind + 2]);
|
393 |
| - symlink(pty_name_ptr, argv[optind + 2]); |
394 |
| - printf("Relinked %s to %s\n", argv[optind + 2], pty_name_ptr); |
| 406 | + symlink(pty_name_ptr, argv[optind + 2]); |
| 407 | + printf("Relinked %s to %s\n", argv[optind + 2], pty_name_ptr); |
395 | 408 | }
|
396 | 409 | socket_fd = connect_to_server(ip_address, MSP_PORT);
|
397 | 410 | compressed_fd = connect_to_server(ip_address, COMPRESSED_DATA_PORT);
|
@@ -425,7 +438,7 @@ int main(int argc, char *argv[]) {
|
425 | 438 | poll_fds[1].events = POLLIN;
|
426 | 439 |
|
427 | 440 | poll(poll_fds, 2, ((MSEC_PER_SEC / update_rate_hz) / 2));
|
428 |
| - |
| 441 | + |
429 | 442 | // We got inbound serial data, process it as MSP data.
|
430 | 443 | if (0 < (serial_data_size = read(serial_fd, serial_data, sizeof(serial_data)))) {
|
431 | 444 | DEBUG_PRINT("RECEIVED data! length %d\n", serial_data_size);
|
|
0 commit comments