B4R Question Teensy with several Serial ports

raphaelcno

Active Member
Licensed User
Longtime User
Will a future version of B4R support Arduino boards with several hardware Serial ports?

For instance Teensy board has 4 Serial ports:

2016-04-17 - B4R Forum - Teensy Serial1+2+3.png

https://www.pjrc.com/teensy/pinout.html
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
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
 
Last edited:
Upvote 0

jarda

Member
Licensed User
Longtime User
Hi Erel

So,
1. Teesy 3.2 working on Arduino v 1.68 (not v 1.69)
2. On B4R not working...

pls.. see image

Untitled2 = chose on Arduino 1.68
Untitled4 = I chose
Untitled6 = Selection on B4R
Untitled8 = result
Untitled10 = compiling on Arduino 1.68

how to choose the procedure?

Jarek
 

Attachments

  • Untitled-2.png
    Untitled-2.png
    189.4 KB · Views: 355
  • Untitled-4.png
    Untitled-4.png
    12.4 KB · Views: 330
  • Untitled-6.png
    Untitled-6.png
    28.7 KB · Views: 351
  • Untitled-8.png
    Untitled-8.png
    72.3 KB · Views: 353
  • Untitled-10.png
    Untitled-10.png
    381.2 KB · Views: 322
Last edited:
Upvote 0

jarda

Member
Licensed User
Longtime User
Only this scenarios is Ok

1. Close COM port on B4J Serial connector
2. Run F5 on B4R my test
3 wait on pop up window
4. open COM port on B4J Serial Connector
5 AppStart15 :)

otherwise : Failed to open port

this is not practical.. :(

Jarek
 

Attachments

  • Untitled-9.jpg
    Untitled-9.jpg
    89 KB · Views: 263
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

jarda

Member
Licensed User
Longtime User
Yes.. this is Ok

my code

#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

but i don't know as possible solve

Jarek
 

Attachments

  • Untitled-21.jpg
    Untitled-21.jpg
    34.3 KB · Views: 310
  • Untitled-22.jpg
    Untitled-22.jpg
    17.9 KB · Views: 303
  • Untitled-6.jpg
    Untitled-6.jpg
    85.8 KB · Views: 317
Last edited:
Upvote 0

amorosik

Expert
Licensed User
Hi Jarda, have you solved the problem of communication with different serials?
I have the same problem and some advice could be very useful to me
 
Upvote 0
Top