CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2012
    Location
    Chatsworth
    Posts
    2

    Windows/C++/COM Port problem

    Hi,

    First, sorry, I don't know much software, so please excuse my posting, if this is in the wrong spot. I have a consultant doing a meter program using MS Visual C++ 2010, and he is having trouble fixing a bug, so I thought I would see if anybody has a suggestion.

    The application connects to a com port (115200, no handshaking), and displays an angle. The data can come quite fast at times. He occasionally misses the last sets of values (the last value sent is the most important one). He claims it is something to do with Windows.

    When I use Hyperterm, it never fails, so I seem to think it shouldn't be a problem.

    Any comments/suggestions?

    Thanks,

    Mark

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Windows/C++/COM Port problem

    Well, the only possible comment is that the "application connects to a com port" has some bugs.
    Since we have no idea how this application was supposed to be implemented and worked, it is no possible to say more...
    Victor Nijegorodov

  3. #3
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Windows/C++/COM Port problem

    I would say that the application absolutely has some bug. If I don't remember wrong the serial port buffer is about 1000 bytes in Windows so in a modern PC and at that quite slow bitrate it shouldn't be an issue to handle the received data. I've done applications with 10 Mbit / seconds serial communication (serial port on USB) without having any issues so claiming it has something to do with Windows is low.

    Just remembered... if you run windows 3.11 on for instance something like a 386/486 then 115200 isn't supported. I can recommend one that I know works at that rate though...
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  4. #4
    Join Date
    Jul 2012
    Location
    Chatsworth
    Posts
    2

    Re: Windows/C++/COM Port problem

    The data that is comig in is an ASCII angle, always the same # of characters (8), the last 2 are CR and LF. i.e. +179.0 CR LF. Is there a way to attach the SerialPort.cpp file here? I have no issues with anybody seeing it.

    I don't know how hyperterm works. I thought maybe since it was older, it works different than a program written with MSVC++.

    Thanks again,

    Mark

  5. #5
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Windows/C++/COM Port problem

    In the advanced editor there is an attach button. It might though that even if SerialPort.cpp is alright the characters are lost in some other parts of the code.

    One way of test that is to use a serial port class that is used by many others (i.e. many testers and eyes that search for bugs). There are a lot of such classes on the net and as an example http://www.naughter.com/serialport.html
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured