From: William H. <wi...@ne...> - 2009-03-30 14:23:41
|
For future reference, you should *always* include all the details, exactly as you see them and without editorialisation, in your postings. The empty lines arose because *nix treats both \n and \r as line delimiters. So there is an "empty line" between the \n and \r, and fgets returns right away on every second call to readIMU. dong Lee wrote: > Hi Dave, > > Thanks for your help, I believe I found the problem. > Previously, cat /dev/ttyS2 result was like below, > (empty lines were included byitself, eventhough I didn't send it, > the format was "$IMADC,00,000,000,000,000,000,000\n\r\0" ) > > $IMADC,20,9D2,688,AE9,9F0,649,10D > > $IMADC,20,9D0,685,AE9,9EF,651,105 > > $IMADC,20,9CC,689,AE9,9E8,650,112 > > Now I deleted \r, and the new format is > "$IMADC,00,000,000,000,000,000,000\n\0", and cat /dev/ttyS2 result is > (empty line disappeared...) > > $IMADC,20,9D2,688,AE9,9F0,649,10D > $IMADC,20,9D0,685,AE9,9EF,651,105 > $IMADC,20,9CC,689,AE9,9E8,650,112 > > and, the program looks working fine. (need more tests....) > > Does this make sence? > Do you know why empty lines were added? > > Thanks > eaton > > > --- On *Mon, 3/30/09, Dave Hylands /<dhy...@gm...>/* wrote: > > > From: Dave Hylands <dhy...@gm...> > Subject: Re: [Gumstix-users] Gumstix verdex pro ttyS2 issue > To: "General mailing list for gumstix users." > <gum...@li...> > Date: Monday, March 30, 2009, 1:07 AM > > Hi eaton, > > > However, if I use readIMU(), then it gets only the first sentence > correctly, > > then rest of sentences are read as empty. > > (First sentence is read correctly always, but next sentences not...) > > > > Could someone tell me what might be the problem? > > I don't see anything obvious. > > fgets will leave the \n in the buffer that's read (and perhaps a \r as > well - I don't recall if NMEA sends those or not). I'm not sure how > this impacts your parsing code, since you didn't show us that. > > Were you expecting readIMU to process one sentence per call? > > -- > Dave Hylands > Shuswap, BC, Canada > http://www.DaveHylands.com/ > > ------------------------------------------------------------------------------ > _______________________________________________ > gumstix-users mailing list > gum...@li... > </mc/compose?to=gum...@li...> > https://lists.sourceforge.net/lists/listinfo/gumstix-users > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > > > ------------------------------------------------------------------------ > > _______________________________________________ > gumstix-users mailing list > gum...@li... > https://lists.sourceforge.net/lists/listinfo/gumstix-users |