I think I'm about to give up on this.
I have my new hardware and put it together. I tested with simple arduino project and get a loopback response so I know hardware is good.
I have a small test project in b4r and spent about 3 hours last night going through the b4r libraries, mainly AsyncStreams and B4RStream.
The issue as far as I can tell is that when the B4RStream library does readBytes with the line
Int i = wrappedStream->readBytes(((Byte*)Buffer->data + StartOffset + total), MaxCount);
The returned value 'i' is -1.
If you log the action directly with
::Serial.println(wrappedStream->readBytes(((Byte*)Buffer->data + StartOffset + total), MaxCount));
the returned value is 4294967295 which is higher than the max value of the Int variable (2147483647) so is possibly why it returns -1 (overflow maybe?)
This in turn returns to the AsyncStream lib the value of read bytes as 0
So then in this code in AsyncStream
if (index > 0 && (!me->prefixMode || index == maxSize)) {
arr->length = index;
sender->wrapPointer(b);
B4R::StackMemory::cp += index;
::Serial.print("Lib - Data4");
me->NewDataSub(arr);
}
'i' is always 0 and so NewDataSub is never called.
Also, interestingly. When accessing the stream direct in b4r with
If swserial.Stream.BytesAvailable> 1 Then
Dim b(swserial.Stream.BytesAvailable) As Byte
Dim len As Int = swserial.Stream.ReadBytes(b, 0, b.Length)
Log ("b4r - ", b)
Log ("Length = ", len)
Else
Log("No data")
End If
in the log, Length = 0. Which again uses the B4RStream lib and returns 0 like when using AsyncStream.
Any thoughts on this
@Erel?