Hi,

I am using Lejos for a school project. We are sending a lot of data through
bluetooth, and problems are arising. Essentially, bluetooth communication
will lose packets when the bandwith is full.

The problem is in the native command Bluetooth.btSend(). The C-file says:

void bt_send(U8 *buf, U32 len)
{
  if (*AT91C_US1_TNCR == 0)
  {
    memcpy(&(out_buf[out_buf_ptr][0]), buf, len);
    *AT91C_US1_TNPR = (unsigned int) &(out_buf[out_buf_ptr][0]);
    *AT91C_US1_TNCR = len;
    out_buf_ptr = (out_buf_ptr+1) % 2;
  }
}


Notice that, when the link is full (ie AT91C_US1_TNCR != 0), btSend will
drop packets. The solution is simple: add a native method
getUnflushedPackets() that returns *AT91C_US1_TNCR. Let the flush() and
sendPacket methods in java yield while getUnflushedPackets() != 0. btSend()
should remain non-blocking, because the memcpy operation takes a bit of
time.

Is there some other way to work around this problem without a patch to the
JNI C-libraries? I do not have an ARM compiler, and as such cannot create an
extra getUnflushedPackets()-method.


Hope this gets solved,
we really need it for our school project ;-)
Ruben
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Lejos-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lejos-discussion

Reply via email to