コード例 #1
0
ファイル: gps.c プロジェクト: iforce2d/cleanflight
void gpsEnablePassthrough(serialPort_t *gpsPassthroughPort)
{
    waitForSerialPortToFinishTransmitting(gpsState.gpsPort);
    waitForSerialPortToFinishTransmitting(gpsPassthroughPort);

    if(!(gpsState.gpsPort->mode & MODE_TX))
    serialSetMode(gpsState.gpsPort, gpsState.gpsPort->mode | MODE_TX);

    LED0_OFF;
    LED1_OFF;

    char c;
    while(1) {
        if (serialRxBytesWaiting(gpsState.gpsPort)) {
            LED0_ON;
            c = serialRead(gpsState.gpsPort);
            serialWrite(gpsPassthroughPort, c);
            LED0_OFF;
        }
        if (serialRxBytesWaiting(gpsPassthroughPort)) {
            LED1_ON;
            c = serialRead(gpsPassthroughPort);
            serialWrite(gpsState.gpsPort, c);
            LED1_OFF;
        }
    }
}
コード例 #2
0
ファイル: gps.c プロジェクト: Liquidas/betaflight
void gpsEnablePassthrough(serialPort_t *gpsPassthroughPort)
{
    waitForSerialPortToFinishTransmitting(gpsPort);
    waitForSerialPortToFinishTransmitting(gpsPassthroughPort);

    if(!(gpsPort->mode & MODE_TX))
        serialSetMode(gpsPort, gpsPort->mode | MODE_TX);

#ifdef DISPLAY
    if (feature(FEATURE_DISPLAY)) {
        displayShowFixedPage(PAGE_GPS);
    }
#endif

    serialPassthrough(gpsPort, gpsPassthroughPort, &gpsHandlePassthrough, NULL);
}
コード例 #3
0
ファイル: gps.c プロジェクト: ChrisNisbet01/cleanflight
gpsEnablePassthroughResult_e gpsEnablePassthrough(void)
{
    if (gpsData.state != GPS_RECEIVING_DATA)
        return GPS_PASSTHROUGH_NO_GPS;

    serialPort_t *gpsPassthroughPort = findOpenSerialPort(FUNCTION_GPS_PASSTHROUGH);
    if (gpsPassthroughPort) {

        waitForSerialPortToFinishTransmitting(gpsPassthroughPort);
        serialSetBaudRate(gpsPassthroughPort, serialConfig->gps_passthrough_baudrate);
    } else {
        gpsPassthroughPort = openSerialPort(FUNCTION_GPS_PASSTHROUGH, NULL, serialConfig->gps_passthrough_baudrate, MODE_RXTX, SERIAL_NOT_INVERTED);
        if (!gpsPassthroughPort) {
            return GPS_PASSTHROUGH_NO_SERIAL_PORT;
        }
    }

    LED0_OFF;
    LED1_OFF;

    while(1) {
        if (serialTotalBytesWaiting(gpsPort)) {
            LED0_ON;
            serialWrite(gpsPassthroughPort, serialRead(gpsPort));
            LED0_OFF;
        }
        if (serialTotalBytesWaiting(gpsPassthroughPort)) {
            LED1_ON;
            serialWrite(gpsPort, serialRead(gpsPassthroughPort));
            LED1_OFF;
        }
    }
    return GPS_PASSTHROUGH_ENABLED;
}
コード例 #4
0
ファイル: gps.c プロジェクト: 180jacob/cleanflight
void gpsEnablePassthrough(serialPort_t *gpsPassthroughPort)
{
    waitForSerialPortToFinishTransmitting(gpsPort);
    waitForSerialPortToFinishTransmitting(gpsPassthroughPort);

    if(!(gpsPort->mode & MODE_TX))
        serialSetMode(gpsPort, gpsPort->mode | MODE_TX);

    LED0_OFF;
    LED1_OFF;

#ifdef DISPLAY
    if (feature(FEATURE_DISPLAY)) {
        displayShowFixedPage(PAGE_GPS);
    }
#endif
    char c;
    while(1) {
        if (serialRxBytesWaiting(gpsPort)) {
            LED0_ON;
            c = serialRead(gpsPort);
            gpsNewData(c);
            serialWrite(gpsPassthroughPort, c);
            LED0_OFF;
        }
        if (serialRxBytesWaiting(gpsPassthroughPort)) {
            LED1_ON;
            c = serialRead(gpsPassthroughPort);
            serialWrite(gpsPort, c);
            LED1_OFF;
        }
#ifdef DISPLAY
        if (feature(FEATURE_DISPLAY)) {
            updateDisplay();
        }
#endif
    }
}
コード例 #5
0
ファイル: serial.c プロジェクト: mmiers/betaflight
/*
 A high-level serial passthrough implementation. Used by cli to start an
 arbitrary serial passthrough "proxy". Optional callbacks can be given to allow
 for specialized data processing.
 */
void serialPassthrough(serialPort_t *left, serialPort_t *right, serialConsumer
                       *leftC, serialConsumer *rightC)
{
    waitForSerialPortToFinishTransmitting(left);
    waitForSerialPortToFinishTransmitting(right);

    if (!leftC)
        leftC = &nopConsumer;
    if (!rightC)
        rightC = &nopConsumer;

    LED0_OFF;
    LED1_OFF;

    // Either port might be open in a mode other than MODE_RXTX. We rely on
    // serialRxBytesWaiting() to do the right thing for a TX only port. No
    // special handling is necessary OR performed.
    while(1) {
        // TODO: maintain a timestamp of last data received. Use this to
        // implement a guard interval and check for `+++` as an escape sequence
        // to return to CLI command mode.
        // https://en.wikipedia.org/wiki/Escape_sequence#Modem_control
        if (serialRxBytesWaiting(left)) {
            LED0_ON;
            uint8_t c = serialRead(left);
            serialWrite(right, c);
            leftC(c);
            LED0_OFF;
         }
         if (serialRxBytesWaiting(right)) {
             LED0_ON;
             uint8_t c = serialRead(right);
             serialWrite(left, c);
             rightC(c);
             LED0_OFF;
         }
     }
 }
コード例 #6
0
ファイル: msp_server_osd.c プロジェクト: 180jacob/cleanflight
void mspApplyVideoConfigurationFn(mspPort_t *msp)
{
    waitForSerialPortToFinishTransmitting(msp->port);
    osdApplyConfiguration();
}
コード例 #7
0
ファイル: msp_server_osd.c プロジェクト: 180jacob/cleanflight
void mspRebootFn(mspPort_t *msp)
{
    waitForSerialPortToFinishTransmitting(msp->port);  // TODO - postpone reboot, allow all modules to react
    systemReset();
}
コード例 #8
0
ファイル: serial_cli.c プロジェクト: Reini60/cleanflight
static void cliReboot(void) {
    cliPrint("\r\nRebooting...");
    waitForSerialPortToFinishTransmitting(cliPort);
    systemReset(false);
}