Connecting Tech Pros Worldwide Help | Site Map

How to access hardware ports using C ?

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 14th, 2005, 09:23 PM
agnivesh
Guest
 
Posts: n/a
Default How to access hardware ports using C ?

Hi there,

I'm a beginner in C programming and want to learn how to write C (pure
C) code to access hardware ports (serial,parallel,usb etc.) under
windows environment ?

1. Please, suggest any online tutorials or free ebooks etc. for that.

2. Is it possible to do above tasks using MingW Developer Studio, GTK+
etc. ? I've just downloaded these tools and want to make sure before
starting learning these tools, that we can use these tools to write
small windows GUI applications (in C), which can interact with external
embedded systems through PC's serial, parallel or usb port.

thanks in advance,
agnivesh.


  #2  
Old November 14th, 2005, 09:23 PM
Thomas Matthews
Guest
 
Posts: n/a
Default Re: How to access hardware ports using C ?

agnivesh wrote:[color=blue]
> Hi there,
>
> I'm a beginner in C programming and want to learn how to write C (pure
> C) code to access hardware ports (serial,parallel,usb etc.) under
> windows environment ?
>
> 1. Please, suggest any online tutorials or free ebooks etc. for that.
>
> 2. Is it possible to do above tasks using MingW Developer Studio, GTK+
> etc. ? I've just downloaded these tools and want to make sure before
> starting learning these tools, that we can use these tools to write
> small windows GUI applications (in C), which can interact with external
> embedded systems through PC's serial, parallel or usb port.
>
> thanks in advance,
> agnivesh.
>[/color]

Hardware ports are platform dependent. The bigger platforms
require that programs use operating system functions to access
the ports. In smaller platforms, programs generally access
some kind of hardware chip. In even smaller platforms, the
ports are accessed directly.

You will have to ask in a newsgroup about your platform or
operating system.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
  #3  
Old November 14th, 2005, 09:24 PM
agnivesh
Guest
 
Posts: n/a
Default Re: How to access hardware ports using C ?

Please guide considering my os being windows xp and I want to interact
with external hardware thruogh hardware ports like serial, parallel or
usb using C.

thanks in advance.

  #4  
Old November 14th, 2005, 09:24 PM
Gordon Burditt
Guest
 
Posts: n/a
Default Re: How to access hardware ports using C ?

>Please guide considering my os being windows xp and I want to interact[color=blue]
>with external hardware thruogh hardware ports like serial, parallel or
>usb using C.[/color]

This question is best asked in a newsgroup specific to your OS.

A reasonable OS will insist that a user-level program ask the OS
nicely (and if you don't have admin-like privileges, say "NO")
before letting it do direct I/O to ports (assuming the hardware
supports such a thing at all), or simply not allow it at all. After
you've asked nicely, you may be able to use the assembly-language
instructions to do I/O to ports.

Or you use the drivers that the OS has provided.

It is not particularly easy to do your own I/O to USB devices when
the OS is also trying to do I/O to USB devices it controls (e.g.
the keyboard and/or mouse.) without stomping over each other and
likely locking up the system. Generally the right way to do this
is called "writing a driver".

Operating systems likely to qualify as a "reasonable OS" as defined
above include UNIX, Linux, and recent versions of Windows (including
XP). CP/M, most configurations of MS-DOS, and Windows 3.1 and
earlier don't. I'm not sure of the status of Windows 95 and Windows
98.

Gordon L. Burditt
  #5  
Old November 14th, 2005, 09:25 PM
CBFalconer
Guest
 
Posts: n/a
Default Re: How to access hardware ports using C ?

agnivesh wrote:[color=blue]
>
> Please guide considering my os being windows xp and I want to
> interact with external hardware thruogh hardware ports like
> serial, parallel or usb using C.[/color]

What part of Thomas Matthews advice, to which you replied but
didn't bother to quote, don't you understand? Also see the advice
in my sig, below.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson

Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!


  #6  
Old November 14th, 2005, 09:26 PM
Villy Kruse
Guest
 
Posts: n/a
Default Re: How to access hardware ports using C ?

On Tue, 10 May 2005 21:35:53 GMT,
CBFalconer <cbfalconer@yahoo.com> wrote:

[color=blue]
> agnivesh wrote:[color=green]
>>
>> Please guide considering my os being windows xp and I want to
>> interact with external hardware thruogh hardware ports like
>> serial, parallel or usb using C.[/color]
>
> What part of Thomas Matthews advice, to which you replied but
> didn't bother to quote, don't you understand? Also see the advice
> in my sig, below.
>[/color]

Appart from that, I don't think a beginner should even go there. On xp
system the hardware should exclusively be accessed through device drivers
and user programs should then talk to the device drivers using the API
designed for this purpose.

Villy
  #7  
Old November 14th, 2005, 09:26 PM
italy
Guest
 
Posts: n/a
Default Re: How to access hardware ports using C ?

Eh, this newsgroup is specifically for discussion of the C language.

1. Google
2. Yes, you may use any compiler. Look into your platform for how ports
are written to, and obviously read.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.