Pages: [1]   Go Down
Author Topic: Arduino and Android - USB loosing packages  (Read 635 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello folks,

I'm trying to interact with my Arduino UNO from my Android tablet running 4.0.3 and got everything working using the Android USB Host API, which means I can send data over USB to the board and read it there via Serial.read() successfully. Now I'm trying to implement a feedback functionality, which means the other way around, sending from the Uno and reading on the tablet. This works also quite well using Serial.write() but I got a little problem: Sometimes, there are no bytes transferred and some other times, only some of them, so the content I'm sending is cut in half. Any suggestions how to fix this? I'm asssuming the Serial port has some issues sending all of the data, perhaps I should change the baud-rate which is currently at 9600?
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 634
Posts: 50239
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I'm asssuming the Serial port has some issues sending all of the data, perhaps I should change the baud-rate which is currently at 9600?
No. Most likely, you are expecting serial data to miraculously arrive all at once.

Post some code, if you really want help.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks. I'm currently using the following code to communicate with the board (written for Android in Java, off course)

Code:
byte[]data = new byte[1024]; //bigger size just to make sure...
int returnLen = conn.bulkTransfer(epIN,data,data.length,500); //epIN is the
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 634
Posts: 50239
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is that the code for sending data to the Arduino, or for getting data from the Arduino?

Where is the Arduino code?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Arduino simply uses
Code:
Serial.write(5); //sending 5 as an example
Logged

Pages: [1]   Go Up
Jump to: