Note that you use SoftwareSerial library to turn (almost) any 2 pins to a serial port.
You can access hardware Serial2, 3 and 4 on supported devices with this code:
B4X:
Sub Process_Globals
Public Serial1 As Serial
Private serial2 As Stream
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
RunNative("SetSerial2", Null)
'use AsyncStreams to work with serial2
End Sub
#if C
void SetSerial2(B4R::Object* unused) {
::Serial2.begin(9600);
b4r_main::_serial2->wrappedStream = &::Serial2;
}
#end if
#if C
void SerialNative1(B4R::Object* unused) {
::Serial1.begin(115200); //<--You can change the baud rate
b4r_main::_serialnative1->wrappedStream = &::Serial1;
}
#end if
#if C
void SerialNative2(B4R::Object* unused) {
::Serial2.begin(9600); //<--You can change the baud rate
b4r_main::_serialnative2->wrappedStream = &::Serial2;
}
#end if
#if C
void SerialNative3(B4R::Object* unused) {
::Serial3.begin(9600); //<--You can change the baud rate
b4r_main::_serialnative3->wrappedStream = &::Serial3;
}
#end if
Problem is B4J (Java) Serial connector and Teensy USB connector
Two devices and one port...
So.. after complile I must reinit B4J Serial connector