Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old September 5th, 2011, 08:07 PM   #1 (permalink)
Junior Member
 
Join Date: Mar 2011
Location: Mexico
Posts: 30
 
Device(s): Samsung Galaxy 5 (GT-I5500L), Samsung Galaxy Ace
Thanks: 11
Thanked 2 Times in 2 Posts
Cry Trouble with the Buffer using bluetooth of android

I'm using the bluetooth of an android phone to send some data (strings) to an arduino with bluetooth device.
All works like charm... but I can only send 325 strings!!! (each string only contains 2 positive int numbers).
After this, at the logcat of eclipse, appears me this message: "rfc_setup_rx_bufout of buffer: rfc_setup_rx_bufout of buffer: Out of Buffers" each time that the android tries to send a new data.
I can't close the bluetoothsocket and reopen it (or connect) during the application cause I need to send data very fast for my purpose(about 100-200 ms one after another) and there's no time for that. How can I "clear" the buffer? Is it really the problem with the buffer??
Part of the code I'm ussing this:
Code:
    

private BluetoothSocket btSocket = null; 
try { 
            btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);

       } catch (IOException e) { 

       } 
           try { 
                outStream = btSocket.getOutputStream(); 

           } catch (IOException e) { 
                Log.e(TAG, "ON RESUME: Output stream creation failed.", e); 
           } 

byte[] msgBuffer = message.getBytes(); 
           try { 
                outStream.write(msgBuffer); 

           } catch (IOException e) { 
                Log.e(TAG, "ON RESUME: Exception during write.", e); 
           }
The "message" in message.getBytes(); is actually the string that I'm sending.

Another thing: I'm ussing an array (byte[] msgBuffer). Is there anyway I can make a "loop" to get to the [0] or [1] index after sending the data so this string will never be full cause I would only use 2 values.
Or the problem is with an internal buffer of my phone (samsung GT-I5500) and no with the code?
A will really apreciate any help cause I'm stuck in this.

lugopaco is offline  
Last edited by lugopaco; September 5th, 2011 at 08:11 PM.
Reply With Quote
Sponsors
Old September 6th, 2011, 11:33 AM   #2 (permalink)
Over Macho Grande?
 
alostpacket's Avatar
 
Join Date: Nov 2009
Location: NY
Posts: 7,090
 
Device(s): GalaxyNexus(LTE), NexusOne, OG Droid, GalaxyTab 10.1(LTE), Eris, Logitech Revue (fishtank)
Thanks: 4,164
Thanked 3,126 Times in 1,292 Posts
Default

moved to application development forum


have you tried wrapping the OutputStream in a BufferedOutputStream?
alostpacket is offline  
Reply With Quote
The Following User Says Thank You to alostpacket For This Useful Post:
lugopaco (September 7th, 2011)
Old September 7th, 2011, 09:29 AM   #3 (permalink)
Junior Member
 
Join Date: Mar 2011
Location: Mexico
Posts: 30
 
Device(s): Samsung Galaxy 5 (GT-I5500L), Samsung Galaxy Ace
Thanks: 11
Thanked 2 Times in 2 Posts
Default

I tried in a mini-Xperia and it worked (I received from the arduino more than 5000 values!! quite enough to do some tests). Actually for the project I'm doing, we will use this phone and the samsung will be part of another part of the work. Many thanks anyway. I will try it late when I've got more time to play with another resources.

Thanks!!!
lugopaco is offline  
Reply With Quote
Old September 7th, 2011, 03:22 PM   #4 (permalink)
Over Macho Grande?
 
alostpacket's Avatar
 
Join Date: Nov 2009
Location: NY
Posts: 7,090
 
Device(s): GalaxyNexus(LTE), NexusOne, OG Droid, GalaxyTab 10.1(LTE), Eris, Logitech Revue (fishtank)
Thanks: 4,164
Thanked 3,126 Times in 1,292 Posts
Default

You're welcome, glad you got it sorted
alostpacket is offline  
Reply With Quote
Reply

Bookmarks

Tags
android, bluetooth, buffer, java


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 11:45 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo