Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Serial Communication in C++ (http://www.chiefdelphi.com/forums/showthread.php?t=16759)

Adam Shapiro 20-01-2003 18:33

Serial Communication in C++
 
I'm having trouble finding resources on serial communication with c++ for the 3d dashboard program. I have finished coding the interface but I need the serial comm part... I heard that you might need to use MFC but I wasn't sure. Is there another way without having to create an MFC-based app?

Raven_Writer 20-01-2003 19:23

Re: Serial Communication in C++
 
Quote:

Originally posted by Adam Shapiro
I'm having trouble finding resources on serial communication with c++ for the 3d dashboard program. I have finished coding the interface but I need the serial comm part... I heard that you might need to use MFC but I wasn't sure. Is there another way without having to create an MFC-based app?
http://www.robbayer.com - just go to the how-to link, and there is a tutorial on how to get a serial communication set up w/o using MFC.

Adam Shapiro 20-01-2003 19:58

Wow, I should have checked there first... thanks.

Raven_Writer 20-01-2003 20:02

Quote:

Originally posted by Adam Shapiro
Wow, I should have checked there first... thanks.
Yup, it helps if you download RoboCon (found on his site) also...it comes with some nifty functions and all.

rbayer 20-01-2003 20:32

A word of warning: ignore everything it says about mult-threading unless you know what you are doing. It's messy and can lead to some insanely difficult bugs.

Instead, follow RoboCon's example, as it is not multi-threaded and works just fine. Just make sure you are looking at the RoboCon source, and not ConSample as ConSample is MFC, but RoboCon is not.

--Rob

Raven_Writer 20-01-2003 20:37

And MFC is confusing if you haven't really done any Win32 Programming (to me it was anyways). Multi-threading doesn't work all that well w/ Win32 anyhow.

Adam Shapiro 20-01-2003 20:52

I've done a bit of MFC and Win32 but I didn't really want to add MFC to the app if I could avoid it. It is complex enough having to use Direct3D... I'll try RoboCon to see how it works. Hopefully I can get this program working soon so I can upload the code to our team website (which I need to finish too...).

Kevin Watson 20-01-2003 23:40

I've got a low overhead example of how to implement a software-based state machine that properly handles the dashboard data stream. If it'll help, you can find it on this page:

http://www.cvhsrobotics.org/resources.htm

-Kevin

Ryan Meador 21-01-2003 12:49

I've used my serial port to communicate with my Stamp- and PIC-controlled minions many times. The code in C++ is very easy. It's treated as a file. Just open "COMX" as the file and set a few permissions (where X is the port number)... its all in the MSDN serial communication sample program.

hPort = CreateFile ("COM4", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

Then you'll want to look up the DCB structure to set all the cool baud rate, parity, and stop bit options. The COMMTIMEOUTS struct might help you out too. I've got a program that uses my serial port to send data (via my very own cobbled-together RS-232 radio transmitter) to one of my PIC robots. PM me and I'll send you the code.


All times are GMT -5. The time now is 07:31.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi