473,382 Members | 1,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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.

Nov 14 '05 #1
6 10915
agnivesh wrote:
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.


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
Nov 14 '05 #2
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.

Nov 14 '05 #3
>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.


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
Nov 14 '05 #4
agnivesh wrote:

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.


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 (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #5
On Tue, 10 May 2005 21:35:53 GMT,
CBFalconer <cb********@yahoo.com> wrote:

agnivesh wrote:

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.


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.


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
Nov 14 '05 #6
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.

Nov 14 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Wolfgang | last post by:
Dear all, I'm using GPIO (general purpose IO) of a motherboard. Accessing SMBus Components directly by the Registers of the SMBus Controller. Has anybody a more elegant way not to bind the...
64
by: John | last post by:
Hi What future does access have after the release of vs 2005/sql 2005? MS doesn't seem to have done anything major with access lately and presumably hoping that everyone migrates to vs/sql. ...
16
by: silentlights | last post by:
Hi Guys, I am looking for an alternative means of register access in a microcontroller. Currently my get() function looks like this.. ------------------------ implementation in comm.c...
4
by: MTB | last post by:
I want to switch to windows programming and have no idea how to access hardware in windows. please help
13
by: Al the programmer | last post by:
I need to access the serial ports on my webserver from an asp.net page. I have no problem accessing the serial ports from a windows form application, but the code doesn't work in asp.net. I have...
49
by: Mell via AccessMonster.com | last post by:
I created databases on Access 2003 and I want to deploy them to users. My code was also done using 2003. If they have Ms Access 2000 or higher, will they be able to use these dbs with all code,...
3
by: Tom | last post by:
Is there any way to 'download' a control that could access hardware on a PC? Reason is that I am considering retooling a client-server app of ours over to ASP.NET (VB.NET). However, currently that...
5
by: =?Utf-8?B?Q2hyaXN0aWFuIEhhdmVs?= | last post by:
Hi, how can I access the RS-232 hardware interface using C# and .NET2.0 to send and receive messages to a hardware component? Christian
6
by: Steve Mowbray | last post by:
Hi I am using SerialPort component to send raw binary files to a remote device with RTS/CTS handshaking - the remote device has a small receive buffer and is slow so needs to be hardware flow...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.