Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 636
  • Last Modified:

C Program for Serial Communication in Windows 2000

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
presly
Asked:
presly
2 Solutions
 
jkrCommented:
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
 
honey_hamsterCommented:
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
 
zebadaCommented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
havman56Commented:
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
 
preslyAuthor Commented:
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
 
honey_hamsterCommented:
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
 
jkrCommented:
>>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
 
jmcgOwnerCommented:
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

Industry Leaders: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now