Help with Serial Communication - Please!
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 21

Thread: Help with Serial Communication - Please!

  1. #1
    Join Date
    Apr 2012
    Posts
    18

    Question Help with Serial Communication - Please!

    Hi Everyone, happy to join the forums here!
    I'm having one hell of a time with Serial Communication in VC++ (MultiThreading /Win32)

    Here's the issue...
    I have a USB Serial device that is reading a gyroscope and sending out Text to COM8 like this:

    !ANG: 0.33, 0.22, 0.66
    !ANG: 0.33, 0.22, 0.66
    etc....

    The data is flying into that COM port perfectly... I've gone through the Tutorial to make a Win32 CLR Application and that works perfectly too.

    The problem is, I need to make this work with a Win32 /MT Application - When I try to tell VC++ to use the Common Language Library it says:
    Command line error D8016: '/clr' and '/MT' command-line options are incompatible

    When I use ReadFile(blah,blah,blaH) All I get is the bytes... I need the Text that it is sending!

    I will seriously PayPal someone $10 for a beer if they can help me get the COM Port Data/Text working!

    Cheers,
    C

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,071

    Re: Help with Serial Communication - Please!

    When I use ReadFile(blah,blah,blaH) All I get is the bytes... I need the Text that it is sending!
    FYI any text is bytes. So, what's your problem?
    Best regards,
    Igor

  3. #3
    Join Date
    Jul 2002
    Posts
    2,526

    Re: Help with Serial Communication - Please!

    '/clr' and '/MT' command-line options are incompatible. So, just change one of them. If you need /clr (BTW, why?), replace /MT with another value, compatible with /clr.

  4. #4
    Join Date
    Apr 2012
    Posts
    18

    Re: Help with Serial Communication - Please!

    Hi Guys, Sorry I should be more specific...

    When I pass the buffer date into a Trace so I can see what it's doiing, it outputs all these garbage characters, not the proper text... I can read COM8 Inside of HyperTerminal properly so I know I have all the Baud/Settings correct...

    It's pretty **** frustrating to have it work so easily inside the Win32/CLR Program, and have to use all this API Crap from 1995 to try and work with this

  5. #5
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Help with Serial Communication - Please!

    I can read COM8 Inside of HyperTerminal properly so I know I have all the Baud/Settings correct...
    You have the settings correct in HyperTerminal, but are they correct on your connection ? Each program can/has to set their own settings.

  6. #6
    Join Date
    Apr 2012
    Posts
    18

    Re: Help with Serial Communication - Please!

    Big help on this forum....

  7. #7
    Join Date
    Apr 2012
    Posts
    18

    Re: Help with Serial Communication - Please!

    Can anyone point me to a full example please, not the stupid MSDN article that only has Pieces...

  8. #8
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,642

    Re: Help with Serial Communication - Please!

    Here's a full example code. Either use at it is or study it to find out where you go wrong 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
    http://www.microsoft.com/visualstudio/eng/downloads

  9. #9
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,071

    Re: Help with Serial Communication - Please!

    Quote Originally Posted by ChadReitsma View Post
    Big help on this forum....
    Big help always starts with decent problem explanation... You're still on your road, we're waiting when you start explaining, not just complaining.
    Best regards,
    Igor

  10. #10
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,553

    Re: Help with Serial Communication - Please!

    Quote Originally Posted by ChadReitsma View Post
    ... I've gone through the Tutorial to make a Win32 CLR Application and that works perfectly too.
    As I understand it, there is no such thing as a "Win32 CLR Application". A Win32 application is a compiled application (probably but not necessarily written in C or C++) whose output is machine code. A CLR application involves the Common Language Runtime which is a .NET Runtime, whose output is an Intermediate Language (or IL) that can be executed by the .NET Framework. The application is probably (but not necessarily) written in languages like VB.NET, C#, Managed C++, etc.

    From the foregoing, it can be understood immediately why /MT is not compliant with /clr. "/MT" would result in use of the static version of the (multi-threaded) run-time library, and a static linking to the run-time library is completely inconsistent with CLR's output of an intermediate language for execution by the .NET framework.

    What are you trying to accomplish with the /MT switch, and why do you think you need it?

    Perhaps it also would be helpful for you to post a link to the "tutorial" that you followed.

    Finally, if you really want a CLR application, then this is the wrong forum.

    Mike

    PS: Quote from ChadReitsma: "Big help on this forum.... "

    Turn off the sarcasm. Every single person here is posting because they want to help and because they're highly motivated to do so. If you think you're not getting the help you want, it's almost certainly not due to lack of trying on the part of those posting replies.

  11. #11
    Join Date
    Apr 2012
    Posts
    18

    Re: Help with Serial Communication - Please!

    Hi guys, Sorry for the sarcasm - it's just really frustrating.
    I do appreciate the help.

    I have to use the /MT option because the application I am modifying (Half-Life 2) is coded that way - turning it off creates a ton of errors when I try to compile.

    I can't use the Naughter Class as it uses MFC which isn't included in VC++ Express 2010 ... I guess I should just go grab a real copy of VC++.
    I'll try looking at the WinAPI CreateFile stuff again... I think that's the best bet.


    Thanks again.

  12. #12
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,642

    Re: Help with Serial Communication - Please!

    Ok but you can review how the code is written and mimic it in plain Win32 APIs.

    Is this http://msdn.microsoft.com/en-us/library/ms810467.aspx the stupid MSDN article that only has pieces?
    Last edited by S_M_A; April 2nd, 2012 at 04:01 PM.
    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
    http://www.microsoft.com/visualstudio/eng/downloads

  13. #13
    Join Date
    Apr 2012
    Posts
    18

    Re: Help with Serial Communication - Please!

    Yep, I've tried using their examples but it doesn't seem to read the Port correctly - I'll keep trying though - thanks for the tips!

  14. #14
    Join Date
    Apr 2012
    Posts
    18

    Re: Help with Serial Communication - Please!

    Got it!!!

    I found a few examples using CSerial... but I was missing this serial.lib, built the library separately, added it to my project and it worked!
    For anyone that just needs a quick Copy/Paste Serial Communications Example, here is the header file, Library and .CPP <attached>

    Just wanted to say thanks again for the help / push in the right direction.
    Attached Files Attached Files

  15. #15
    Join Date
    Apr 2012
    Posts
    18

    Re: Help with Serial Communication - Please!

    Me again... was wondering if someone knew a really easy way to convert this output from the buffer

    0x0018e4b4 "!ANG:0.54,2.08,-178.62
    !ANG:0.43,2.05,-178.64
    !ANG:0.44,1.96,-178.65
    "
    How can I strip out everything inside of the "s I don't need the 0x0018e4b4 etc...

    Thanks

Page 1 of 2 12 LastLast

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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center