C++ serial comunication help

Discussion in 'Programmer's Corner' started by dreamcatcher, Aug 22, 2010.

  1. dreamcatcher

    Thread Starter New Member

    Jan 5, 2010
    27
    0
    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
     
  2. indianhits

    Active Member

    Jul 25, 2009
    86
    0
    you can use Turbo c++'s inport() and outport().
    thats the only easy way to do this!

    or in assembly!
     
  3. cheezewizz

    Active Member

    Apr 16, 2009
    82
    10
    If you're coding for win32 it's not massively complicated to just use the windows API. www.robbayer.com/files/serial-win.pdf has a good tutorial of the basics and MSDN gives great details of each function used....
     
  4. debjit625

    Well-Known Member

    Apr 17, 2010
    790
    186
    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
     
  5. cheezewizz

    Active Member

    Apr 16, 2009
    82
    10
    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
     
  6. debjit625

    Well-Known Member

    Apr 17, 2010
    790
    186
    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
     
  7. indianhits

    Active Member

    Jul 25, 2009
    86
    0
    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
     
  8. debjit625

    Well-Known Member

    Apr 17, 2010
    790
    186
    "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".
     
  9. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    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?
     
  10. indianhits

    Active Member

    Jul 25, 2009
    86
    0
    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: Aug 24, 2010
  11. Eng_Bandar

    Active Member

    Feb 27, 2010
    50
    1
  12. dreamcatcher

    Thread Starter New Member

    Jan 5, 2010
    27
    0
    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.
     
Loading...