Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Mobile
  4. Setting Serial Port Buffer Size

Setting Serial Port Buffer Size

Scheduled Pinned Locked Moved Mobile
c++csshelptutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cbusgut
    wrote on last edited by
    #1

    Hello All I am developing in eVC++ an application that reads from the serial port the binary data sent by a GPS receiver (Sirf protocol) The way of reading is the typical one, with a thread as shown in the tty example (Pocket PC 2002). Every time a character arrives, I do more or less the following: BOOL bReturn = TRUE; DWORD dwCodsError, dwNumBytes, dwNumBytesRead; COMSTAT ComState; unsigned char BufferRead[5600]; ClearCommError(m_hPort, &dwCodsError, &ComState); dwNumBytes=ComState.cbInQue; if(dwNumBytes>0) { bReturn=ReadFile(m_hPort, BufferRead, dwNumBytes, &NumBytesRead, NULL); } The problem is that the application does a lot of work, and from time to time, when the application is busiest, I lose some of the messages of the reveiver. In such cases, I have notice that cbInQue value is 2047, and that it never exceeds that number. I guess that is the maximum value of the Port Serial buffer-in. That should be the reason why subsequent messages are not stored in the buffer. At present I am trying not to overload so much the application, but I would like to know if it is possible to change the buffer-in size. In this way, I would not lose so many messages. I have tried with: SetupComm(m_hPort,BUFFER_IN_SIZE,BUFFER_OUT_SIZE); with BUFFER_IN_SIZE = 4095 and BUFFER_OUT_SIZE = 2047, but it doesn't work. Any Suggestions? Thanks in Advance PD: I am using the Emtac PCMCIA GPS receiver (just in case it was a problem with the driver) Carlos

    D 1 Reply Last reply
    0
    • C cbusgut

      Hello All I am developing in eVC++ an application that reads from the serial port the binary data sent by a GPS receiver (Sirf protocol) The way of reading is the typical one, with a thread as shown in the tty example (Pocket PC 2002). Every time a character arrives, I do more or less the following: BOOL bReturn = TRUE; DWORD dwCodsError, dwNumBytes, dwNumBytesRead; COMSTAT ComState; unsigned char BufferRead[5600]; ClearCommError(m_hPort, &dwCodsError, &ComState); dwNumBytes=ComState.cbInQue; if(dwNumBytes>0) { bReturn=ReadFile(m_hPort, BufferRead, dwNumBytes, &NumBytesRead, NULL); } The problem is that the application does a lot of work, and from time to time, when the application is busiest, I lose some of the messages of the reveiver. In such cases, I have notice that cbInQue value is 2047, and that it never exceeds that number. I guess that is the maximum value of the Port Serial buffer-in. That should be the reason why subsequent messages are not stored in the buffer. At present I am trying not to overload so much the application, but I would like to know if it is possible to change the buffer-in size. In this way, I would not lose so many messages. I have tried with: SetupComm(m_hPort,BUFFER_IN_SIZE,BUFFER_OUT_SIZE); with BUFFER_IN_SIZE = 4095 and BUFFER_OUT_SIZE = 2047, but it doesn't work. Any Suggestions? Thanks in Advance PD: I am using the Emtac PCMCIA GPS receiver (just in case it was a problem with the driver) Carlos

      D Offline
      D Offline
      Daniel Strigl
      wrote on last edited by
      #2

      Try to increase the priority of the reading thread! Daniel ;) --------------------------- Never change a running system!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups