PDA

View Full Version : Serial communication



RobRoy
December 5th, 2002, 12:58 PM
My plugin need to read the serial port. I never work with controlling serial port so I'm using Mark Fiechtner serial plugin as example. I understand how to open, configure and close the port. But I don't understant how I could detect if I receive something on the serial port. I don't want to read the serial port all the time to see if something change on the serial port. I know in VB if I use mscomm32.ocx that a event is send every time something happen on the port, but whit VC++ ???


Thank!

Mark F
December 5th, 2002, 01:39 PM
The Serial plugin starts a separate thread to wait for serial events. It registers the events for which it wants notification using SetCommMask() and uses a combination of WaitCommEvent() (with overlapped IO) and WaitForMultipleObjects() to block until an event occurs.

Look in the device.cpp file for the ComThread() routine for the exact code.

When a serial event is signaled, the code calls the CheckEvents() routine to decide what to do.

RobRoy
December 5th, 2002, 11:34 PM
Mark I would like your opinion about mscomm32.ocx . I create a MFC application using this ocx and that was pretty easy to control the serial port(for someone like me, who know less in VC++) and that was working good. With that component I will save a lot of time. But I can’t make it work with my plugin, the component create always fail.

First I will like to know if you already use mscomm32.ocx and if you have a solution to make it work with my plugin.

Second do you thing that a good idea using that component for my plugin or I should use your way to control the serial port? I know that if I use the component every computer that gona want to use my plugin will need to register mscomm32.ocx :(

Ron
December 6th, 2002, 01:35 AM
If you want to use activex controls in a girder plugin you'll have to do a CoInitialize, maybe that is missing ?

Mark F
December 6th, 2002, 02:46 AM
I don't use mscomm32.ocx for my plugins as you can see from the available code. See Ron's post about the CoInitialize() call to make it work.

If it will make your life easier, use it. :) You understand the biggest drawbacks which I see as:
obtain it from somewhere
register it on every computer

Providing a link to the file and explaining the registration process in the readme file MIGHT help to reduce the support questions.