Hi,
I use a similar algorithm on 76800 baud for RS485 Honeywell C-bus token
ring protocol and it works without problems from java on BBB and PC..
And I noticed thatyou nowhere call a *flush* when sending data, that
can be the problem..
Test it with the state machine, It must work..
Here is my reading algorithm from c lib on linux it detects a pause in
the transfer:
timeout - read timeout in seconds
usReadPause - after no incomming data on port for x micro seconds,
return from read sequence.. (return one data packet)
jint user_com_apli_jni_Cbridge_serialReceiveInterSpacingReadPause(JNIEnv * env,
jobject object,jint handle,jobject buffer,jint usReadPause,jint timeout){
size_t capacity = env->GetDirectBufferCapacity(buffer);
fd_set readfs;
timeval tv;
tv.tv_sec = timeout / 1000;
tv.tv_usec = 0;
void *buff = env->GetDirectBufferAddress(buffer);
int size = 0;
int rd = 0;
FD_ZERO(&readfs);
FD_SET(handle, &readfs);
select(handle + 1, &readfs,NULL,NULL, &tv );
if (FD_ISSET(handle, &readfs)) {
size = read(handle, buff, capacity);
rd = size;
do {
usleep(usReadPause);
buff = ((char*) buff) + rd;
rd = read(handle, buff, capacity - size);
if (rd > 0) {
size += rd;
}
}while (rd > 0 && capacity - size > 0);
env->SetIntField(buffer, limitFieldId, size);
return size;
}
return 0;
}
Arsi
------------------------------------------------------------------------
*From:* David Howlett
*Sent:* Thursday, April 27, 2017 6:54PM
*To:* Beagleboard
*Subject:* [beagleboard] Re: Repeatable bug where beaglebone black loses
bytes
from it's serial connection.
Reply to arsi
=============
If I understand you correctly, you are recommending adding a 4 byte
sequence "0x10 0x11 0x12 0x13" on a regular basis in the streaming
data to allow the receiving PC to sync up with the stream. Is that
what you mean? For my current application the data looks like:
10392.614241251299
10392.614691251242
10392.615141251357
10392.615581251385
10392.616281251357
10392.616741251242
10392.617181251328
10392.617651251473
10392.618101251212
10392.618801251299
It is delimited by "/r/n" which allows easy syncing up. The trouble is
that bytes can go missing to make the above data look like:
10392.614241251299
10392.614691251242
10392.615141251357
10392.615581251385
1039216281251357
10392.616741251242
10392.617181251328
10392.617651251473
10392.618101251212
10392.618801251299
I could make my format checking stricter and I could add checksums to
every line. This would cut down the error rate but I would prefer to
fix the cause of the data loss if possible.
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/beagleboard/5902E548.1030302%40chello.sk.
For more options, visit https://groups.google.com/d/optout.