mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-21 14:37:35 +08:00
Merge branch 'master' into master
This commit is contained in:
@@ -17,7 +17,7 @@ for index,m in enumerate(raw_messages):
|
||||
temp_list_floats = []
|
||||
temp_list_uint64 = []
|
||||
temp_list_bool = []
|
||||
if("actuator_control" not in m and "pwm_input" not in m and "position_setpoint" not in m):
|
||||
if("pwm_input" not in m and "position_setpoint" not in m):
|
||||
temp_list = []
|
||||
f = open(m,'r')
|
||||
for line in f.readlines():
|
||||
@@ -55,9 +55,11 @@ for index,m in enumerate(raw_messages):
|
||||
|
||||
f.close()
|
||||
(m_head, m_tail) = os.path.split(m)
|
||||
messages.append(m_tail.split('.')[0])
|
||||
message = m_tail.split('.')[0]
|
||||
if message != "actuator_controls":
|
||||
messages.append(message)
|
||||
message_elements.append(temp_list)
|
||||
#messages.append(m.split('/')[-1].split('.')[0])
|
||||
message_elements.append(temp_list)
|
||||
|
||||
num_messages = len(messages);
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
* Basic shell to execute builtin "apps"
|
||||
*
|
||||
* @author Mark Charlebois <charlebm@gmail.com>
|
||||
* @auther Roman Bapst <bapstroman@gmail.com>
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
@@ -43,6 +44,7 @@
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <signal.h>
|
||||
#include <termios.h>
|
||||
|
||||
namespace px4
|
||||
{
|
||||
@@ -56,6 +58,8 @@ typedef int (*px4_main_t)(int argc, char *argv[]);
|
||||
#include "apps.h"
|
||||
#include "px4_middleware.h"
|
||||
|
||||
#define CMD_BUFF_SIZE 100
|
||||
|
||||
static bool _ExitFlag = false;
|
||||
extern "C" {
|
||||
void _SigIntHandler(int sig_num);
|
||||
@@ -203,22 +207,82 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!daemon_mode) {
|
||||
string mystr;
|
||||
string mystr = "";
|
||||
string string_buffer[CMD_BUFF_SIZE];
|
||||
int buf_ptr_write = 0;
|
||||
int buf_ptr_read = 0;
|
||||
|
||||
print_prompt();
|
||||
|
||||
// change input mode so that we can manage shell
|
||||
struct termios term;
|
||||
tcgetattr(0, &term);
|
||||
term.c_lflag &= ~ICANON;
|
||||
term.c_lflag &= ~ECHO;
|
||||
tcsetattr(0, TCSANOW, &term);
|
||||
setbuf(stdin, NULL);
|
||||
|
||||
while (!_ExitFlag) {
|
||||
|
||||
struct pollfd fds;
|
||||
int ret;
|
||||
fds.fd = 0; /* stdin */
|
||||
fds.events = POLLIN;
|
||||
ret = poll(&fds, 1, 100);
|
||||
char c = getchar();
|
||||
|
||||
if (ret > 0) {
|
||||
getline(cin, mystr);
|
||||
switch (c) {
|
||||
case 127: // backslash
|
||||
if (mystr.length() > 0) {
|
||||
mystr.pop_back();
|
||||
printf("%c[2K", 27); // clear line
|
||||
cout << (char)13;
|
||||
print_prompt();
|
||||
cout << mystr;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case'\n': // user hit enter
|
||||
if (buf_ptr_write == CMD_BUFF_SIZE) {
|
||||
buf_ptr_write = 0;
|
||||
}
|
||||
|
||||
string_buffer[buf_ptr_write] = mystr;
|
||||
buf_ptr_write++;
|
||||
process_line(mystr, !daemon_mode);
|
||||
mystr = "";
|
||||
buf_ptr_read = buf_ptr_write;
|
||||
break;
|
||||
|
||||
case '\033': { // arrow keys
|
||||
c = getchar(); // skip first one, does not have the info
|
||||
c = getchar();
|
||||
|
||||
if (c == 'A') {
|
||||
buf_ptr_read--;
|
||||
|
||||
} else if (c == 'B') {
|
||||
if (buf_ptr_read < buf_ptr_write) {
|
||||
buf_ptr_read++;
|
||||
}
|
||||
|
||||
} else {
|
||||
// TODO: Support editing current line
|
||||
}
|
||||
|
||||
if (buf_ptr_read < 0) {
|
||||
buf_ptr_read = 0;
|
||||
}
|
||||
|
||||
string saved_cmd = string_buffer[buf_ptr_read];
|
||||
printf("%c[2K", 27);
|
||||
cout << (char)13;
|
||||
mystr = saved_cmd;
|
||||
print_prompt();
|
||||
cout << mystr;
|
||||
break;
|
||||
}
|
||||
|
||||
default: // any other input
|
||||
cout << c;
|
||||
mystr += c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user