# Q2686 UART receive buffer size is limit only 56?

**URL:** <https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436>\
**Category:** Legacy AirPrime modules\
**Created:** [May 22, 2010, 7:43am UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436 "2010-05-22T07:43:41Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![nagendra81](https://avatars.discourse-cdn.com/v4/letter/n/90db22/32.png) [@nagendra81](https://forum.sierrawireless.com/u/nagendra81)\
**Post date:** [May 22, 2010, 7:43am UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/1 "2010-05-22T07:43:41Z")

</div>

Hi,

is there any limit for only 56 bytes uart data length?

every time i received bytes only below 56 .if i send 110 bytes to uart from other terminal, i got two parts of packets. why ? where is the problem?

can anybody help regarding that problem?

Thanks in advance

regards  
Nagendra

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [May 22, 2010, 9:22am UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/2 "2010-05-22T09:22:59Z")

</div>

It’s not a problem - it is perfectly normal behaviour.

Your application just needs to be designed to accept input in any arbitrary-sized “fragments”

---

<div class="post-metadata">

**Author:** ![nagendra81](https://avatars.discourse-cdn.com/v4/letter/n/90db22/32.png) [@nagendra81](https://forum.sierrawireless.com/u/nagendra81)\
**Post date:** [May 22, 2010, 9:27am UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/3 "2010-05-22T09:27:47Z")

</div>

thanks for reply

ok i will try . what is the maximum size of data buffer in fcm datahandler?  
is there any specific fixed length or variable?

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [May 22, 2010, 10:16am UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/4 "2010-05-22T10:16:56Z")

</div>

> [@nagendra81](#):
>
> ok i will try . what is the maximum size of data buffer in fcm datahandler?

See the ADL User Guide.

See also: [FCM and WIP - #10 by awneil](https://forum.sierrawireless.com/t/fcm-and-wip/4407/10)

---

<div class="post-metadata">

**Author:** ![raveesa](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@raveesa](https://forum.sierrawireless.com/u/raveesa)\
**Post date:** [April 11, 2011, 1:59pm UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/5 "2011-04-11T13:59:35Z")

</div>

Hi,  
I’m facing similar kind of problem with Q2686 device ,  
I need to send some 90 bytes of data from external device , so I use arbitrary-sized “fragments” to receive that ,. when I send less than 30 bytes from external device it receives properly , if I send more than 30 bytes of data it receives correctly but my external device hangs up !!

If I remove the device (external device) and connect to the PC through level convertor, it sends all 90 bytes properly and my external device wont hang up .

what is the problem at q2686 device side …? is there any way to refresh the q2686’s UART2 rx buffer…?

regards  
Ravee

---

<div class="post-metadata">

**Author:** ![raveesa](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@raveesa](https://forum.sierrawireless.com/u/raveesa)\
**Post date:** [April 12, 2011, 2:05pm UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/6 "2011-04-12T14:05:24Z")

</div>

Hi,  
Is there any way to refresh the UART2 RX buffer of q2686 …?

regards  
Ravee

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [April 13, 2011, 6:09am UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/7 "2011-04-13T06:09:27Z")

</div>

What do you mean by, “refresh the UART2 RX buffer” ❓

If the external device is just sending stuff, how can it be affected by the receiver? 😕

Or does your Q26 application also send some reply to the external device?

Are there any other connections from the Q26 to the external device (including V24 control lines)?

---

<div class="post-metadata">

**Author:** ![raveesa](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@raveesa](https://forum.sierrawireless.com/u/raveesa)\
**Post date:** [April 13, 2011, 8:38am UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/8 "2011-04-13T08:38:21Z")

</div>

Hi,  
I noticed that there will be some junk values in the rx buffer , so how to refresh that buffer i.e means it should not contain any junk data .

Yes q26 device will send some data back but not as soon as it receives the data , I do some processing of that data and waits for user input , once the user has provided the i/p q26 will send that data to external device(usually it will take 5 to 10 seconds) , but my external device hangs up as soon as it sends the data(this happens irregularly ) .

regards  
Ravee

---

<div class="post-metadata">

**Author:** ![raveesa](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@raveesa](https://forum.sierrawireless.com/u/raveesa)\
**Post date:** [April 18, 2011, 4:47am UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/9 "2011-04-18T04:47:41Z")

</div>

Hi,  
What ever the data I’m sending from the device is getting split-ed at the q26 side ,…  
i.e when I send some 90 bytes from external device it gets split-ed in to 3 frames at the q26 uart receiver side  
some correct bytes+ junk values  
some correct + junk values  
correct bytes ,  
Here is the example data I have received at q 26  
MK1CA3001D371C1F+++ÿ++++  
0AA1001D351C1E0AA2001D381C1F09A4001C391BÁ  
1905KM001D371C1F+++ÿ++++  
since q2686 uart rx buffer can receive maximum of 56 bytes, I have implemented the arbitrary-sized “fragments” to receive whole 90 bytes of data , now the problem is due to data gets broken it many frames .  
due to this my buffer getting filled with junk values , becoz of this it leads to restart the device while processing the buffer … and this will happen once in a while …  
How to over come his problem …? how to fill the rx buffer with zeros (to initialize with zero)…

regards  
Ravee

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [April 18, 2011, 6:28am UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/10 "2011-04-18T06:28:22Z")

</div>

Obviously (well, it should be obvious), the first thing you need to determine is whether the external device is actually transmitting the junk, or if there’s a bug in your software that’s causing the junk to appear.

> [@raveesa](#):
>
> Here is the example data I have received at q 26  
> MK1CA3001D371C1F+++ÿ++++  
> 0AA1001D351C1E0AA2001D381C1F09A4001C391BÁ  
> 1905KM001D371C1F+++ÿ++++

How, exactly, did you obtain those traces?

Is the “junk” always at the end of the “good” data like that?

> [@](#):
>
> since q2686 uart rx buffer can receive maximum of 56 bytes

It’s not a limitation of the Q26 buffer - it’s just how FCM works.

> [@](#):
>
> I have implemented the arbitrary-sized “fragments” to receive whole 90 bytes of data

Maybe there’s a bug in your software implementation?

Maybe there’s a bug or fault in your hardware - eg, are you sure that you have the levels correct…?

Are you sure that the external device’s baud rate is absolutely correct?

> [@](#):
>
> How to over come his problem …?

FCM just delivers to your application whatever it receives - so, if you get junk, that’s what was received…

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [April 18, 2011, 6:30am UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/11 "2011-04-18T06:30:03Z")

</div>

Have you looked at the actual hex values of the received “junk” bytes?

---

<div class="post-metadata">

**Author:** ![raveesa](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@raveesa](https://forum.sierrawireless.com/u/raveesa)\
**Post date:** [April 18, 2011, 6:45am UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/12 "2011-04-18T06:45:53Z")

</div>

Hi,

I print the received data on the uart1 using adl\_atSendResponsePort(ADL\_AT\_RSP, uart1\_port,Rx\_data);  
Yes, junk data always at the end of the good data …  
And this happens once a while (i.e. I receive the data correctly for some 20 times then it gives the data like that ) so levels , baud rate are correct and external device is sending proper data.(verified through connecting to PC) .

Below is the code for software implementation  
to receive the data

```auto
bool fcmdatahandler2(u16 datalen,u8 *Rx_data)
{
 
 for(counter=0;counter<strlen(data);counter++)
	    		  	    				    	   		{
                                                   
	      Rawdata[atwritecnt] = data[counter];
                     atwritecnt++;
	    		  	    				    	   		}
if(atwritecnt>=90)
{
atwritecnt=0;
// do the required action 
}
}
```

is there any way to reset the uart.? and will it solve the problem …?

regards  
Ravee

---

<div class="post-metadata">

**Author:** ![szalik](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@szalik](https://forum.sierrawireless.com/u/szalik)\
**Post date:** [April 18, 2011, 6:55am UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/13 "2011-04-18T06:55:39Z")

</div>

> [@raveesa](#):
>
> Hi,
> 
> I print the received data on the uart1 using adl\_atSendResponsePort(ADL\_AT\_RSP, uart1\_port,Rx\_data);  
> Yes, junk data always at the end of the good data …

And how do you know that Rx\_data is nul-terminated C string? You should always use the the length parameter supplied by the FCM handler to correctly determine how many bytes you actually received.

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [April 18, 2011, 7:15am UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/14 "2011-04-18T07:15:17Z")

</div>

> [@raveesa](#):
>
> will it solve the problem …?

No - it will not❗

> [@I](#):
>
> Maybe there’s a bug in your software implementation?

Yes - there is!

As szalik correctly says, FCM does not provide the data as a NUL-terminated ‘C’ string!

Think about it: if that were the case, it would make FCM useless for pure binary data - wouldn’t it…?!

---

<div class="post-metadata">

**Author:** ![raveesa](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@raveesa](https://forum.sierrawireless.com/u/raveesa)\
**Post date:** [April 18, 2011, 8:36am UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/15 "2011-04-18T08:36:26Z")

</div>

Hi,  
I was printing the null for every FCM data event

```auto
bool fcmdatahandler2(u16 datalen,u8 *Rx_data)
{
using adl_atSendResponsePort(ADL_AT_RSP, uart1_port,Rx_data);
using adl_atSendResponsePort(ADL_AT_RSP, uart1_port,"\n");,

for(counter=0;counter<datalen,counter++)
                                                  {
                                                   
         Rawdata[atwritecnt] = data[counter];
                     atwritecnt++;
                                                  }
if(atwritecnt>=90)
{
atwritecnt=0;
// do the required action 
}
}
```

I handled with datalen given by FCM …  
But still the problem exist …

regards  
Ravee

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [April 18, 2011, 9:50am UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/16 "2011-04-18T09:50:44Z")

</div>

> [@raveesa](#):
>
> I was printing the null for every FCM data event

No, you were not!

I think you misunderstand the meaning of NUL?

NUL is a byte with a value of zero.

```auto
bool fcmdatahandler2( u16 datalen, u8 *Rx_data )
{
using adl_atSendResponsePort( ADL_AT_RSP, uart1_port, Rx_data );
```

That is wrong!

adl\_atSendResponsePort requires a string as its 3rd parameter; as has already been pointed out to you, the Rx\_data pointer provided by the FCM data handler is not a string!

Therefore, the resulting output produced by this is meaningless!

---

<div class="post-metadata">

**Author:** ![raveesa](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@raveesa](https://forum.sierrawireless.com/u/raveesa)\
**Post date:** [April 21, 2011, 11:26am UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/17 "2011-04-21T11:26:52Z")

</div>

Hi,  
Still i’m not abale to solve the problem ,.  
Now I have written below code to print/ verify the data the data .  
And also I have included output which I have got it ,…

```auto
static u8 Rawdata[100];
bool fcmdatahandler2(u16 datalen,u8 *data)
{
 for(counter=0;counter<datalen;counter++)
	{
 Rawdata[atwritecnt] = data[counter];
 atwritecnt++;
 }
 if(atwritecnt>90)
 {
 atwritecnt=0;
 adl_atSendResponsePort(ADL_AT_RSP, uart1_port,Rawdata);
 adl_atSendResponsePort(ADL_AT_RSP, uart1_port,"\n");
 }
                                              
 }
```

output :

1CA3001829141B06A2001829151B06A1001827131B06A4001829121A06A5001829121A06  
1CA3001828171A06A2001828171A06A1001826171A06A4001828181905A5001829121A06  
1CA3001927181B06A2001926171A06A1001925171A06A4001827181A05A5001926181B07  
1CA3001926181B06A2001926181B06A1001925171A06A4001927181A06A5001926181B07  
1CA3001927191B06A2001926181B06A1001926181B06A4001927181A06A5001829121A06  
1CA3001927191B06A1001925181B06A2001926181B06A4001926181B06A5001926181B07  
1CA3001926191B+ÐÁêÐ‰ë+Ð+ø‰V+ÐÁêÐ‰ë+Ð+ø‰VA5001926181B07 1CA3001927191B07A1001925181B07A2001926181B07A4001926181B06A5001926181B07  
1CA3001927191B07A1001926181B07A2001926181B07A4001926181B06A5001829121A06  
1CA3001928191B07A1001926181B07A2001927181B07A4001927181B06A5001926181B07  
1CA3001929191B07A1001927181B07A2001928181C07A4001A27181B06A5001926181B07  
1CA300192A191B07A1001928181B07A2001929181B07A4001A28181B06A5001926181B07  
1CA300192C191B07A100192B181B07A200192C181C07A4001A29181B06A5001829121A06  
1CA300192F191B07A100192D181B07A200192E181C07A4001A2B181B06A5001926181B07  
1CA300192F191B07A100192E181B07A200192F181C07A400192C181B06A5001926181B07  
1CA3001931191C07A100192F181B07A2001931181B07A400192C181A06A5001926181B07  
1CA3001934191C07A1001932181B07A2001934181B07A400192E181A06A5001829121A06  
1CA3001935191B07A1001934181B07A2001935181C07A400192F181A05A5001926181B07  
1CA3001935191C07A1001933181B07A2001935181C07A4001A30181A05A5001926181B07  
1CA3001932191C07Vè)ÿÿÿPÿ,q@ WUVÿÓ…À„ ;ÇWUVF181A05A5001829121A06 1CA3001A30191C07A100192E191B07A2001A2F191C07A4001A2E191A06A5001926181B07  
1CA3001A2F191C07A1001A2D191C07A2001A2E191C07A4001A2D191B06A5001926181B07  
1CA3001A2E1A1C07A1001A2D191C07A2001A2E191C07A4001A2C191B06A5001926181B07

Red lines indicates some junk values  
I’m not able to debugg …pls help me to find out the problem …?

---

<div class="post-metadata">

**Author:** ![szalik](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@szalik](https://forum.sierrawireless.com/u/szalik)\
**Post date:** [April 21, 2011, 11:45am UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/18 "2011-04-21T11:45:59Z")

</div>

> [@raveesa](#):
>
> Hi,  
> Still i’m not abale to solve the problem ,.  
> Now I have written below code to print/ verify the data the data .  
> And also I have included output which I have got it ,…
> 
> ```auto
> static u8 Rawdata[100];
> bool fcmdatahandler2(u16 datalen,u8 *data)
> {
> for(counter=0;counter<datalen;counter++)
> {
> Rawdata[atwritecnt] = data[counter];
> atwritecnt++;
> }
> if(atwritecnt>90)
> {
> atwritecnt=0;
> adl_atSendResponsePort(ADL_AT_RSP, uart1_port,Rawdata);
> adl_atSendResponsePort(ADL_AT_RSP, uart1_port,"\n");
> }
>                                               
> }
> ```

Sorry, but you’re still doing it wrong. Instead of counting on the forum members to fix it for you, please read some book on C language and C strings in particular.

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [April 21, 2011, 11:58am UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/19 "2011-04-21T11:58:38Z")

</div>

> [@raveesa](#):
>
> Still i’m not abale to solve the problem

The problem is that you still haven’t understood how strings work in ‘C’ !

As szalik says, you need to go back to the basics of what a string is in ‘C’ - this has nothing specifically to do with Open-AT.

I know that code entry on this forum isn’t great, but please take time to ensure that the code you post is legible!

Use the ‘Preview’ to be sure before you post.

```auto
static u8 Rawdata[100];
bool fcmdatahandler2( u16 datalen, u8 *data )
{
  for( counter=0; counter<datalen; counter++ )
  {
    Rawdata[atwritecnt] = data[counter];
    atwritecnt++;
  }
  if( atwritecnt>90 )
  {
     atwritecnt=0;
     adl_atSendResponsePort( ADL_AT_RSP, uart1_port, Rawdata );
     adl_atSendResponsePort( ADL_AT_RSP, uart1_port, "\n" );
  }
                                             
}
```

One thing to note: do not use TAB characters in source code - the expansion of TABs is entirely unreliable!

---

<div class="post-metadata">

**Author:** ![raveesa](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@raveesa](https://forum.sierrawireless.com/u/raveesa)\
**Post date:** [April 21, 2011, 2:42pm UTC](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436/20 "2011-04-21T14:42:08Z")

</div>

Hi,  
I thank you guys for having patience to answering my questions,  
I went through the basics of strings , char array is not a string if does not have null char (’\0’).  
if( atwritecnt\>90 )  
{  
Rawdata [atwritecnt]=’\0’;  
adl\_atSendResponsePort( ADL\_AT\_RSP, uart1\_port, Rawdata );  
adl\_atSendResponsePort( ADL\_AT\_RSP, uart1\_port, “\n” );  
atwritecnt=0;  
}

I hope this will work… I’ll test this tomorrow and reply …

regards  
Ravee

[Next page](https://forum.sierrawireless.com/t/q2686-uart-receive-buffer-size-is-limit-only-56/4436.md?page=2)
