Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8315425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:07:40+00:00 2026-06-08T21:07:40+00:00

First time poster long time reader. I’ve been playing round with reading in data

  • 0

First time poster long time reader.

I’ve been playing round with reading in data from a bluetooth GPS unit.
I can connect to it using hyperterm and see the data

The following log is from the hyperterm

$GPRMC,195307.109,A,5208.2241,N,00027.7689,W,000.0,345.8,310712,,,A*7E
$GPVTG,345.8,T,,M,000.0,N,000.0,K,A*07
$GPGGA,195308.109,5208.2242,N,00027.7688,W,1,04,2.1,58.9,M,47.3,M,,0000*7E
$GPGSA,A,3,19,03,11,22,,,,,,,,,5.5,2.1,5.0*3F
$GPRMC,195308.109,A,5208.2242,N,00027.7688,W,000.0,345.8,310712,,,A*73
$GPVTG,345.8,T,,M,000.0,N,000.0,K,A*07
$GPGGA,195309.109,5208.2243,N,00027.7688,W,1,04,2.1,58.9,M,47.3,M,,0000*7E

END LOG

The following log is from my C++ program

$GPGSV,3,3,12,14,20,105,16,28,18,323,,08,07,288,,16,01,178,*7A

$GPRMC,195,3,2ÿþÿÿÿL.š945.109,A,5208.2386,N,00027.7592,W,000.0,169.5,8,323,,08,07,288,,16,01,178,*7A

$GPRMC,195,3,2ÿþÿÿÿL.š310712,,,A*70

$GPVTG,169.5,T,,M,000.0,N,000.0,K,A*06

8,07,288,,16,01,178,*7A

$GPRMC,195,3,2ÿþÿÿÿL.š310712,,,A*70

$GPVTG,169.5,T,,M,000.0,N,000.0,K,A*06

8,07,288,,16,01,178,*7A

$GPRMC,195,3,2ÿþÿÿÿL.š$GPGGA,195946.109,5208.2386,N,00027.7592,W,1.0,K,A*06

8,07,288,,16,01,178,*7A

END LOG

THE PROBLEM
I’ve left the line feeds as they come, the C++ output has extra line feeds, not sure why?
The C++ log also has some funky chars…?

The Code

    for (int n=0;n<100;n++) {
        char INBUFFER[100];
        cv::waitKey(1000);
        bStatus = ReadFile(comport,   // Handle
                &INBUFFER,            // Incoming data
                100,                  // Number of bytes to read
                &bytes_read,          // Number of bytes read
                NULL);

        cout << "bStatus " << bStatus << endl;
        if (bStatus != 0)
        {
            // error processing code goes here
        }
        LogFile << INBUFFER;
    }

I’m using settings…

    comSettings.BaudRate = 2400;
    comSettings.StopBits = ONESTOPBIT;
    comSettings.ByteSize = 8;
    comSettings.Parity   = NOPARITY;
    comSettings.fParity  = FALSE;

…which as far as I can tell are the same as the settings used by hyperterm.
Any hints on what I’m doing wrong?

cheers!

UPDATE
So after updating to use bytes_read and account for the extra LF at the end of NMEA data I now have…

    if (bytes_read!=0) {
        for (int i=0; i < bytes_read; i++) {
            LogFile << INBUFFER[i];
        }
    }

Which appears to have fixed things!

$GPGGA,215057.026,5208.2189,N,00027.7349,W,1,04,6.8,244.6,M,47.3,M,,0000*41
$GPGSA,A,3,32,11,01,19,,,,,,,,,9.7,6.8,7.0*3D
$GPRMC,215057.026,A,5208.2189,N,00027.7349,W,002.0,208.7,310712,,,A*74
$GPVTG,208.7,T,,M,002.0,N,003.8,K,A*09
$GPGGA,215058.026,5208.2166,N,00027.7333,W,1,04,6.8,243.1,M,47.3,M,,0000*42

Thanks folks, your help was much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:07:42+00:00Added an answer on June 8, 2026 at 9:07 pm

    You have a bytes_read var, but you don’t do anything with it? Seems to me that you’re dumping the entire INBUFFER to the file, no matter how many/few bytes are actually loaded into it?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First time poster, long time reader. I've been having a problem with figuring this
first time poster, long time reader so be gentle with me :) See the
Long time reader, first time poster. Any help is greatly appreciated. I have crafted
long time reader, first time poster. I’m coming with an issue that many of
Long time reader, first time poster. Working on a web site at http://www.howardpitch.com/ ,
Long time reader, first time poster. I'm a big noob when it comes to
Long time reader, first time poster asks: After many weeks of google and forum
First time poster, long time reader. I searched and found no questions that answered
I'm a long time reader first time poster, glad to start participating in this
Long time reader, first time poster. One day I hope to be answering questions

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.