@@ -24,11 +24,10 @@ typedef struct msp_cache_entry_s {
24
24
25
25
static msp_cache_entry_t * msp_message_cache [256 ]; // make a slot for all possible messages
26
26
27
- static uint8_t frame_buffer [4196 ]; // buffer a whole frame of MSP commands until we get a draw command
27
+ static uint8_t frame_buffer [8192 ]; // buffer a whole frame of MSP commands until we get a draw command
28
28
static uint32_t fb_cursor = 0 ;
29
29
30
- static uint8_t rx_message_buffer [256 ]; // only needs to be the maximum size of an MSP packet, we only care to fwd MSP
31
- static uint8_t tx_message_buffer [256 ];
30
+ static uint8_t message_buffer [256 ]; // only needs to be the maximum size of an MSP packet, we only care to fwd MSP
32
31
33
32
int pty_fd ;
34
33
int serial_fd ;
@@ -94,9 +93,10 @@ static void rx_msp_callback(msp_msg_t *msp_message)
94
93
// This was an MSP DisplayPort message, so buffer it until we get a whole frame.
95
94
if (fb_cursor > sizeof (frame_buffer )) {
96
95
printf ("Exhausted frame buffer!\n" );
96
+ return ;
97
97
}
98
- uint16_t size = msp_data_from_msg (rx_message_buffer , msp_message );
99
- memcpy (& frame_buffer [fb_cursor ], rx_message_buffer , size );
98
+ uint16_t size = msp_data_from_msg (message_buffer , msp_message );
99
+ memcpy (& frame_buffer [fb_cursor ], message_buffer , size );
100
100
fb_cursor += size ;
101
101
if (msp_message -> payload [0 ] == 4 ) {
102
102
// Once we have a whole frame of data, send it to the goggles.
@@ -105,21 +105,21 @@ static void rx_msp_callback(msp_msg_t *msp_message)
105
105
fb_cursor = 0 ;
106
106
}
107
107
} else {
108
- uint16_t size = msp_data_from_msg (rx_message_buffer , msp_message );
108
+ uint16_t size = msp_data_from_msg (message_buffer , msp_message );
109
109
// This isn't an MSP DisplayPort message, so send it to either DJI directly or to the cache.
110
110
if (serial_passthrough ) {
111
- write (pty_fd , rx_message_buffer , size );
111
+ write (pty_fd , message_buffer , size );
112
112
} else {
113
113
// Serial passthrough is off, so cache the response we got.
114
114
if (cache_msp_message (msp_message )) {
115
115
// 1 -> cache miss, so this message expired or hasn't been seen.
116
116
// this means DJI is waiting for it, so send it over
117
117
DEBUG_PRINT ("DJI was waiting, got msg %d\n" , msp_message -> cmd );
118
118
for (int i = 0 ; i < size ; i ++ ) {
119
- DEBUG_PRINT ("%02X " , rx_message_buffer [i ]);
119
+ DEBUG_PRINT ("%02X " , message_buffer [i ]);
120
120
}
121
121
DEBUG_PRINT ("\n" );
122
- write (pty_fd , rx_message_buffer , size );
122
+ write (pty_fd , message_buffer , size );
123
123
}
124
124
}
125
125
}
@@ -143,8 +143,8 @@ static void tx_msp_callback(msp_msg_t *msp_message)
143
143
} else {
144
144
// cache miss, so write the DJI request to serial and wait for the FC to come back.
145
145
DEBUG_PRINT ("DJI->FC MSP CACHE MISS msg %d\n" ,msp_message -> cmd );
146
- uint16_t size = msp_data_from_msg (tx_message_buffer , msp_message );
147
- write (serial_fd , tx_message_buffer , size );
146
+ uint16_t size = msp_data_from_msg (message_buffer , msp_message );
147
+ write (serial_fd , message_buffer , size );
148
148
}
149
149
}
150
150
@@ -169,7 +169,7 @@ int main(int argc, char *argv[]) {
169
169
}
170
170
171
171
if ((argc - optind ) < 2 ) {
172
- printf ("usage: msp_displayport_mux [-f] [-s] [-p] ipaddr serial_port [pty_target]\n-s : enable serial caching\n-f : 230400 baud serial\n" );
172
+ printf ("usage: msp_displayport_mux [-f] [-s] ipaddr serial_port [pty_target]\n-s : enable serial caching\n-f : 230400 baud serial\n" );
173
173
return 0 ;
174
174
}
175
175
0 commit comments