sparkfun / OpenLog

Open Source Hardware Datalogger
https://www.sparkfun.com/products/9530
Other
547 stars 215 forks source link

Can't get '<' character (only '12') #227

Closed n-eq closed 2 years ago

n-eq commented 5 years ago

Subject of the issue

I am trying to interface OpenLog with an EFM32 MCU without success.

Your workbench

Actual behavior

After several tests, I noticed that in the created log files (LOGXXXXX.TXT), only 12 is sent by OpenLog, which means '<' is missing. Besides STAT1 (blue) LED is off. According to the documentation, this means:

Code

Here's the code running on my MCU:


static void wait_for_break(bool less)
{
    int c;
    while (1) {
        if ((c = UART_GetChar()) >= 0) {
            if (((less) && (c == '<')) || ((!less) && (c == '>'))) {
                GPIO_PinOutSet(LED_GREEN_PORT, LED_GREEN_BIT);
                break;
            }
        }
        GPIO_PinOutToggle(LED_GREEN_PORT, LED_GREEN_BIT);
        RTC_Delay(T5MS);
    }
}

static inline void go_to_command_mode()
{
    // CTRL-Z is escape character, unless stated otherwise in config.txt file
    printf((char) 26); // ctrl-z
    printf((char) 26); // ctrl-z
    printf((char) 26); // ctrl-z
}

int main()
{
    /* ... */

    UART_Options_t options = {LEUART_DEVICE, LEUART_LOCATION, 9600, 8, 'N',
        1, false};

    // Open an I/O stream using LEUART0
    STREAM_t* stream = UART_Open(&options, STREAM_RDWR);

    GPIO_PinModeSet(LED_GREEN_PORT, LED_GREEN_BIT, gpioModePushPull, 0);
    GPIO_PinModeSet(LED_RED_PORT, LED_RED_BIT, gpioModePushPull, 1);

    wait_for_break(true); // 12<

    // never reached....
    go_to_command_mode();
    wait_for_break(false); // >
    GPIO_PinOutSet(LED_GREEN_PORT, LED_GREEN_BIT);
    GPIO_PinOutClear(LED_RED_PORT, LED_RED_BIT);
    printf("append file10.txt\r");
    wait_for_break(true); // <
    printf("Hello!\r"); // write content
    GPIO_PinOutSet(LED_RED_PORT, LED_RED_BIT);
    RTC_Delay(T10MS);
    go_to_command_mode();
    wait_for_break(false); // ~> (done)

    clig(LED_RED_PORT, LED_RED_BIT, 5);

    /* ... */
}

I very much appreciate your help.

nseidle commented 5 years ago

Hmm - I'm not familiar enough with EFM32s to help troubleshoot.

It sounds like OpenLog is working (over a direct serial connection at least). I recommend using a logic analyzer to see what is being transmitted into the EFM32. It may be that you're scanning for the '<' character incorrectly.