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

  • SEARCH
  • Home
  • 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 7771427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:39:01+00:00 2026-06-01T16:39:01+00:00

I’m using the following code snippet to send gps data accross a com port

  • 0

I’m using the following code snippet to send gps data accross a com port once a second:

serialPort = new SerialPort("COM4", 4800, Parity.None, 8, StopBits.One);
serialPort.Handshake = Handshake.None;
serialPort.WriteTimeout = 500;
serialPort.Open();

This is all fine and good, but when writing to the serial port using the following method:

serialPort.Write(theString);

with theString == 504 charactors My read program, using:

  while (true) {
      Console.Write(serialPort.ReadExisting());
  }

will only ever read 254 bytes of data from that write statment.
The same occurrs with putty too.

I have tried splitting the write statment into 254 byte sized chunks and writing twice but it appears that the second write operation, although confirmed as run by my writer program, never gets read by the reader program.

I know my write buffer is 4096 bytes and my read buffer is 2048 bytes.

My string is this:

$GPGGA,191500.00,3351.6474,S,15112.6510,E,2,04,2.5,+0008,M,+020,M,00,0000*76
$GPVTG,057.3,T,,,000.0,N,000.0,K,A*41
$GPRMC,191500.00,A,3351.6474,S,15112.6510,E,000.0,057.3,120412,D*40
$GPGLL,3351.6474,S,15112.6510,E,191500.00,A,A*79
$GPGSA,A,3,,,,,,,,,,,,,2.5,1.3,2.1*34
$GPGSV,1,1,5,03,20,40,89,06,18,30,86,12,25,15,80,20,5,36,70*77
$GPDTM,999,,0.0,S,0.0,E,+0.0,W84*3B
$GPZDA,191500.00,11,04,12*60
$GPGBS,191500.00,+020.0,+020.0,+000.0,,0.00000,+0000.0,0000.0*63
$GPMSS,999,999,200.0,4800,*56

When I try to write to the buffer using one write statment per line in the string, It will write everything to the buffer, however, two write operations will get interlaced in the reader, so the result is this:

etc...
$GPGGA,191500.00,3351.6474,S,15112.6510,E,2,04,2.5,+0008,M,+020,M,00,0000*76
$GPDTM,999,,0.0,S,0.0,E,+0.0,W84*3B
$GPVTG,057.3,T,,,000.0,N,000.0,K,A*41
$GPZDA,191500.00,11,04,12*60
$GPRMC,191500.00,A,3351.6474,S,15112.6510,E,000.0,057.3,120412,D*40
$GPGBS,191500.00,+020.0,+020.0,+000.0,,0.00000,+0000.0,0000.0*63
$GPGLL,3351.6474,S,15112.6510,E,191500.00,A,A*79
$GPMSS,999,999,200.0,4800,*56
$GPGSA,A,3,,,,,,,,,,,,,2.5,1.3,2.1*34
$GPGSV,1,1,5,03,20,40,89,06,18,30,86,12,25,15,80,20,5,36,70*77
etc...

None of this makes sense to me, although at 9600 baud rate the interlacing problem does not occurr, (I assume because 4800 baud == 480bytes/s), Changing the baud rate is not an option, and somehow the normal GPS is able to transmit all this data in one burst.

QUESTION:

Does anyone know why my read is only ever picking up 254 bytes of data when I am writing 504 bytes of data to the stream?
Is there some constraint on

serialPort.Write(Byte[], int offset, int count);

that does not allow for more than 254 bytes? (which would not explain the second write operation not completing).

Or even. does anyone know of a better way to write to the serial port?


This method appears to work for the data provided (although my original question still stands):

string Sentence = "";
for (int i = 0; i < block_list[total_block].Count; i+=2) {
    Sentence = block_list[total_block][i] + block_list[total_block][i+1];
    serialPort.Write(Sentence);
}
  • 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-01T16:39:02+00:00Added an answer on June 1, 2026 at 4:39 pm

    Hang on, you stated that you used a one-second timeout but your code reads:

    serialPort.WriteTimeout = 500;
    

    That’s a half-second timeout on the sending side. And at 4.8Kbps (which is roughly 480 characters per second, as you state), that’s only enough time to send about 240 characters.

    It may be that the GPS can do this because it doesn’t have that half-second timeout.

    Try bumping the timeout up a bit and seeing what happens – five seconds should give you plenty of breathing space for testing. At 4.8Kbps, 504 bytes will need a little more than a second for full transmission.

    And be sure you really don’t want any handshaking? Lack of that may also cause data loss down the track.

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

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build

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.