B4R Question Problem with multiple UARTS

Nefarious19

New Member
Hello Guys,

I tried to compile code below to use other hardware uarts on my Arduino boards but i get an error. Can you explain wthat i'm doing wrong? Thank you in advance for help.

B4X:
#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 300
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
   
    Public SerialNative1 As Stream
   
   
End Sub

Private Sub AppStart

    RunNative("SerialNative1", Null)
End Sub

    #if C
    void SerialNative1(B4R::Object* unused) 
    {   
        ::Serial1.begin(9600); //<--You can change the baud rate
        b4r_main::_serialnative1->wrappedStream = &::Serial1;
    }
    #end if

ERROR:
B4X:
B4R version: 1.80
Parsing code.    (0.00s)
Compiling code.    (0.02s)
Building project    (0.03s)
Compiling & deploying Ino project (Arduino Nano - COM7)    Error
Loading configuration...
Initializing packages...
Preparing boards...
Verifying...
sketch\b4r_main.cpp: In function 'void SerialNative1(B4R::Object*)':
b4r_main.cpp:9: error: '::Serial1' has not been declared
    ::Serial1.begin(9600); //<--You can change the baud rate
    ^
b4r_main.cpp:10: error: '::Serial1' has not been declared
    b4r_main::_serialnative1->wrappedStream = &::Serial1;
                                               ^
exit status 1
 

Nefarious19

New Member
I know that Atmega328p has only one uart but i thoutgh that i can use each uart in this way. What if I don't want to use uart as Log but as a serial communication with other modules? In Arduino Mega compilation process ends with no error in this moment when i'm choosing Serial2.
 
Upvote 0
Top