1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-21 15:25:17 +03:00

Comments from projectkk2glider addressed

This commit is contained in:
Bertrand Songis 2015-08-11 18:15:43 +02:00
parent 9b527b1810
commit 6356fbb2f4
5 changed files with 12 additions and 10 deletions

View file

@ -37,8 +37,9 @@
#include "opentx.h" #include "opentx.h"
#include <ctype.h> #include <ctype.h>
#define CLI_STACK_SIZE 500 #define CLI_STACK_SIZE 500
#define CLI_MAX_ARGS 8 #define CLI_COMMAND_MAX_ARGS 8
#define CLI_COMMAND_MAX_LEN 256
extern Fifo<512> uart3TxFifo; extern Fifo<512> uart3TxFifo;
OS_TID cliTaskId; OS_TID cliTaskId;
@ -253,14 +254,14 @@ int cliExecCommand(const char ** argv)
int cliExecLine(char * line) int cliExecLine(char * line)
{ {
int len = strlen(line); int len = strlen(line);
const char * argv[CLI_MAX_ARGS]; const char * argv[CLI_COMMAND_MAX_ARGS];
memset(argv, 0, sizeof(argv)); memset(argv, 0, sizeof(argv));
int argc = 1; int argc = 1;
argv[0] = line; argv[0] = line;
for (int i=0; i<len; i++) { for (int i=0; i<len; i++) {
if (line[i] == ' ') { if (line[i] == ' ') {
line[i] = '\0'; line[i] = '\0';
if (argc < CLI_MAX_ARGS) { if (argc < CLI_COMMAND_MAX_ARGS) {
argv[argc++] = &line[i+1]; argv[argc++] = &line[i+1];
} }
} }
@ -270,7 +271,7 @@ int cliExecLine(char * line)
void cliTask(void * pdata) void cliTask(void * pdata)
{ {
char line[256]; char line[CLI_COMMAND_MAX_LEN+1];
uint8_t pos = 0; uint8_t pos = 0;
cliPrompt(); cliPrompt();
@ -302,7 +303,7 @@ void cliTask(void * pdata)
pos = 0; pos = 0;
cliPrompt(); cliPrompt();
} }
else if (isascii(c)) { else if (isascii(c) && pos < CLI_COMMAND_MAX_LEN) {
line[pos++] = c; line[pos++] = c;
serialPutc(c); serialPutc(c);
} }

View file

@ -51,8 +51,8 @@ void handleCli()
while(cliRxFifo.pop(c)) { while(cliRxFifo.pop(c)) {
//send back //send back
sendUsbSerialChar(c); usbSerialPutc(c);
sendUsbSerialChar('+'); usbSerialPutc('+');
} }
} }

View file

@ -44,7 +44,7 @@
void serialPutc(char c) void serialPutc(char c)
{ {
#if defined(USB_SERIAL) #if defined(USB_SERIAL)
sendUsbSerialChar(c); usbSerialPutc(c);
#else #else
serial2Putc(c); serial2Putc(c);
#endif #endif

View file

@ -283,6 +283,7 @@ void backlightInit(void);
int usbPlugged(void); int usbPlugged(void);
void usbInit(void); void usbInit(void);
void usbDeInit(void); void usbDeInit(void);
void usbSerialPutc(uint8_t c);
#if defined(__cplusplus) && !defined(SIMU) #if defined(__cplusplus) && !defined(SIMU)
} }

View file

@ -157,7 +157,7 @@ static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len)
uint16_t usbWraps = 0; uint16_t usbWraps = 0;
uint16_t charsWritten = 0; uint16_t charsWritten = 0;
void sendUsbSerialChar(uint8_t c) void usbSerialPutc(uint8_t c)
{ {
if (!cdcConnected) return; if (!cdcConnected) return;