473,788 Members | 3,068 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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,paralle l,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 10939
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,paralle l,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.l earn.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.c om, 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********@yah oo.com) (cb********@wor ldnet.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********@yah oo.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
767
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 software to much to the specific motherboard ? Thanks in advance for any hint, Wolfgang
64
5260
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. Any comments? Thanks
16
2968
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 ------------------------ /*A simple get() function*/ unsigned char port0_get_char(void) { unsigned char input_c;
4
1485
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
4834
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 been told it is not possible to access the serial ports from asp.net. The application is used to control custom hardware. The hardware is connected to a PC through serial ports. Our customer wants to control the hardware from a remote...
49
3238
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, etc? Please explain -- Message posted via http://www.accessmonster.com
3
2130
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 app has options that 'talk' over the serial port to a piece of hardware, controlling it and getting information to/from it. The ASP.NET app would need to do the same think. Previously, in VB6, I believe one could do something like this by...
5
3035
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
4557
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 controlled to prevent the PC sending too much data per second. Here is my attempt at setting the hardware handshake operation: serialPort1->Handshake = System::IO::Ports::Handshake::RequestToSend; serialPort1->RtsEnable = true;
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.