Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: C++ Serial Communication

  1. C++ Serial Communication

    So, I have a somewhat complete interface for communicating with my Roomba in python, but I want to write it in C++ because that's what all my CS classes are in, so I would like to work on it as I learn new C++ concepts.

    I am a little puzzled on how to get started though.

    Here is what I got in python. How do I do this in C++?

    Code:
    def connect(self, port, baud=115200):
            self.ser = serial.Serial(port-1, baud, timeout=1)
            self.ser.setRTS(0)
            self.ser.flushOutput()
    In python I just use the pySerial module and poof its connected with that code.

    Do I need an additional library to do serial communication in C++? Or is there some built in way of doing serial comm?

    Thanks
    J

  2. #2
    Join Date
    May 2008
    Posts
    2,228
    Images
    155
    Rep Power
    131

    Re: C++ Serial Communication

    There is a reason people use python -- somebody did all the hard work for you in creating pySerial.

    -Fergs

  3. Re: C++ Serial Communication

    Yeah, I am just hoping someone did all the hard work in C++ too. I just cant find it :P

  4. #4
    Join Date
    May 2008
    Location
    TN
    Posts
    853
    Images
    99
    Rep Power
    77

    Re: C++ Serial Communication

    I believe you have to treat the serial port as a file object. I've never done this on a computer though.

    [edit] maybe this will help:
    http://www.codeproject.com/KB/system/serial.aspx
    "If A is a success in life, then A equals x plus y plus z. Work is x; y is play; and z is keeping your mouth shut."
    -
    Einstein

    Don't be a HelpVampire

  5. #5
    Join Date
    Apr 2008
    Location
    Sacramento, CA, USA Area
    Posts
    5,341
    Rep Power
    181

    Re: C++ Serial Communication

    Just to be clear:

    C++ doesn't do serial - ANSI doesn't define a standard method of getting to the ports. Libraries do serial. So - what C++ are we talking about here? It's going to be different (sometimes wildly different) depending upon what compiler/environment/libraries you're using.
    I Void Warranties�

  6. Re: C++ Serial Communication

    In the ideal world, it works on Windows and my Acer Aspire One net book running Ubuntu.

    In reality, I mainly want it to work on Windows XP with Visual Studio 2008. If I need a lot more than that to get started, I suppose Ill just stick to python for the time being.

  7. #7
    Join Date
    Apr 2008
    Location
    Sacramento, CA, USA Area
    Posts
    5,341
    Rep Power
    181

    Re: C++ Serial Communication

    Of course, it's possible to get it to compile under both - just a whole lot of ifdef's.

    Tomorrow night (if no one beats me to it), I'll knock out some MS VS C++ for you for that task.
    I Void Warranties�

  8. Re: C++ Serial Communication

    Thanks a bunch! I would usually just wait till we learn it in class, but I am not sure we ever well. All the electrical engineering kids get to learn it, but not the CS kids.

  9. #9
    Join Date
    Apr 2008
    Location
    Sacramento, CA, USA Area
    Posts
    5,341
    Rep Power
    181

    Re: C++ Serial Communication

    Before I get all into this - have you looked at this: http://www.codeguru.com/cpp/i-n/netw...icle.php/c2503
    I Void Warranties�

  10. Re: C++ Serial Communication

    I forgot about that. I looked at that awhile ago, and it seemed like it should fit the bill but it wouldn't compile.

    The compiler had a bunch of problems with the decelerations that were in all caps like BOOL and DWORD.

    I tried to look up what those meant and that lead me to the Microsoft development site where I promptly got very lost.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. "ALMower" [was: Robotic Lawn Mower]
    By revoltage in forum Robotics General Discussion
    Replies: 363
    Last Post: 07-19-2009, 08:06 AM
  2. Question(s) C++, C Serial or USB communications help
    By Eric in forum Software and Programming
    Replies: 5
    Last Post: 10-15-2008, 02:05 PM
  3. Kondo web page translated.
    By Droid Works in forum Humanoids, Walkers & Crawlers
    Replies: 4
    Last Post: 10-06-2007, 05:49 PM

Posting Permissions

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