Home Page Forums Raspberry Pi Shields Proper way to read GPS data via c code? (EC25-A)


This topic contains 1 reply, has 2 voices, and was last updated by  Saeed 7 months, 1 week ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #37270


    I apologize I’m a beginner.

    Below is my (c++) code. I am not sure how to check if “/dev/ttyUSB1” has data. So I figure I should always turn on data then read. I turn it off at the end of the binary.

    If I run it once it seems to work fine. I read 24+ bytes of data followed by 1byte on second read then close. I suspect I’m making several mistakes

    1. If I read twice from ttyUSB1 too quickly is that bad?
    2. If I write to ttyUSB2 is that bad?
    3. Not sure if I should call fsync after my writes

    Anyway the end result is, first run data works, second run (or third) I seem to lose ttyUSB 1 and 2. I suspect the first run crashes it.

    I’d like to eventually detect if ttyUSB1 stops sending data. I’m not sure if I should use select on ttyUSB1 file descriptor or if I have to do something with multi threads


Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.