This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LAUNCHCC3220MODASF: UART Initialization and Handling Large Responses from GSM Modem on CC3220MODASF Launchpad

Part Number: LAUNCHCC3220MODASF

Tool/software:

Hi TI tech Team,

I am working with the CC3220MODASF launchpad and trying to communicate with a GSM modem using AT commands. My question is how to initialize the UART and handle reading when the GSM modem's response is a large string?

my UART initilization for GSM menttioned below

UART_init();

UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 115200;
uartParams.readTimeout = UART_WAIT_FOREVER; // 500
Gsm_uart= UART_open(CONFIG_UART_1, &uartParams);

if (Gsm_uart == NULL) {
// UART_open() failed
while (1);
}

UART reading handle 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void printBuffer() {
buffer[buffer_index] = '\0'; // Null-terminate the buffer
//Display_printf(display, 0, 0, "%s", buffer); // Print the buffer as a string
strcat(UART_READ, buffer);
buffer_index = 0; // Reset buffer index for next data
}
int readGSMUART(char *output, size_t max_length, int timeout_ms) {
unsigned long start_time = Timer_getMillis();
while (Timer_getMillis() - start_time < timeout_ms) {
if (UART_read(Gsm_uart, &input, 1) > 0) {
if (input >= 32 && input <= 126) {
buffer[buffer_index++] = input; // Store the character in the buffer
if (buffer_index >= MAX_BUFFER_SIZE - 1) {
printBuffer();
}
} else if (input == '\n' || input == '\r') {
printBuffer(); // Handle newline or carriage return
if (strlen(UART_READ) > 0) {
// Check if the response is complete (usually by checking for specific patterns or length)
if (strstr(UART_READ, "OK") || strstr(UART_READ, "ERROR") || strstr(UART_READ, ">") || (strlen(UART_READ) >= max_length - 1)) {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX