My buffer is size 32.
Now, i added i can check how many bytes we received and close the buffer when it reaches 32. This is working fine now.
The GSM Modem i'm using is send its responds and finish them with CR + LF
I've changed my code to detect CR character and replace it by star character '*'
Once LF character is been received, it closes the buffer with '\0'
I'm also using a second buffer to avoid having the first one displayed while bytes are coming in.
When LF character is been detected it generates the string to be displayed. ( capture_buffer )
I think i'm almost done however 2 problems remains :
When i connect the Pic board to hyperterminal and enter bytes from my laptop keyboard, the bytes are captured and string is displayed properly.
If i connect the GSM Modem (Tellit GM862 ) to the Pic board and send commands , the GSM modem replies are not captured, i only get displayed a string with a single character that is the star '*'
Normaly, when Pic sends : AT and (CR)
Modem should respond : OK (CR) (LF)
At this time i'm only able to display '*' it looks that OK is NOT read, only CR ( replaced by * ) and LF looks to be detected.
I don't know why ...
As someone experienced trouble to receive responses from Tellit GSM Modem to Pic ? Maybe, a Synchronous or Asynchonous UART / USART wrong settings in my code ?
I hope someone could help me .
Here is my last tested code :
unsigned char buffer_uart = "-";
unsigned char capture_uart = "-";
static int buf_ptr;
static char got_char;
placed into infinite loop :
if (DataRdyUART()) // Check if datas are ready to be read.
buffer_uart[buf_ptr] = ReadUART(); // Stores byte from uart in the buffer
if (buffer_uart[buf_ptr]== '\r') // CR character received ?
buffer_uart[buf_ptr] = '*'; // Replace it with * character and ends the buffer string
if (buffer_uart[buf_ptr]== '\n') // LF character received ?
buffer_uart[buf_ptr] = '\0'; // Replace it with \0 character and ends the buffer string
// Overload check : If string is > 32 bytes long then ends it with '\0'
buffer_uart = '\0';
if(got_char) // If buffer ready to be used : do something :
capture_uart='\0'; // clear old displayed datas
strcpy (capture_uart,buffer_uart); // copy current buffer to buffer to be displayed
buffer_uart='\0'; // clear current buffer and be ready for next incoming string
post edited by lcoulon - 2010/07/11 06:25:15