welu1805 Active Member Licensed User Longtime User Feb 17, 2017 #1 Hi all, In C I can look with serial.availabe if there are any bytes to read. With serial.read I can read one byte, with serial.write I can write one. Are there similar commands in B4R? Thanx Lutz
Hi all, In C I can look with serial.availabe if there are any bytes to read. With serial.read I can read one byte, with serial.write I can write one. Are there similar commands in B4R? Thanx Lutz
Erel B4X founder Staff member Licensed User Longtime User Feb 17, 2017 #2 You should use AsyncStreams. Many examples: https://www.b4x.com/android/forum/pages/results/?query=b4r+asyncstreams Upvote 0
You should use AsyncStreams. Many examples: https://www.b4x.com/android/forum/pages/results/?query=b4r+asyncstreams
welu1805 Active Member Licensed User Longtime User Feb 17, 2017 #3 Erel said: You should use AsyncStreams. Many examples: https://www.b4x.com/android/forum/pages/results/?query=b4r asyncstreams Click to expand... It should NOT work asynchronous in the background. I need it in realtime, because these are midi events. Upvote 0
Erel said: You should use AsyncStreams. Many examples: https://www.b4x.com/android/forum/pages/results/?query=b4r asyncstreams Click to expand... It should NOT work asynchronous in the background. I need it in realtime, because these are midi events.
Erel B4X founder Staff member Licensed User Longtime User Feb 19, 2017 #4 Arduino is single threaded. AsyncStreams doesn't run in the background. Reading is event based. If you like you can work with the stream directly: https://www.b4x.com/b4r/help/core.html#stream Upvote 0
Arduino is single threaded. AsyncStreams doesn't run in the background. Reading is event based. If you like you can work with the stream directly: https://www.b4x.com/b4r/help/core.html#stream
welu1805 Active Member Licensed User Longtime User Feb 20, 2017 #5 OK, that is what I want. In my special case I want to use an Arduino Mega, because it has 4 UARTs. Serial for Logs with 115000 and Serial2 for Midi with 31250. How can I access Serial2 (or 3 and 4)? Upvote 0
OK, that is what I want. In my special case I want to use an Arduino Mega, because it has 4 UARTs. Serial for Logs with 115000 and Serial2 for Midi with 31250. How can I access Serial2 (or 3 and 4)?
Erel B4X founder Staff member Licensed User Longtime User Feb 20, 2017 #6 welu1805 said: How can I access Serial2 (or 3 and 4)? Click to expand... You should start a new thread for a new question. Additional Hardware Serial Ports Upvote 0
welu1805 said: How can I access Serial2 (or 3 and 4)? Click to expand... You should start a new thread for a new question. Additional Hardware Serial Ports
welu1805 Active Member Licensed User Longtime User Feb 22, 2017 #8 Sub Process_Globals 'These global variables will be declared once when the application starts. 'Public variables can be accessed from all modules. Public Serial As Serial Private SerialNative1 As Stream End Sub Private Sub AppStart Serial.Initialize(115200) Log("AppStart") RunNative("SerialNative1", Null) End Sub #if C void SerialNative1(B4R::Object* unused) { ::Serial1.begin(31250); //<--You can change the baud rate b4r_main::_serialnative1->wrappedStream = &::Serial1; }#end if I get this error: B4R version: 1.80 Parsing code. Error Error parsing program. Error description: Unbalanced #End If Occurred on line: 29 (Main) Upvote 0
Sub Process_Globals 'These global variables will be declared once when the application starts. 'Public variables can be accessed from all modules. Public Serial As Serial Private SerialNative1 As Stream End Sub Private Sub AppStart Serial.Initialize(115200) Log("AppStart") RunNative("SerialNative1", Null) End Sub #if C void SerialNative1(B4R::Object* unused) { ::Serial1.begin(31250); //<--You can change the baud rate b4r_main::_serialnative1->wrappedStream = &::Serial1; }#end if I get this error: B4R version: 1.80 Parsing code. Error Error parsing program. Error description: Unbalanced #End If Occurred on line: 29 (Main)
welu1805 Active Member Licensed User Longtime User Feb 22, 2017 #9 I found the error: #if C void SerialNative1(B4R::Object* unused) { ::Serial1.begin(31250); //<--You can change the baud rate b4r_main::_serialnative1->wrappedStream = &::Serial1; } #end if Upvote 0
I found the error: #if C void SerialNative1(B4R::Object* unused) { ::Serial1.begin(31250); //<--You can change the baud rate b4r_main::_serialnative1->wrappedStream = &::Serial1; } #end if