Serial communication

This is a discussion on Serial communication within the C Programming forums, part of the General Programming Boards category; Is there a way to perform serial communication using c? I have an RS232 output from a AD converter, i ...

  1. #1
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168

    Serial communication

    Is there a way to perform serial communication using c?
    I have an RS232 output from a AD converter, i was wondering if any one knows of links or even ways of interacting with the serial port.

    Thank!

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    On what platform?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168
    windows xp
    i have found termio.h and bios.h but i will take any advice or direction you can give

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,645

  5. #5
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168
    This sounds pretty intense

    This article assumes a familiarity with the fundamentals of multiple threading and synchronization in Win32. In addition, a basic understanding of the Win32 heap functions is useful to fully comprehend the memory management methods used by the Multithreaded TTY (MTTTY) sample included with this article.

  6. #6
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    Is there a way to perform serial communication using c?
    I have an RS232 output from a AD converter, i was wondering if any one knows of links or even ways of interacting with the serial port.
    This site might be interesting:
    http://www.beyondlogic.org/

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Shiro View Post
    This site might be interesting:
    http://www.beyondlogic.org/
    Unfortunately, most of the info on RS232 on that site assumes DOS rather than Windows.

    It is MUCH better to learn how to do this in Windows than in DOS, because DOS isn't very good at doing this when it's run as a virtual DOS under Windows.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Wanabe Laser Engineer chico1st's Avatar
    Join Date
    Jul 2007
    Posts
    168
    so that means using win32 is better than using bios.h etc... the MSDN article is very good. im enjoying it so far

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by chico1st View Post
    so that means using win32 is better than using bios.h etc... the MSDN article is very good. im enjoying it so far
    Actually, bios.h is probably better than the "direct IO port approach", but it's still going to end up with a fair bit of overhead, since the BIOS call performs a software interrupt, the NTVDM (which is the part of the Windows kernel that deals with DOS applications) will intercept the sw interrupt, and look at the various register values to figure out what it means, then translate that to a call to the relevant Win32 file operation, wait for that to finish and return the result back through NTVDM into your applicaiton.

    In the case of a direct port access, the story is slightly more complex, because the NTVDM keeps track of the port state, simulating the serial port and then performing the same Win32 file operations to actually access the port. So it's pretty much the same.

    And in the end, you still end up in the same Win32 API function - but you went across the road so that you could get to the shop that is on your side of the road.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Duplex communication thro serial port
    By Priyachu in forum Linux Programming
    Replies: 1
    Last Post: 05-30-2009, 04:03 AM
  2. Serial port Communication
    By vin_pll in forum C++ Programming
    Replies: 23
    Last Post: 01-07-2009, 08:32 AM
  3. Serial pot communication through c program
    By vin_pll in forum C++ Programming
    Replies: 2
    Last Post: 01-01-2009, 11:52 AM
  4. Please help with serial communication problem - Long
    By spdylude in forum Windows Programming
    Replies: 3
    Last Post: 04-06-2005, 09:41 AM
  5. Serial communication packets
    By Roaring_Tiger in forum C Programming
    Replies: 3
    Last Post: 04-26-2003, 08:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21