Click here to Skip to main content
Licence 
First Posted 13 Feb 2002
Views 138,638
Bookmarked 57 times

Serial communication for Win32 with modem support

By | 13 Feb 2002 | Article
Free source code (C++) for WIN32 serial communication. Manages also a modem. Example project provided.

Introduction

Here it is. Finally, I think I've reached the final step in serial communication programmation on Win32. This new version (V2.0) is much more structured than the previous one. I can handle either 1-byte exchange (like a UART) or arrays of byte. The application is 100% event-driven on the user side (the object itself is using one thread). And more important of all, this new version handles also modem specific signals like CD and RI. CD allows you to know if the modem is connected (to the other modem) or if you are in command mode. And RI is the RING Indicator. With this version, you can make whatever you like (like for example implementing PPP or simulating a microcontroller's UART)

Links

Download

I've removed the "non event-driven" version since I believe it is not so useful. Anyway, you can still download the V1.x package here (serial.zip). The version 2 can be downloaded here serial2.zip.

Feedback

I hope that this version will be the ultimate library for the serial port. I hope to receive your comments about it. Since the version 1.x was downloaded more than 4000 times in 8 months, I hope this one will be even better. If you like this software, please let me know, 'cause I like to know what people think of my work.

Bye

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Thierry Schneider

Web Developer

Switzerland Switzerland

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Jokehy086syi1z Pinsussvj73tzst7r12:48 14 Dec '07  
GeneralHELP on "Pin: "DTR_INACTIVE" problem Pinmemberjames luo8:12 9 Jun '07  
GeneralRe: HELP on "Pin: "DTR_INACTIVE" problem PinmemberThierry Schneider19:56 11 Jun '07  
GeneralRe: HELP on "Pin: "DTR_INACTIVE" problem Pinmemberjames luo14:38 12 Jun '07  
QuestionHow can i simulate pcAnyWhere Remote Host? PinmemberYe lai Fang20:23 18 Apr '07  
AnswerRe: How can i simulate pcAnyWhere Remote Host? PinmemberThierry Schneider6:26 20 Apr '07  
GeneralRe: How can i simulate pcAnyWhere Remote Host? PinmemberYe lai Fang21:31 22 Apr '07  
Questionhow can i communicate modem through serial port PinmemberMember #37697463:28 28 Jan '07  
AnswerRe: how can i communicate modem through serial port PinmemberThierry Schneider21:54 3 Feb '07  
AnswerRe: how can i communicate modem through serial port Pinmemberlarrykind6:42 11 Mar '07  
GeneralRe: how can i communicate modem through serial port PinmemberLuiz Salamon16:58 18 Mar '07  
this is dial communication :
 
Port opened by process "svchost.exe" (PID: 1916)
 
Request: 13/3/2007 23:03:57.75264 (+1995.9063 seconds)
 
41 54 0D AT.
 
Answer: 13/3/2007 23:03:57.75264 (+0.0000 seconds)
 
41 54 0D 0D 0A 4F 4B 0D 0A AT...OK..
 
Request: 13/3/2007 23:03:57.89364 (+0.0156 seconds)
 
41 54 45 30 56 31 0D ATE0V1.
 
Answer: 13/3/2007 23:03:57.89364 (+0.0000 seconds)
 
41 54 45 30 56 31 0D 0D 0A 4F 4B 0D 0A ATE0V1...OK..
 
Request: 13/3/2007 23:03:57.03464 (+0.0156 seconds)
 
41 54 0D AT.
 
Answer: 13/3/2007 23:03:57.15964 (+0.1250 seconds)
 
0D 0A 4F 4B 0D 0A ..OK..
 
Request: 13/3/2007 23:03:57.17464 (+0.0156 seconds)
 
41 54 53 30 3D 30 0D ATS0=0.
 
Answer: 13/3/2007 23:03:57.29964 (+0.1250 seconds)
 
0D 0A 4F 4B 0D 0A ..OK..
 
Request: 13/3/2007 23:03:57.31564 (+0.0156 seconds)
 
41 54 0D AT.
 
Answer: 13/3/2007 23:03:58.44064 (+0.1250 seconds)
 
0D 0A 4F 4B 0D 0A ..OK..
 
Request: 13/3/2007 23:03:58.45664 (+0.0156 seconds)
 
41 54 45 30 56 31 0D ATE0V1.
 
Answer: 13/3/2007 23:03:58.58164 (+0.1250 seconds)
 
0D 0A 4F 4B 0D 0A ..OK..
 
Request: 13/3/2007 23:03:58.59664 (+0.0156 seconds)
 
41 54 0D AT.
 
Answer: 13/3/2007 23:03:58.72164 (+0.1250 seconds)
 
0D 0A 4F 4B 0D 0A ..OK..
 
Request: 13/3/2007 23:03:58.73764 (+0.0156 seconds)
 
41 54 44 54 33 34 36 32 39 38 30 33 0D ATDT34629803. <-- telef. number
 
Answer: 13/3/2007 23:04:30.51864 (+31.7813 seconds)
 
0D 0A 43 4F 4E 4E 45 43 54 20 32 34 30 30 30 2F ..CONNECT 24000/
41 52 51 2F 56 33 34 2F ARQ/V34/
 
Request: 13/3/2007 23:04:30.56564 (+0.0469 seconds)
 
