saramah
Member level 3
hI,
When I was terying to understand the tutorials from
, the below 2d array is found.
.
what i understand, it is a 2-D array, and 'so_far[]' array itself is one of the another index of 'string' array. But my qestion is how this operate in the code below as mentioned in the aricle:
how //if (strings[so_far] == received) this line being implemented. if i had been recived "O" for "OK" at 'received' variable from calling fun //_SIM900_getch();
I REQUEST TO MAKE ME UNDERSTAND IF POSSIBLE..
TNX
When I was terying to understand the tutorials from
HTML:
https://circuitdigest.com/microcontroller-projects/gsm-interfacing-with-pic16f877a
Code:
if (strings[i][so_far[i]] == received)
what i understand, it is a 2-D array, and 'so_far[]' array itself is one of the another index of 'string' array. But my qestion is how this operate in the code below as mentioned in the aricle:
Code:
/*
#define SIM900_OK 1
#define SIM900_READY 2
#define SIM900_FAIL 3
#define SIM900_RING 4
#define SIM900_NC 5
#define SIM900_UNLINK 6
*/
inline unsigned char _SIM900_waitResponse(void)
{
unsigned char so_far[6] = {0,0,0,0,0,0};
unsigned const char lengths[6] = {2,12,5,4,6,6};
unsigned const char* strings[6] = {"OK", "+CPIN: READY", "ERROR", "RING", "NO CARRIER", "Unlink"};
unsigned const char responses[6] = {SIM900_OK, SIM900_READY, SIM900_FAIL, SIM900_RING, SIM900_NC, SIM900_UNLINK};
unsigned char received;
unsigned char response;
char continue_loop = 1;
while (continue_loop)
{
received = _SIM900_getch();
for (unsigned char i = 0; i < 6; i++)
{
if (strings[i][so_far[i]] == received)
{
so_far[i]++;
if (so_far[i] == lengths[i])
{
response = responses[i];
continue_loop = 0;
}
}
else
{
so_far[i] = 0;
}
}
}
return response;
}
how //if (strings[so_far] == received) this line being implemented. if i had been recived "O" for "OK" at 'received' variable from calling fun //_SIM900_getch();
I REQUEST TO MAKE ME UNDERSTAND IF POSSIBLE..
TNX