B4R Question No Log is coming at serial monitor

pokhraj_d

Member
Hello,
I am running the gps code with Tiny_GPS library. No error has been found during compilation.
But no result is also showing at log window.
Where is my mistake? Please suggest.

Below is my code:
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 Serial1 As Serial
    Public serial2 As SoftwareSerial   'Additional software serial port
    Private astream As AsyncStreams
    Private lat,lon As Long
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    serial2.Initialize(9600,5,6) ', rx 5, TX is 6
    astream.Initialize(serial2.Stream,"astream_newdata",Null)
    Log("AppStart")
    RunNative("setup",Null)
End Sub

Sub astream_newdata(Buffer() As Byte)
    RunNative("gpsread",Null)
    Log(Buffer)
End Sub


#if C
#include "TinyGPS.h"
#define PIN_TX 6
#define PIN_RX 5
SoftwareSerial serial2(PIN_TX,PIN_RX);
TinyGPS gps;
void setup(B4R::Object* o){
serial2.begin(9600);
}
void gpsread (B4R::Object* o) {
    int c = serial2.read();
     gps.encode(c);
   long slat, slong;
   gps.f_get_position(&slat,&slong);
   b4r_main::_lat = slat;
   b4r_main::_lon = slong;
}
#End if

Thanks-
Pokhraj Das
 

pokhraj_d

Member
Hello @Erel

Your code creates two SoftwareSerials on the same pins. You must remove one of them.

Not sure about how to remove the pin related to Serial1.
I have commented out the code related to Serial1, but still no output coming.
Could you please advice once please.

Pokhraj
 
Upvote 0
Top