7E FF 7D 23 C0 21 7D 21 7D 20 7D 20 7D 37 7D 22 ~ÿ}#À!}!} } }7}"
7D 26 7D 20 7D 20 7D 20 7D 20 7D 25 7D 26 56 9B }&} } } } }%}&V›
71 B5 7D 27 7D 22 7D 28 7D 22 7D 2D 7D 23 7D 26 qµ}'}"}(}"}-}#}&
7D 25 45 7E }%E~
 
Answer: 13/3/2007 23:04:31.67464 (+1.1094 seconds)
 
7E FF 7D 23 C0 21 7D 21 7D 21 7D 20 7D 3F 7D 21 ~ÿ}#À!}!}!} }?}!
7D 24 7D 25 F4 7D 22 7D 26 7D 20 7D 2A 7D 20 7D }$}%ô}"}&} }*} }
20 7D 23 7D 24 C0 23 7D 27 7D 22 7D 28 7D 22 7D }#}$À#}'}"}(}"}
33 7D 29 7D 23 7D 20 D0 52 7D 23 92 70 D8 72 7E 3})}#} ÐR}#’pØr~
 
Request: 13/3/2007 23:04:31.69064 (+0.0000 seconds)
 
7E FF 7D 23 C0 21 7D 24 7D 21 7D 20 7D 2D 7D 33 ~ÿ}#À!}$}!} }-}3
7D 29 7D 23 7D 20 D0 52 7D 23 92 70 81 4E 7E })}#} ÐR}#’pN~
 
Answer: 13/3/2007 23:04:31.69064 (+0.0000 seconds)
 
7E FF 7D 23 C0 21 7D 24 7D 20 7D 20 7D 27 7D 2D ~ÿ}#À!}$} } }'}-
7D 23 7D 26 AD 36 7E }#}&­6~
 
Request: 13/3/2007 23:04:31.69064 (+0.0000 seconds)
 
7E FF 7D 23 C0 21 7D 21 7D 21 7D 20 7D 34 7D 22 ~ÿ}#À!}!}!} }4}"
7D 26 7D 20 7D 20 7D 20 7D 20 7D 25 7D 26 56 9B }&} } } } }%}&V›
71 B5 7D 27 7D 22 7D 28 7D 22 BB CE 7E qµ}'}"}(}"»Î~
 
Answer: 13/3/2007 23:04:31.81564 (+0.1250 seconds)
 
7E FF 7D 23 C0 21 7D 21 7D 22 7D 20 7D 36 7D 21 ~ÿ}#À!}!}"} }6}!
7D 24 7D 25 F4 7D 22 7D 26 7D 20 7D 2A 7D 20 7D }$}%ô}"}&} }*} }
20 7D 23 7D 24 C0 23 7D 27 7D 22 7D 28 7D 22 88 }#}$À#}'}"}(}"ˆ
75 7E u~
 
Request: 13/3/2007 23:04:31.83164 (+0.0000 seconds)
 
7E FF 7D 23 C0 21 7D 22 7D 22 7D 20 7D 36 7D 21 ~ÿ}#À!}"}"} }6}!
7D 24 7D 25 F4 7D 22 7D 26 7D 20 7D 2A 7D 20 7D }$}%ô}"}&} }*} }
20 7D 23 7D 24 C0 23 7D 27 7D 22 7D 28 7D 22 7D }#}$À#}'}"}(}"}
5E 86 7E ^†~
 
Answer: 13/3/2007 23:04:31.84664 (+0.0156 seconds)
 
7E FF 7D 23 C0 21 7D 22 7D 21 7D 20 7D 34 7D 22 ~ÿ}#À!}"}!} }4}"
7D 26 7D 20 7D 20 7D 20 7D 20 7D 25 7D 26 56 9B }&} } } } }%}&V›
71 B5 7D 27 7D 22 7D 28 7D 22 50 A7 7E qµ}'}"}(}"P§~
 
Request: 13/3/2007 23:04:31.84664 (+0.0000 seconds)
 
....
 
Data captured using Serial Monitor, http://www.hhdsoftware.com.
 

GeneralOne correction PinmemberJJ DBT10:41 2 Aug '06  
Generalfax Pinmemberthachvv1816:06 25 Nov '04  
Questionhow can I use this code for two or more ports PinmemberGF Hou4:27 30 Oct '04  
QuestionCan I add this source code to an ATL project? Pinmembergentleboyzhang16:37 25 Oct '04  
AnswerRe: Can I add this source code to an ATL project? Pinmemberpaulains9:33 7 Dec '04  
GeneralRe: Can I add this source code to an ATL project? PinmemberRocom23:58 8 Jun '05  
GeneralPerfect Work! PinsussCheer J. Chen17:51 22 Mar '04  
QuestionWhat about sending HexData PinmemberMessnerEW3:10 18 Mar '04  
AnswerRe: What about sending HexData PinmemberThierry Schneider21:19 22 Mar '04  
GeneralSimple Serial PinmemberJa2Yap21:09 11 Feb '04  
QuestionSounds useful, but how can caller know the size it would receive? Pinmemberjason lue9:05 7 May '03  
AnswerRe: Sounds useful, but how can caller know the size it would receive? Pinmemberthierrydollar23:49 7 May '03  
GeneralRe: Sounds useful, but how can caller know the size it would receive? Pinsussjason lue13:43 10 May '03  
GeneralRe: Sounds useful, but how can caller know the size it would receive? Pinmemberthierrydollar20:51 11 May '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120529.1 | Last Updated 14 Feb 2002
Article Copyright 2002 by Thierry Schneider
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid