Android DUE UNO
<-- Bluetooth/Ser1 -->
<-- Ser2 / (10/11) -->
Communication between Android and DUe in both directions OK
Receiving Data from UNO, OK
Only sending Data from DUe to UNO not works !
The Data was send , but on the UNO the newdata-event was not fired.
DUE-Code:
B4X:
Private Sub AppStart
RunNative("SerialNative1", Null)
Stream1.Initialize(SerialNative1, "Android_NewData", Null)
RunNative("SerialNative2", Null)
Stream2.Initialize(SerialNative2, "Slave_NewData", Null)
...
Sub Timer1_Tick
Log("timer")
Stream2.Write(ser.ConvertArrayToBytes(Array("BOT",201,1,"EOT")))
...
UNO-Code:
B4X:
Private Sub AppStart
Serial1.Initialize(115200)
Log("appstart")
'softserial.Initialize(9600,SerPin.A0,SerPin.A1)
softserial.Initialize(9600,10,11)
astream.Initialize(softserial.Stream, "astream_newdata", Null)
...
Sub astream_newdata (Buffer() As Byte)
Dim be(20) As Object
Dim data() As Object = ser.ConvertBytesToArray(Buffer,be)
Log("Received:------------------------")
For Each o As Object In data
Log(o)
Next
.....
What is the inline C? If you used this code as an example then the baud rate is different for SerialNative2. Are you sure you have the correct pins connected? Serial2 on pins 17 (RX) and 16 (TX) for the DUE, so uno-due -> 10-16, 11-17. Try the error events. What is the #StackBufferSize?
Inline C, cabels,pins baudrate,level-shifter are o, stackbuffersize are standard 300
it is not possible to use prefixmode with a DUE !!!
compiling gives this error
Überprüfungs- und Hochladevorgang...
F:\B4R\Projekte\Gartensteuerung2\Master\Objects\bin\sketch\b4r_main.cpp: In static member function 'static void b4r_main::_appstart()':
b4r_main.cpp:102: error: invalid conversion from 'void (*)(B4R::Array*)' to 'B4R::SubVoidVoid {aka void (*)()}' [-fpermissive]
b4r_main::_stream2->InitializePrefix(b4r_main::_serialnative2,Common_False,_slave_newdata,_slave_error);
^
In file included from F:\B4R\Projekte\Gartensteuerung2\Master\Objects\bin\sketch\B4RDefines.h:25:0,
from F:\B4R\Projekte\Gartensteuerung2\Master\Objects\bin\sketch\b4r_main.cpp:1:
rRandomAccessFile.h:198: error: initializing argument 4 of 'void B4R::AsyncStreams::InitializePrefix(B4R::B4RStream*, bool, B4R::SubVoidArray, B4R::SubVoidVoid)' [-fpermissive]
void InitializePrefix (B4RStream* Stream, bool BigEndian, SubVoidArray NewDataSub, SubVoidVoid ErrorSub);
^
exit status 1
invalid conversion from 'void (*)(B4R::Array*)' to 'B4R::SubVoidVoid {aka void (*)()}' [-fpermissive]
I've tested it with this code and it compiles properly:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
Dim astream As AsyncStreams
astream.InitializePrefix(Serial1.Stream, False, "astream_NewData", "astream_Error")
End Sub
Sub AStream_Error
End Sub
Sub AStream_NewData (Buffer() As Byte)
End Sub
I've tested it with this code and it compiles properly:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
Dim astream As AsyncStreams
astream.InitializePrefix(Serial1.Stream, False, "astream_NewData", "astream_Error")
End Sub
Sub AStream_Error
End Sub
Sub AStream_NewData (Buffer() As Byte)
End Sub
Sorry, i see my sub Astream_Error was wrong declared (compiling is now ok)
Now i have changed the Due and UNO-side to astream.InitializePrefix
but the Problem is the same , the receiving-event on the uno was not fired, also the error-event
also try :
-other serial on the Due
-other Ports on the UNO
- increasing the stackbuffer size
all the same no receiving data at the UNO