Accessing Hardware Port 
Author Message
 Accessing Hardware Port

G'day,

I am trying to access some hardware ports for a project I am looking at
undertaking and I am wondering which commands I need to use to do this.  I
am flexible as to whether I use Windows/DOS or Linux.

Any help would be greatly appreciated.
Glenn



Thu, 31 Mar 2005 15:24:32 GMT  
 Accessing Hardware Port

Quote:
> G'day,

> I am trying to access some hardware ports for a project I am looking
> at undertaking and I am wondering which commands I need to use to do
> this.  I am flexible as to whether I use Windows/DOS or Linux.

> Any help would be greatly appreciated.

You can't do that in standard C.

However, accessing the hardware is probably possible, but under the control
of the system. Hence, the system has to provide a way to do it. This is why
'drivers' are made for. You must use the required system functions.

If there is no driver for the device, you must provide one, or eventually
write it yourself. The way of writing drivers is completely system specific
and involves systemmm calls, C-extensions, assembly language etc. Not a job
for an absolute beginner!

--
-ed- emdel at noos.fr ~]=[o
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
C-library: http://www.dinkumware.com/htm_cl/index.html
"Mal nommer les choses c'est ajouter du malheur au monde."
-- Albert Camus.



Thu, 31 Mar 2005 17:00:24 GMT  
 Accessing Hardware Port

Quote:
>I am trying to access some hardware ports for a project I am looking at
>undertaking and I am wondering which commands I need to use to do this.  I
>am flexible as to whether I use Windows/DOS or Linux.

Real multitasking operating systems restrict the access to the hardware
ports to themselves, for reasons that should be obvious to anyone.

So, I recommend DOS for your project.  The names of the relevant functions
depend on the DOS compiler you plan to use and are off-topic for this
newsgroup, but you should know where to find comp.os.msdos.programmer.

However, the phrasing of your question suggests that you're not an
experienced C programmer.  I strongly suggest to learn C properly *before*
starting any kind of project requiring access to the hardware ports.

Dan
--
Dan Pop
DESY Zeuthen, RZ group



Fri, 01 Apr 2005 19:11:28 GMT  
 Accessing Hardware Port

Quote:


>>I am trying to access some hardware ports for a project I am looking at
>>undertaking and I am wondering which commands I need to use to do this.  I
>>am flexible as to whether I use Windows/DOS or Linux.

> Real multitasking operating systems restrict the access to the hardware
> ports to themselves, for reasons that should be obvious to anyone.

Of course, real multitasking operating systems also allow the owner of
the computer to access the hardware ports if he would really like to,
for reasons that should be equally obvious.  On Linux you can ask for
a length of this particular piece of rope using ioperm().

        - Kevin.



Fri, 01 Apr 2005 21:33:42 GMT  
 Accessing Hardware Port

Quote:


>>I am trying to access some hardware ports for a project I am looking at
>>undertaking and I am wondering which commands I need to use to do this.  I
>>am flexible as to whether I use Windows/DOS or Linux.

>Real multitasking operating systems restrict the access to the hardware
>ports to themselves, for reasons that should be obvious to anyone.

>So, I recommend DOS for your project.  The names of the relevant functions
>depend on the DOS compiler you plan to use and are off-topic for this
>newsgroup, but you should know where to find comp.os.msdos.programmer.

Nonsense.  Any decent OS that restricts access to ports will also
provide an API to obtain access, for those who need it.  If you want
to unconditionally restrict access, just turn the box off!

<OT>In Linux, access is obtained with ioperm().  There are several HOWTO
documents that cover how to bang on the ports with Linux, including
example code.  It's really no harder than doing the same thing in DOS; and
with Linux, you get all the nice fringe benefits like multitasking, flat
32-bit (or larger) address model, robust TCP/IP stack, free Web server
(HTTP configuration of your embedded system over the LAN, for essentially
no additional effort).

I would not recommend DOS for much of anything, now that Linux can
be used in virtually all of the same situations.  Legacy software is
about the only valid reason to use DOS.  If you're writing new code,
no matter how small and even for embedded systems, IMO Linux is a
much better choice than DOS (even if the latter were free).</OT>

--Ben

--



Sat, 02 Apr 2005 02:09:49 GMT  
 Accessing Hardware Port

Quote:


>>>I am trying to access some hardware ports for a project I am looking at
>>>undertaking and I am wondering which commands I need to use to do this.  I
>>>am flexible as to whether I use Windows/DOS or Linux.

>> Real multitasking operating systems restrict the access to the hardware
>> ports to themselves, for reasons that should be obvious to anyone.

>Of course, real multitasking operating systems also allow the owner of
>the computer to access the hardware ports if he would really like to,
>for reasons that should be equally obvious.  On Linux you can ask for
>a length of this particular piece of rope using ioperm().

I wouldn't recommend to an obvious newbie to do software development
as root on a Linux system.

Dan
--
Dan Pop
DESY Zeuthen, RZ group



Sun, 03 Apr 2005 03:05:31 GMT  
 Accessing Hardware Port

Quote:

> I wouldn't recommend to an obvious newbie to do software development
> as root on a Linux system.

Aw, Dan, where's your sense of adventure?  ;-)

--

|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL  |
|_____________________________________________|_______________________|

Opinions expressed herein are my own and may not represent those of my employer.



Sun, 03 Apr 2005 03:34:47 GMT  
 Accessing Hardware Port

Quote:




>>>>I am trying to access some hardware ports for a project I am looking at
>>>>undertaking and I am wondering which commands I need to use to do this.  I
>>>>am flexible as to whether I use Windows/DOS or Linux.

>>> Real multitasking operating systems restrict the access to the hardware
>>> ports to themselves, for reasons that should be obvious to anyone.

>>Of course, real multitasking operating systems also allow the owner of
>>the computer to access the hardware ports if he would really like to,
>>for reasons that should be equally obvious.  On Linux you can ask for
>>a length of this particular piece of rope using ioperm().

>I wouldn't recommend to an obvious newbie to do software development
>as root on a Linux system.

So what's your point?  I wouldn't recommend to an obvious newbie to
do programming that involved hitting the hardware ports, in the first
place.  If they are competent to take the risk of hitting the ports,
then they are competent to be root.  (The *development* should not be
done as root in any case, but as we all know, the user will have to
become root, or use the setuid bit, to run the program -- as well they
should have to!).  On MS-DOS, they are root all the time (and then some),
and all the same dangers are present as when one is root under Unix,
except that there is no way to turn these dangers *off*.

--Ben

--



Sun, 03 Apr 2005 04:20:44 GMT  
 Accessing Hardware Port

Quote:


>> I wouldn't recommend to an obvious newbie to do software development
>> as root on a Linux system.

>Aw, Dan, where's your sense of adventure?  ;-)

talking of easy ways to trash your OS... .
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>


Sun, 03 Apr 2005 04:47:32 GMT  
 Accessing Hardware Port
On 15 Oct 2002 20:20:44 GMT, in comp.lang.c ,

Quote:



>>I wouldn't recommend to an obvious newbie to do software development
>>as root on a Linux system.

>So what's your point?  I wouldn't recommend to an obvious newbie to
>do programming that involved hitting the hardware ports, in the first
>place.  If they are competent to take the risk of hitting the ports,
>then they are competent to be root.

That logic does not follow. I know many competent programmers who I
certainly would not let loose with root permissions on any of our unix
boxes.

Quote:
>On MS-DOS, they are root all the time (and then some),
>and all the same dangers are present as when one is root under Unix,
>except that there is no way to turn these dangers *off*.

Relevance factor?

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>



Sun, 03 Apr 2005 06:47:57 GMT  
 Accessing Hardware Port


Quote:
>On 15 Oct 2002 20:20:44 GMT, in comp.lang.c ,



>>>I wouldn't recommend to an obvious newbie to do software development
>>>as root on a Linux system.

>>So what's your point?  I wouldn't recommend to an obvious newbie to
>>do programming that involved hitting the hardware ports, in the first
>>place.  If they are competent to take the risk of hitting the ports,
>>then they are competent to be root.

>That logic does not follow. I know many competent programmers who I
>certainly would not let loose with root permissions on any of our unix
>boxes.

But you would let them have access to the hardware ports?  I think not!

If you let them use your MS-DOS boxes *at all*, you are letting them
have "root permissions" on those machines.  The only reason it might
not be as dangerous is that the MS-DOS machines are not likely used
for anything critical that lots of people depend on, like mail, web
server, home directories, etc..

Quote:
>>On MS-DOS, they are root all the time (and then some),
>>and all the same dangers are present as when one is root under Unix,
>>except that there is no way to turn these dangers *off*.

>Relevance factor?

Dan seemed to be suggesting that the fact that you need root perms, one
way or another, to hit the ports in Unix, was somehow a problem or a
disadvantage.  My point is that you effectively need root perms on *any*
OS, to hit the ports, and that is how it should be.  The fact that Unix
provides a security model that allows *some* users to be *prohibited*
from hitting the ports, whereas MS-DOS has no such model, is not a
strike against Unix.

Now can ya see it?

--Ben

--



Sun, 03 Apr 2005 07:04:16 GMT  
 Accessing Hardware Port
On 15 Oct 2002 23:04:16 GMT, in comp.lang.c ,

Quote:

>But you would let them have access to the hardware ports?  I think not!

This entire debate is OT here. I'm not continuing it.

Quote:
>Now can ya see it?

See what? That you're babbling?

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>



Sun, 03 Apr 2005 07:20:18 GMT  
 Accessing Hardware Port

Quote:




> >> I wouldn't recommend to an obvious newbie to do software development
> >> as root on a Linux system.

> >Aw, Dan, where's your sense of adventure?  ;-)

> talking of easy ways to trash your OS... .

This is getting OT, but what is missing is the concept of
non-sharable resources, which describes the port.  The process
using it needs the capability of accessing such things, must
request it from the OS, and must release it when done.  It is not
much different than requesting a file for exclusive access, which
normally happens when you open a file for write.  Enter virtual
ports.

--

   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!



Sun, 03 Apr 2005 11:40:33 GMT  
 Accessing Hardware Port

Quote:


> >On 15 Oct 2002 20:20:44 GMT, in comp.lang.c ,





> >>>I wouldn't recommend to an obvious newbie to do software development
> >>>as root on a Linux system.

> >>So what's your point?  I wouldn't recommend to an obvious newbie to
> >>do programming that involved hitting the hardware ports, in the first
> >>place.  If they are competent to take the risk of hitting the ports,
> >>then they are competent to be root.

> >That logic does not follow. I know many competent programmers who I
> >certainly would not let loose with root permissions on any of our unix
> >boxes.

> But you would let them have access to the hardware ports?  I think not!

> If you let them use your MS-DOS boxes *at all*, you are letting them
> have "root permissions" on those machines.  The only reason it might
> not be as dangerous is that the MS-DOS machines are not likely used
> for anything critical that lots of people depend on, like mail, web
> server, home directories, etc..

> >>On MS-DOS, they are root all the time (and then some),
> >>and all the same dangers are present as when one is root under Unix,
> >>except that there is no way to turn these dangers *off*.

> >Relevance factor?

> Dan seemed to be suggesting that the fact that you need root perms, one
> way or another, to hit the ports in Unix, was somehow a problem or a
> disadvantage.  My point is that you effectively need root perms on *any*
> OS, to hit the ports, and that is how it should be.  The fact that Unix
> provides a security model that allows *some* users to be *prohibited*
> from hitting the ports, whereas MS-DOS has no such model, is not a
> strike against Unix.

> Now can ya see it?

As the person that started this debate, I am a uni student that is doing a
unix systems programming subject and the system being used for development
and for running for that matter would be a stand-alone linux box where the
only thing running would be the program that I develop. So if I{*filter*}the
whole thing up then, so be it and I just re install  linux... And I agree
giving any user, unless they are trustworthy not to{*filter*}up critical
programs,  giving port access is a dangerous thing to do.

Glenn



Tue, 05 Apr 2005 09:03:52 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. Accessing hardware ports in C

2. port hardware access

3. hardware port i/o

4. In/output byte to hardware port in Win32?

5. howto program hardware (IO ports / kybds)

6. Group? Hardware Ports

7. Hardware Ports

8. Hardware Interrupts for the RS232 port

9. using hardware port-address

10. bit fields and reading from a hardware port

11. RS232 COM1 serial port Software/Hardware Problem

12. hardware ports I/O

 

 
Powered by phpBB® Forum Software