auto-sync

This commit is contained in:
rusEfi 2017-01-05 04:03:02 -05:00
parent 36b57ce9b9
commit 278263528c
6 changed files with 20 additions and 18 deletions

View File

@ -25,7 +25,7 @@
#if EFI_SIMULATOR || defined(__DOXYGEN__) #if EFI_SIMULATOR || defined(__DOXYGEN__)
#include "rusEfiFunctionalTest.h" #include "rusEfiFunctionalTest.h"
#endif #endif /*EFI_SIMULATOR */
EXTERN_ENGINE; EXTERN_ENGINE;
@ -33,7 +33,7 @@ EXTERN_ENGINE;
#include "usbcfg.h" #include "usbcfg.h"
#include "usbconsole.h" #include "usbconsole.h"
extern SerialUSBDriver SDU1; extern SerialUSBDriver SDU1;
#endif #endif /* HAL_USE_SERIAL_USB */
int lastWriteSize; int lastWriteSize;
int lastWriteActual; int lastWriteActual;
@ -63,7 +63,7 @@ static bool getConsoleLine(BaseSequentialStream *chp, char *line, unsigned size)
char *p = line; char *p = line;
while (true) { while (true) {
if (!isConsoleReady()) { if (!isCommandLineConsoleReady()) {
// we better do not read from USB serial before it is ready // we better do not read from USB serial before it is ready
chThdSleepMilliseconds(10); chThdSleepMilliseconds(10);
continue; continue;
@ -131,18 +131,16 @@ static bool getConsoleLine(BaseSequentialStream *chp, char *line, unsigned size)
CommandHandler console_line_callback; CommandHandler console_line_callback;
static bool is_serial_over_uart; static bool isCommandLineConsoleOverTTL;
bool isSerialOverUart(void) { bool isSerialOverUart(void) {
return is_serial_over_uart; return isCommandLineConsoleOverTTL;
} }
#if (defined(EFI_CONSOLE_UART_DEVICE) && ! EFI_SIMULATOR ) || defined(__DOXYGEN__) #if (defined(EFI_CONSOLE_UART_DEVICE) && ! EFI_SIMULATOR ) || defined(__DOXYGEN__)
static SerialConfig serialConfig = { SERIAL_SPEED, 0, USART_CR2_STOP1_BITS | USART_CR2_LINEN, 0 }; static SerialConfig serialConfig = { SERIAL_SPEED, 0, USART_CR2_STOP1_BITS | USART_CR2_LINEN, 0 };
#endif #endif
#if EFI_PROD_CODE || EFI_EGT || defined(__DOXYGEN__)
bool consoleInBinaryMode = false; bool consoleInBinaryMode = false;
void runConsoleLoop(ts_channel_s *console) { void runConsoleLoop(ts_channel_s *console) {
@ -174,6 +172,10 @@ void runConsoleLoop(ts_channel_s *console) {
} }
} }
#if EFI_PROD_CODE || EFI_EGT || defined(__DOXYGEN__)
SerialDriver * getConsoleChannel(void) { SerialDriver * getConsoleChannel(void) {
#if defined(EFI_CONSOLE_UART_DEVICE) || defined(__DOXYGEN__) #if defined(EFI_CONSOLE_UART_DEVICE) || defined(__DOXYGEN__)
if (isSerialOverUart()) { if (isSerialOverUart()) {
@ -185,10 +187,10 @@ SerialDriver * getConsoleChannel(void) {
return (SerialDriver *) &SDU1; return (SerialDriver *) &SDU1;
#else #else
return NULL; return NULL;
#endif #endif /* HAL_USE_SERIAL_USB */
} }
bool isConsoleReady(void) { bool isCommandLineConsoleReady(void) {
if (isSerialOverUart()) { if (isSerialOverUart()) {
return isSerialConsoleStarted; return isSerialConsoleStarted;
} else { } else {
@ -250,7 +252,7 @@ void startConsole(Logging *sharedLogger, CommandHandler console_line_callback_p)
palSetPadMode(CONSOLE_MODE_SWITCH_PORT, CONSOLE_MODE_SWITCH_PIN, PAL_MODE_INPUT_PULLUP); palSetPadMode(CONSOLE_MODE_SWITCH_PORT, CONSOLE_MODE_SWITCH_PIN, PAL_MODE_INPUT_PULLUP);
is_serial_over_uart = GET_CONSOLE_MODE_VALUE() == EFI_USE_UART_FOR_CONSOLE; isCommandLineConsoleOverTTL = GET_CONSOLE_MODE_VALUE() == EFI_USE_UART_FOR_CONSOLE;
if (isSerialOverUart()) { if (isSerialOverUart()) {
/* /*
@ -268,7 +270,7 @@ void startConsole(Logging *sharedLogger, CommandHandler console_line_callback_p)
chEvtRegisterMask((event_source_t *) chnGetEventSource(EFI_CONSOLE_UART_DEVICE), &consoleEventListener, 1); chEvtRegisterMask((event_source_t *) chnGetEventSource(EFI_CONSOLE_UART_DEVICE), &consoleEventListener, 1);
} }
#else #else
is_serial_over_uart = false; isCommandLineConsoleOverTTL = false;
#endif /* EFI_PROD_CODE */ #endif /* EFI_PROD_CODE */
chThdCreateStatic(consoleThreadStack, sizeof(consoleThreadStack), NORMALPRIO, (tfunc_t)consoleThreadThreadEntryPoint, NULL); chThdCreateStatic(consoleThreadStack, sizeof(consoleThreadStack), NORMALPRIO, (tfunc_t)consoleThreadThreadEntryPoint, NULL);

View File

@ -29,9 +29,9 @@ bool isSerialOverUart(void);
void onDataArrived(void); void onDataArrived(void);
#if EFI_PROD_CODE || EFI_SIMULATOR || EFI_EGT #if EFI_PROD_CODE || EFI_SIMULATOR || EFI_EGT
bool isConsoleReady(void); bool isCommandLineConsoleReady(void);
#else #else
#define isConsoleReady() true #define isCommandLineConsoleReady() true
#endif #endif
#endif /* CONSOLE_IO_H_ */ #endif /* CONSOLE_IO_H_ */

View File

@ -142,7 +142,7 @@ static void cmd_threads(void) {
*/ */
void print(const char *format, ...) { void print(const char *format, ...) {
#if !EFI_UART_ECHO_TEST_MODE #if !EFI_UART_ECHO_TEST_MODE
if (!isConsoleReady()) { if (!isCommandLineConsoleReady()) {
return; return;
} }
va_list ap; va_list ap;

View File

@ -412,7 +412,7 @@ extern fatal_msg_t errorMessageBuffer;
* @brief Sends all pending data to dev console * @brief Sends all pending data to dev console
*/ */
void updateDevConsoleState(Engine *engine) { void updateDevConsoleState(Engine *engine) {
if (!isConsoleReady()) { if (!isCommandLineConsoleReady()) {
return; return;
} }
// looks like this is not needed anymore // looks like this is not needed anymore
@ -596,7 +596,7 @@ static void blinkingThread(void *arg) {
initialLedsBlink(); initialLedsBlink();
while (true) { while (true) {
int delayMs = isConsoleReady() ? 3 * blinkingPeriod : blinkingPeriod; int delayMs = is_usb_serial_ready() ? 3 * blinkingPeriod : blinkingPeriod;
#if EFI_INTERNAL_FLASH || defined(__DOXYGEN__) #if EFI_INTERNAL_FLASH || defined(__DOXYGEN__)
if (getNeedToWriteConfiguration()) { if (getNeedToWriteConfiguration()) {

View File

@ -218,7 +218,7 @@ void printWithLength(char *line) {
*p++ = '\r'; *p++ = '\r';
*p++ = '\n'; *p++ = '\n';
if (!isConsoleReady()) if (!isCommandLineConsoleReady())
return; return;
consoleOutputBuffer((const uint8_t *) header, strlen(header)); consoleOutputBuffer((const uint8_t *) header, strlen(header));
consoleOutputBuffer((const uint8_t *) line, p - line); consoleOutputBuffer((const uint8_t *) line, p - line);

View File

@ -109,7 +109,7 @@ int isSerialOverTcpReady;
int maxNesting = 0; int maxNesting = 0;
bool isConsoleReady(void) { bool isCommandLineConsoleReady(void) {
return isSerialOverTcpReady; return isSerialOverTcpReady;
} }