B4R Question No Log is coming at serial monitor

Discussion in 'B4R Questions' started by pokhraj_d, Oct 27, 2018.

  1. pokhraj_d

    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:
    Code:
    #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
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    I wouldn't use this library at all. It shouldn't be too difficult to parse the NMEA strings yourself.

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

    pokhraj_d Member

    Hello @Erel

    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
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    I was talking about the two 'serial2' objects.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice