B4R Question Mega, serial port 1 no response

Mostez

Well-Known Member
Licensed User
Longtime User
I tried this example to activate serial port 1 and 2 on Arduino Mega, serial port 2 (Serial HMI LCD) is working OK, but i get no response from port 1(Serial RFID Module), any ideas?

Thanks


B4X:
Sub Process_Globals
    Public LogSerial As Serial
    Public DWINstream As AsyncStreams
    Public RFIDstream As AsyncStreams

    Public SerialNative1 As Stream
    Public SerialNative2 As Stream

    Public BC As ByteConverter
End Sub

B4X:
Private Sub AppStart
     DWIN_VALID_PACKET = False
     RunNative("SerialNative1", Null)
     RunNative("SerialNative2", Null)
     ScreenTimeoutTimer.Initialize("ScreenTimeoutTimer_Tick",1000)
     ScreenTimeoutTimer.Enabled =True
    
     RFIDstream.Initialize(SerialNative1,"ReadRFID","RFIDerr")
     DWINstream.Initialize(SerialNative2 ,"ReadDWIN","DWINerr")
    
     LogSerial.Initialize (115200)
    
      ToggleBacklight(True )
     Delay (3000)
     GotoPage(DWIN_SCREEN_START)
     Buzzer(0x0A) 'buzz 100 MS
     MainDwin
End Sub

B4X:
#IF C
void SerialNative1(B4R::Object* unused) {
::Serial1.begin(9600); //<--You can change the baud rate
b4r_main::_serialnative1->wrappedStream = &::Serial1;
}
void SerialNative2(B4R::Object* unused) {
::Serial2.begin(115200); //<--You can change the baud rate
b4r_main::_serialnative2->wrappedStream = &::Serial2;
  }
#END IF
 

Mostez

Well-Known Member
Licensed User
Longtime User
everything was working OK, until I installed Ethernet-SD Card shield, HMI device works fine(Serial2), but i get no response from Serial1, I have to remove the Ethernet shield to get stream, tried to change to serial3 instead, same thing also, had to remove the shield, any ideas!

Thanks
 
Upvote 0
Top