?
Solved

C Program for Serial Communication in Windows 2000

Posted on 2003-03-11
9
Medium Priority
?
634 Views
Last Modified: 2010-04-15
hi,
   i'm developing an API which has to collect data from another running program and has to send to com port in Windows 2000 platform, as far as collection data is working fine,but the COM port communication it remains a "?". i'm using VC++ for compilation the program is in C anyways. Can anyone help me in this regard pls i'm in gr8 trouble. at present i'm using VB for the Com port interface alone but the doubt is whether the program could run at a strech of 24 hours a day rarely/never shut down. by the way can anyone tell wht is the "CPU Time" in "Process" in "Task Manager" coz the VB program is adding up time second by second but others aren't.

Thanx in advance

0
Comment
Question by:presly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 8110820
Check out http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp ("Serial Communications in Win32") - IMHO the best article available on this issue.
0
 
LVL 2

Assisted Solution

by:honey_hamster
honey_hamster earned 500 total points
ID: 8112979
If you use VB for accessing the serial port, then you'll need to use the MSComm Control.  For receiving data, use the 'OnComm' callback function.  For transmitting data, use the 'Output' method.

If you use VC for accessing the serial port, then you'll need to use at least the following API functions:
CreateFile()
GetCommState()
SetCommState()
WriteFile()
ReadFile()
If you go to msdn.microsoft.com and then search for any of the above functions, you'll get a description of the function and its parameters, etc.  Links will take you to related useful functions.
0
 
LVL 6

Expert Comment

by:zebada
ID: 8114385
This package I wrote, has an extremely simple COM port interface dll (with full source code).
You can either use the dll "as is" or pull the functions out and use them directly in your own program.

One of the functions in the dll deals with checksums, that is not part of the "normal" com routines it is specific to the application using the dll - so just ignore it.

http://www.starrperformance.com.au/efilivev4/downloads/Probe1_6.zip
See the project called "synchcom", synchcom.h and synchcom.c

Regards
Paul
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:havman56
ID: 8126035
presly

i have written serial comm using files concept.
 it is working fine for me.
if u need of my program send mail to micro_mangal@yahoo.com

since the program is huge i could not put it here !!!!
0
 

Author Comment

by:presly
ID: 8126350
hi all Thanks for the response .. but i'm trying to include the C coding in the existing VC workspace

i'm trying out Probe.zip

i'm new for VC(i know to use the VC editor and to compile the C files but nothing more than that ) how do i use the
CreateFile()
GetCommState()
SetCommState()
WriteFile()
ReadFile()
Methods in my existing C Api Program can.

I'm using VB comm Control Which i'm familiar with but i'm afraid of the persistance of the VB exe.
0
 
LVL 2

Expert Comment

by:honey_hamster
ID: 8127753
To learn how to use those functions, go to Microsoft's MSDN website.  First follow the link provided by jkl to get an overview.  After that, type the function names into the little Search textbox in the top left corner, and that will take you to an explanation of the function.

Also, what do you mean by 'afraid of the persistence of the VB exe'?
0
 
LVL 86

Expert Comment

by:jkr
ID: 8127785
>>how do i use the [Win32API] Methods in my existing C Api Program can.

Have you taken a look at the article I posted?
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10121020
Nothing has happened on this question in more than 10 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
split points between jkr and honey_hamster.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question