mirror of https://github.com/rusefi/rusefi-1.git
auto-sync
This commit is contained in:
parent
6210c7b9bb
commit
294f949bd3
|
@ -440,6 +440,7 @@ void runBinaryProtocolLoop(ts_channel_s *tsChannel, bool isConsoleRedirect) {
|
||||||
// tunerStudioError("ERROR: no command");
|
// tunerStudioError("ERROR: no command");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
onDataArrived();
|
||||||
// scheduleMsg(logger, "Got first=%x=[%c]", firstByte, firstByte);
|
// scheduleMsg(logger, "Got first=%x=[%c]", firstByte, firstByte);
|
||||||
if (handlePlainCommand(tsChannel, firstByte))
|
if (handlePlainCommand(tsChannel, firstByte))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -40,6 +40,13 @@ static bool isSerialConsoleStarted = false;
|
||||||
|
|
||||||
static event_listener_t consoleEventListener;
|
static event_listener_t consoleEventListener;
|
||||||
|
|
||||||
|
bool consoleByteArrived = false;
|
||||||
|
|
||||||
|
void onDataArrived(void) {
|
||||||
|
consoleByteArrived = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reads a whole line from the input channel.
|
* @brief Reads a whole line from the input channel.
|
||||||
*
|
*
|
||||||
|
@ -61,6 +68,7 @@ static bool getConsoleLine(BaseSequentialStream *chp, char *line, unsigned size)
|
||||||
}
|
}
|
||||||
|
|
||||||
short c = (short) chSequentialStreamGet(chp);
|
short c = (short) chSequentialStreamGet(chp);
|
||||||
|
onDataArrived();
|
||||||
|
|
||||||
if (isSerialOverUart()) {
|
if (isSerialOverUart()) {
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
|
|
|
@ -26,6 +26,7 @@ void consolePutChar(int x);
|
||||||
void consoleOutputBuffer(const uint8_t *buf, int size);
|
void consoleOutputBuffer(const uint8_t *buf, int size);
|
||||||
void startConsole(Logging *sharedLogger, CommandHandler console_line_callback_p);
|
void startConsole(Logging *sharedLogger, CommandHandler console_line_callback_p);
|
||||||
bool isSerialOverUart(void);
|
bool isSerialOverUart(void);
|
||||||
|
void onDataArrived(void);
|
||||||
|
|
||||||
#if EFI_PROD_CODE || EFI_SIMULATOR || EFI_EGT
|
#if EFI_PROD_CODE || EFI_SIMULATOR || EFI_EGT
|
||||||
bool isConsoleReady(void);
|
bool isConsoleReady(void);
|
||||||
|
|
|
@ -500,6 +500,8 @@ static bool isTriggerErrorNow() {
|
||||||
return justHadError || isTriggerDecoderError();
|
return justHadError || isTriggerDecoderError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern bool consoleByteArrived;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this thread has a lower-then-usual stack size so we cannot afford *print* methods here
|
* this thread has a lower-then-usual stack size so we cannot afford *print* methods here
|
||||||
*/
|
*/
|
||||||
|
@ -524,8 +526,10 @@ static void blinkingThread(void *arg) {
|
||||||
|
|
||||||
communicationPin.setValue(1);
|
communicationPin.setValue(1);
|
||||||
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
|
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
|
||||||
if (isTriggerErrorNow() || isIgnitionTimingError())
|
if (isTriggerErrorNow() || isIgnitionTimingError() || consoleByteArrived) {
|
||||||
|
consoleByteArrived = false;
|
||||||
warningPin.setValue(1);
|
warningPin.setValue(1);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
chThdSleepMilliseconds(delayMs);
|
chThdSleepMilliseconds(delayMs);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import java.util.Arrays;
|
||||||
*/
|
*/
|
||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
public class IncomingDataBuffer {
|
public class IncomingDataBuffer {
|
||||||
private static final int BUFFER_SIZE = 10000;
|
private static final int BUFFER_SIZE = 32768;
|
||||||
/**
|
/**
|
||||||
* buffer for response bytes from controller
|
* buffer for response bytes from controller
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -54,9 +54,8 @@ public class PortHolder {
|
||||||
FileLog.MAIN.logLine("Opening " + port + " @ " + BAUD_RATE);
|
FileLog.MAIN.logLine("Opening " + port + " @ " + BAUD_RATE);
|
||||||
boolean opened = serialPort.openPort();//Open serial port
|
boolean opened = serialPort.openPort();//Open serial port
|
||||||
if (!opened)
|
if (!opened)
|
||||||
FileLog.MAIN.logLine("not opened!");
|
FileLog.MAIN.logLine(port + ": not opened!");
|
||||||
setupPort(serialPort, BAUD_RATE);
|
setupPort(serialPort, BAUD_RATE);
|
||||||
// serialPort.setDataListener(new SerialPortReader(serialPort, communicationLoggingListener));
|
|
||||||
} catch (SerialPortException e) {
|
} catch (SerialPortException e) {
|
||||||
FileLog.MAIN.logLine("ERROR " + e.getMessage());
|
FileLog.MAIN.logLine("ERROR " + e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -57,7 +57,9 @@ public class SerialIoStream implements IoStream {
|
||||||
@Override
|
@Override
|
||||||
public void setDataListener(DataListener listener) {
|
public void setDataListener(DataListener listener) {
|
||||||
try {
|
try {
|
||||||
serialPort.addEventListener(new SerialPortReader(serialPort, listener));
|
SerialPortReader reader = new SerialPortReader(serialPort, listener);
|
||||||
|
serialPort.addEventListener(reader);
|
||||||
|
reader.readInitial();
|
||||||
} catch (SerialPortException e) {
|
} catch (SerialPortException e) {
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,5 +43,10 @@ public class SerialPortReader implements SerialPortEventListener {
|
||||||
public void readInitial() throws SerialPortException {
|
public void readInitial() throws SerialPortException {
|
||||||
int input = serialPort.getInputBufferBytesCount();
|
int input = serialPort.getInputBufferBytesCount();
|
||||||
FileLog.MAIN.logLine(input + " bytes in input buffer");
|
FileLog.MAIN.logLine(input + " bytes in input buffer");
|
||||||
|
while (serialPort.getInputBufferBytesCount() > 0) {
|
||||||
|
byte[] data = serialPort.readBytes();
|
||||||
|
if (data != null)
|
||||||
|
listener.onDataArrived(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue