marcinbor85 / cAT

Plain C library for parsing AT commands for use in host devices.
MIT License
402 stars 77 forks source link

cAT returning ERROR when running embedded. #53

Open andrewstillie opened 8 months ago

andrewstillie commented 8 months ago

I have been testing cAT locally using a Linux machine and compiling with GCC and all is working fine.
This is how I have the comms interface set. static int write_char(char ch) { putc(ch, stdout); return 1; }

static int read_char(char ch) { ch = getc(stdin); return 1; }

I now want to run the code embedded in a SiLabs Microcontroller via a UART and TeraTerm. Serial output from the application is working fine. But when I send AT#HELP (or any other command) I get the "ERROR" response.

The main loop is calling handleATProcessing() every iteration.

struct cat_object at; is declared as a global.

int handleATProcessing(void) {

    while ((cat_service(&at) != 0) && (quit_flag == 0))
    {
        sl_sleeptimer_delay_millisecond(1);
    };

    printf("Bye!\n");

    return 0;

}

My gut feeling is that a command is not being built as characters are received, so command buffer is empty when CR is received. Can you see where I am going wrong or advise how to debug this?

andrewstillie commented 8 months ago

I had to add code to my .read as getc was returning 255 when no characters where detected.

andrewstillie commented 8 months ago

My issue - not cAT