CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2000
    Posts
    128

    sending a byte to serial port

    Hello,

    How can I send a byte (-> 8 bits) to a serial port ?

    Is there a program for testing this ?
    (e.g. Hyperterminal)

    Or can I use a dos-prompt for doing this ?

    With kind regards.


  2. #2
    Join Date
    May 2001
    Posts
    8

    Re: sending a byte to serial port

    try out the following in c for this you need to include dos.h file in your dos development enviorment
    outportb(potrtaddress, data)
    eg. outportb(ox2f8, 0xff) ; //to send 255

    In order to check the the transfer I beleive you can short the pins 2 and 3 with a led or wire and check for the same data in the input stream buffer of the serial port using inportb() function in TC++ or borland C++
    If you are unable to do the aforesaid feel free to contact



  3. #3
    Join Date
    Jun 2001
    Posts
    0

    Re: sending a byte to serial port

    Hi..
    I am interested to know more about using serial port in the my program
    however, i have lack of idea about dos.h library.. where could i find the info, or could you send me a copy if you have one..

    thanks



  4. #4
    Join Date
    Jun 2001
    Posts
    0

    Re: sending a byte to serial port

    hai
    I am interested to know more about dos.h and the call function associated with it eg outportb and inportb

    well, i you can say that I AM INTERESTED with serial programming
    and IT IS MY FIRST TIME.. any help???

    your help is higly appreciated

    regards



  5. #5
    Join Date
    May 2001
    Posts
    8

    Re: sending a byte to serial port

    hi there,
    Before I can tell you more about dos.h I would like to know development platform and OS you r doing your coding, as dos.h is not packaged with all the compilers.

    I would like you to appreciate by rating the post.

    Thanks
    Shyam


  6. #6
    Join Date
    Jun 2001
    Posts
    0

    Re: sending a byte to serial port

    well.. i am thinking of using borland c++ version 4.. but i have been looking at MFC library.. and I talk with my boss.. he said that he may bought me VC++ V6 for me..i am using win 95&98

    which one is the best compiler?




  7. #7
    Join Date
    Jul 2001
    Posts
    0

    Re: sending a byte to serial port

    The complexity of this depends on whether youre using win32 or a dos-based program. For dos, you can just outportb to 0x3f8 the byte you want to send. For win32 it is more complicated, you have to set up the serial port as a file using CreateFile (look in msdn for usage), and setup a hFile. I personally would recommend using dos for simplicity. For dos, code examples are all over the web, including ones with software interrupts.


  8. #8
    Join Date
    Jan 2002
    Posts
    1

    Re: sending a byte to serial port

    I want to receive bytes from serial port ie. I want to get output of epabx to computer and want to save in windows environment .cause at present in dos i have
    a utility calle gcap...
    thak you,

    Mahedra


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured