C++ serial comunication help

Thread Starter

dreamcatcher

Joined Jan 5, 2010
27
Hi,

I'm a beguiner using C++ and I want to write a program that communicate with a PIC microcontroller via serial port (com1).
please can you help me to find tutorials about:

  • using the serial port with C++
  • tutorial about windows form application using C++
Thank you for your help in advance
 

debjit625

Joined Apr 17, 2010
790
In old days of Windows 95 and 98 will let you access serial port using inport() and outport() functions ,but from windows NT you cant access ports directly,you need a kernel driver to access them or you can also use "inpout32.dll" to do the job here is the address http://logix4u.net

Good Luck
 

cheezewizz

Joined Apr 16, 2009
82
Debjit according to that link inpout32.dll is a dll for accessing the parallel port? Isn't he after serial (COM1, etc) communications... If that's the case the link I posted has a pretty good explanation of what you need, if not then er sorry :D
 

debjit625

Joined Apr 17, 2010
790
Yes,you are right and also a bit wrong the tutorial is about parallel port and I have not seen yours link (I wil see it ) and about the dll,the dll access ports i.e.. may be parallel or serial using a kernel driver on NT based platform ,on software front port is nothing but a memory adddress just like in microcontrollers so we just have to use these memory address to work with any I/O ports.

Their is another way to access I/O ports under NT platform i.e.. using win32 API ,I forget the link but you will find it on MSDN ,but using API will cause you overhead i.e.. slower access than kernel mode.

Good Luck
 

indianhits

Joined Jul 25, 2009
86
once i had to use serial,parallel port in XP for uC i didn't have to download any drivers i simply showed the direct address and it worked fine
 

debjit625

Joined Apr 17, 2010
790
"indianhits" are you kidding? if not then give the name of the function you used and the name of the compiler.If anybody will try to use those function under XP they will get a "Privilege error".
 

retched

Joined Dec 5, 2009
5,207
once i had to use serial,parallel port in XP for uC i didn't have to download any drivers i simply showed the direct address and it worked fine
indianhits, I am quite interested in how you managed to do this.

Or is this one of those "One time, in band camp..." stories? ;)

Unless a virus or some TSR was acting as your middleman, I cant see how you directly accessed the port.

Were you just reading the port?
 

indianhits

Joined Jul 25, 2009
86
Turbo c++'s inport(),outport() and there are similar other functions in the IDE and i didn't use any DLL's.Guys if you can once try it!

i am sure everything must be in the function

when i was doing my college project i didn't knew how to do this in win32 so i had not much time left i decided to go with this 16-BIT IDE

but www.robbayer.com/files/serial-win.pdf site is really good i wish i had it earlier :)

and yeah it did it for serial and i heard it can also be done for parallel by changing the port address in the function
 
Last edited:

Thread Starter

dreamcatcher

Joined Jan 5, 2010
27
Hi all,

thank you for your answers, i took a look at them and I did some research and I concluded that C# is much easier to do the serial communication then the C++.

Thank you all.
 
Top