Post
by Simon Knight » Tue Feb 09, 2010 10:52 am
Dear Bernd,
I have posted some sample data below. I have two routines running on repeat timers the first repeating every 250 ms, this reads the contents of the serial buffer and appends it to the global gDataBuffer. The second routine is where the problem occurs, it is called once per second and processes the contents of the data buffer. If all is well it ignores the last line, which is often incomplete and when it has processed all the other lines they are deleted leaving the part line still in the buffer. The next read operation will complete the line and all will be well. While attempting to track down what was causing the with each line construct to fail I added code that reported the number of lines in the data buffer followed by the buffer contents. When eight lines were present the code ran as expected, however once in a while 7 lines were reported (despite there being eight) and the routine failed. Close inspection of the data revealed that normally the line ends were indicated by two Hex(0D) characters but every so often three Hex(0D) were present. When there were three Hex(0D) characters present the "with each line" construct hangs. It will restart after a period of time and all is well if the timer is canceled and the routine is recalled.
I have attached two text files. The first is recorded from the routine that reads the serial port, the second is the same data as read by the second routine but with the following "//////////////FLThe buffer contains 8 lines of data" inserted to indicate the buffer start and ends. You will notice that extra blank lines are present indicating the third hex(0D) character.
I tried to attache the two files but .txt files are not allowed! I have put them in a zip and displayed some different data from the two recording points below:
RECORDED BY THE SERIAL PORT READ ROUTINE
056,33*70
$GPGSV,3,3,12,19,70,287,29,21,11,067,33,22,52,101,29,26,05,102,00*7F
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,0844,08,1j±Õäbä¬bíöbÇ¢∫bí bä b¬öbí™∫bí bííb™ÇbÇ∫¬böäR∫öj§DÈ
’‘*ii)Iì)S Säbí∫bí¬bäíböí™böäR∫
’§àÈï’âââ©äâ…äâiä…JI”THà“*™S(KLS¶”&&K©”ì¶ì í™öbr≈ÇÇÇ¢∫räíä∫b∫≈bbǬÇíäÇbÇÇíröb∫≈r•Çäj§¸$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091447,09,02,2010,+00,00*64
$GPGSV,3,1,11,03,59,145,31,06,51,133,29,08,12,297,29,11,23,261,31*74
$GPGSV,3,2,11,14,09,114,27,18,23,047,27,19,84,253,29,22,50,077,29*7E
$GPGSV,3,3,11,26,15,090,29,28,13,325,31,32,05,195,00*4C
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091448,09,02,2010,+00,00*6B
$GPGSV,3,1,11,03,59,145,29,06,51,133,29,08,12,297,29,11,23,261,29*74
$GPGSV,3,2,11,14,09,114,31,18,23,047,29,19,84,253,29,22,50,077,27*79
$GPGSV,3,3,11,26,15,090,27,28,13,325,31,32,05,195,00*42
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091449,09,02,2010,+00,00*6A
$GPGSV,3,1,11,03,59,145,33,06,51,133,27,08,12,297,31,11,23,261,27*76
$GPGSV,3,2,11,14,09,114,29,18,23,047,29,19,84,253,27,22,50,077,29*70
$GPGSV,3,3,11,26,15,090,29,28,13,325,29,32,05,195,00*45
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091450,09,02,2010,+00,00*62
$GPGSV,3,1,11,03,59,145,29,06,51,133,29,08,12,297,29,11,23,261,31*7D
$GPGSV,3,2,11,14,09,114,29,18,23,047,29,19,84,253,29,22,50,077,29*7E
$GPGSV,3,3,11,26,15,090,31,28,13,325,27,32,05,195,00*42
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091451,09,02,2010,+00,00*63
$GPGSV,3,1,11,03,59,145,29,06,51,133,31,08,12,297,31,11,23,261,31*7D
$GPGSV,3,2,11,14,09,114,31,18,23,047,31,19,84,253,29,22,50,077,29*7E
$GPGSV,3,3,11,26,15,090,29,28,13,325,29,32,05,195,00*45
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091452,09,02,2010,+00,00*60
$GPGSV,3,1,11,03,59,145,27,06,51,133,31,08,12,297,29,11,23,261,31*7A
$GPGSV,3,2,11,14,09,114,29,18,23,047,27,19,84,253,27,22,50,077,29*7E
$GPGSV,3,3,11,26,15,090,27,28,13,325,29,32,05,195,00*4B
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091453,09,02,2010,+00,00*61
$GPGSV,3,1,11,03,59,145,29,06,51,133,27,08,12,297,29,11,23,261,27*74
$GPGSV,3,2,11,14,09,114,29,18,23,047,29,19,84,253,29,22,50,077,27*70
$GPGSV,3,3,11,26,15,090,31,28,13,325,31,32,05,195,00*45
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091454,09,02,2010,+00,00*66
$GPGSV,3,1,11,03,59,145,31,06,51,133,29,08,12,297,31,11,23,261,31*7D
$GPGSV,3,2,11,14,09,114,29,18,23,047,31,19,84,253,31,22,50,077,27*70
$GPGSV,3,3,11,26,15,090,29,28,13,325,29,32,05,195,00*45
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091455,09,02,2010,+00,00*67
$GPGSV,3,1,11,03,59,145,29,06,51,133,29,08,12,297,27,11,23,261,29*7A
$GPGSV,3,2,11,14,09,114,29,18,23,047,27,19,84,253,27,22,50,077,29*7E
$GPGSV,3,3,11,26,15,090,29,28,13,325,29,32,05,195,00*45
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091456,09,02,2010,+00,00*64
$GPGSV,3,1,11,03,59,145,29,06,51,133,31,08,12,297,31,11,23,261,29*74
$GPGSV,3,2,11,14,09,114,29,18,23,047,29,19,84,253,29,22,50,077,31*77
$GPGSV,3,3,11,26,15,090,27,28,13,325,29,32,05,195,00*4B
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091457,09,02,2010,+00,00*65
$GPGSV,3,1,11,03,59,145,31,06,51,133,31,08,12,297,31,11,23,261,29*7D
$GPGSV,3,2,11,14,09,114,29,18,23,047,29,19,84,253,31,22,50,077,29*77
$GPGSV,3,3,11,26,15,090,31,28,13,325,27,32,05,195,00*42
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091458,09,02,2010,+00,00*6A
$GPGSV,3,1,11,03,59,145,31,06,51,133,27,08,12,297,31,11,23,261,31*73
$GPGSV,3,2,11,14,09,114,29,18,23,047,31,19,84,253,29,22,50,077,29*77
$GPGSV,3,3,11,26,15,090,29,28,13,325,31,32,05,195,00*4C
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091459,09,02,2010,+00,00*6B
$GPGSV,3,1,11,03,59,145,29,06,51,133,31,08,12,297,31,11,23,261,29*74
$GPGSV,3,2,11,14,09,114,27,18,23,047,29,19,84,253,31,22,50,077,29*79
$GPGSV,3,3,11,26,15,090,27,28,13,325,29,32,05,195,00*4B
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091500,09,02,2010,+00,00*66
$GPGSV,3,1,11,03,59,145,29,06,51,133,29,08,12,297,31,11,23,261,31*74
$GPGSV,3,2,11,14,09,114,29,18,23,047,29,19,84,253,29,22,50,077,29*7E
$GPGSV,3,3,11,26,15,090,31,28,13,325,29,32,05,195,00*4C
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091501,09,02,2010,+00,00*67
$GPGSV,3,1,11,03,59,145,27,06,51,133,29,08,12,297,29,11,23,261,29*7A
$GPGSV,3,2,11,14,09,114,29,18,23,047,29,19,84,253,29,22,50,077,31*77
$GPGSV,3,3,11,26,15,090,29,28,13,325,29,32,05,195,00*45
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091502,09,02,2010,+00,00*64
$GPGSV,3,1,11,03,59,145,29,06,51,133,31,08,12,297,29,11,23,261,29*7D
$GPGSV,3,2,11,14,09,114,29,18,23,047,33,19,84,253,29,22,50,077,29*75
$GPGSV,3,3,11,26,15,090,27,28,13,325,27,32,05,195,00*45
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091503,09,02,2010,+00,00*65
$GPGSV,3,1,11,03,59,145,29,06,51,133,29,08,12,297,31,11,23,261,27*73
$GPGSV,3,2,11,14,09,114,29,18,23,047,29,19,84,253,29,22,50,077,29*7E
$GPGSV,3,3,11,26,15,090,29,28,13,325,29,32,05,195,00*45
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091504,09,02,2010,+00,00*62
$GPGSV,3,1,11,03,59,145,29,06,51,133,31,08,12,297,33,11,23,261,29*76
$GPGSV,3,2,11,14,09,114,29,18,23,047,29,19,84,253,29,22,50,077,29*7E
$GPGSV,3,3,11,26,15,090,29,28,13,325,29,32,05,195,00*45
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091505,09,02,2010,+00,00*63
$GPGSV,3,1,11,03,59,145,29,06,51,133,29,08,12,297,29,11,23,261,29*74
$GPGSV,3,2,11,14,09,114,29,18,23,047,29,19,84,253,29,22,50,077,29*7E
$GPGSV,3,3,11,26,15,090,27,28,13,325,27,32,05,195,00*45
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091506,09,02,2010,+00,00*60
$GPGSV,3,1,11,03,59,145,27,06,51,133,31,08,12,297,29,11,23,261,31*7A
$GPGSV,3,2,11,14,09,114,27,18,23,047,31,19,84,253,29,22,50,077,29*79
$GPGSV,3,3,11,26,15,090,29,28,13,325,29,32,05,195,00*45
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091507,09,02,2010,+00,00*61
$GPGSV,3,1,11,03,59,145,29,06,51,133,29,08,12,297,29,11,23,261,31*7D
$GPGSV,3,2,11,14,09,114,31,18,23,047,29,19,84,253,31,22,50,077,31*77
$GPGSV,3,3,11,26,15,090,29,28,13,325,29,32,05,195,00*45
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,091508,09,02,2010,+00,00*6E
$GPGSV,3,1,11,03,59,145,31,06,51,133,27,08,12,297,29,11,23,261,31*7A
$GPGSV,3,2,11,14,09,114,27,18,23,047,31,19,84,253,29,22,50,077,31*70
$GPGSV,3,3,11,26,15,090,29,28,13,325,29,32,05,195,00*45
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
Now for the problem as seen by the second routine:
//////////////FLThe buffer contains 8 lines of data
27.8253,N,00047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,093427,09,02,2010,+00,00*60
$GPGSV,3,1,11,03,50,146,31,06,42,136,29,08,08,290,27,11,31,265,29*75
$GPGSV,3,2,11,14,15,109,29,18,16,045,29,19,81,170,31,22,45,067,27*7E
$GPGSV,3,3,11,26,20,083,29,28,19,321,31,32,13,196,00*42
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00
//////////////FLThe buffer contains 8 lines of data
047.1217,W,,,080210,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,093428,09,02,2010,+00,00*6F
$GPGSV,3,1,11,03,50,146,27,06,42,136,29,08,08,290,27,11,31,265,29*72
$GPGSV,3,2,11,14,15,109,29,18,16,045,29,19,81,170,29,22,45,067,29*79
$GPGSV,3,3,11,26,20,083,31,28,19,321,29,32,13,196,00*42
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210
//////////////FLThe buffer contains 8 lines of data
,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,093429,09,02,2010,+00,00*6E
$GPGSV,3,1,11,03,50,146,29,06,42,136,29,08,08,290,31,11,31,265,29*7B
$GPGSV,3,2,11,14,15,109,31,18,16,045,27,19,81,170,31,22,45,067,29*77
$GPGSV,3,3,11,26,20,083,29,28,19,321,29,32,13,196,00*4B
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
//////////////FLThe buffer contains 7 lines of data
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,093430,09,02,2010,+00,00*66
$GPGSV,3,1,11,03,50,146,29,06,42,136,29,08,08,290,29,11,31,265,29*72
$GPGSV,3,2,11,14,15,109,27,18,16,045,31,19,81,170,29,22,45,067,29*7E
$GPGSV,3,3,11,26,20,083,31,28,19,321,27,32,13,196,00*4C
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
//////////////FLThe buffer contains 7 lines of data
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,093431,09,02,2010,+00,00*67
$GPGSV,3,1,11,03,50,146,29,06,42,136,29,08,08,290,29,11,31,265,31*7B
$GPGSV,3,2,11,14,15,109,27,18,16,045,31,19,81,170,31,22,45,067,29*77
$GPGSV,3,3,11,26,20,083,29,28,19,321,31,32,13,196,00*42
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
//////////////FLThe buffer contains 7 lines of data
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,093432,09,02,2010,+00,00*64
$GPGSV,3,1,11,03,50,146,31,06,42,136,29,08,08,290,31,11,31,265,31*7B
$GPGSV,3,2,11,14,15,109,31,18,16,045,31,19,81,170,27,22,45,067,29*77
$GPGSV,3,3,11,26,20,083,29,28,19,321,31,32,13,196,00*42
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210
//////////////FLThe buffer contains 8 lines of data
,002.3,W,N*01
$GPGGA,171530,5327.8253,N,00047.1217,W,0,00,00.00,000009.1,M,0047.1,M,,*63
$GPZDA,093433,09,02,2010,+00,00*65
$GPGSV,3,1,11,03,50,146,31,06,42,136,29,08,08,290,27,11,31,265,29*75
$GPGSV,3,2,11,14,15,109,29,18,16,045,33,19,81,170,29,22,45,067,29*72
$GPGSV,3,3,11,26,20,083,29,28,19,321,29,32,13,196,00*4B
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,171530,V,5327.8253,N,00047.1217,W,,,080210,002.3,W,N*01
-
Attachments
-
- SerialPortProblem.zip
- Two files displaying the same data
- (4.32 KiB) Downloaded 307 times
best wishes
Skids