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. General Programming
  3. Visual Basic
  4. MSComm problems

MSComm problems

Scheduled Pinned Locked Moved Visual Basic
debugginghelpquestion
1 Posts 1 Posters 1 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.
  • N Offline
    N Offline
    NetDave
    wrote on last edited by
    #1

    Hi Guys, I have a baffling problem with the MSComm control in a VB6 app I'm writing. I'm trying to send a binary command out the serial port, then read a binary response. The command is 6 bytes and the response is 17. When I single-step over the .Output statement, everything works just fine. But if I set the breakpoint after the .Output statement, i.e. I'm executing at full throttle through the .Output, the received data is mostly lost. I do wait until .OutBufferCount goes to zero and DoEvents to make sure any messages are getting processed. Another strange symptom is that I'm not seeing any OnComm events. I've set .RThreshold = 1 to try to catch the response data byte by byte, but not a blip from the OnComm event handler. Here's the snippet of initialization code I'm using:

    With MSComm1
        .CommPort = Port
        .Settings = Baud & "," & Parity & "," \_
                    & DataBits & "," & StopBits
        .RTSEnable = True
        .DTREnable = True
        'read entire buffer when Input is used.
        .InputLen = 0
        'we're dealing with binary data
        .InputMode = comInputModeBinary
        .RThreshold = 1
        .PortOpen = True
    End With
    

    And here's what I'm doing in the command/response code:

    'everything works fine if I put a breakpoint on the following
    'line and single-step over the .Output statement
    MSComm1.Output = cmdGetData
    Do Until MSComm1.OutBufferCount = 0
        DoEvents
    Loop
    'this hangs because we never get the full 17 bytes of data
    While MSComm1.InBufferCount < 17
        DoEvents
    Wend
    

    Lastly, everything seems fine when using ASCII (string) data, so I'm wondering if there's something peculiar about binary. Thanks in advance for any insights. -- Dave QRZ? de WAØTTN

    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