LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 12-08-2006, 05:04 PM   #1
kiruxa
LQ Newbie
 
Registered: Nov 2006
Posts: 10

Rep: Reputation: 0
system calls to devices?Talking to devices.


Hello,
I am doing some research on this currently but maybe someone here is able to point me in the right direction.

I am looking for example of a script/c code for communication with perhipiral device(any kind)

Basically what i want to do is to create a script/c code to
enable/disable a device(doesnt matter what device).

I want to be able to disable for example a mouse and then enable it - i dont want existing programs i would like to create or see an example of a piece of code that is able to disable a video card , mouse etc just by running it.

Should i be researching into system calls or I am way off?


Thank you!

I am using Fedora 4.
 
Old 12-08-2006, 05:12 PM   #2
towel401
Member
 
Registered: Apr 2005
Location: Ireland
Distribution: Debian
Posts: 39

Rep: Reputation: 15
fc4 is a bit old now but it will do. anything in unix is a file. so /dev/ttyS0 is your first serial port, /dev/mem is the computer's RAM, so if you know how to write to a file with your script you can control pretttymuch anything. with a serial port you gotta set the correct baud rate and that and i have no idea how you would do that but google probably knows. i dunno how you would go about disabling a mouse that would usually involve changing some setting for your X server.
 
Old 12-08-2006, 05:21 PM   #3
kiruxa
LQ Newbie
 
Registered: Nov 2006
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks for quick reply! , yeah i know FC4 is old
I am just looking for some examples for talking with devices
I would like to create or see a script to maybe turn off a monitor/mouse(i think thats safer)
than tryng to disable and the re enable a video card via script.

Googling so far is hard on this topic not finding much,so i came here in hopes of a link to some guide or code examples.

Any input is usefull,even some helpfull keywords to google for!

Thank you.
 
Old 12-08-2006, 05:29 PM   #4
towel401
Member
 
Registered: Apr 2005
Location: Ireland
Distribution: Debian
Posts: 39

Rep: Reputation: 15
the normal way to do something like that is to pass a command to some -tool for the particular device

for example hdparm -Y will switch off a hard drive but if you really want to know how hdparm goes about switching it off you gotta get the source for it, and see what it sends to the hard drive's /dev file
 
Old 12-08-2006, 05:38 PM   #5
kiruxa
LQ Newbie
 
Registered: Nov 2006
Posts: 10

Original Poster
Rep: Reputation: 0
ah thanks for clearing it up
i'll start on checking out some open source apps!

any specific ones you'd suggest besides hdparm?
 
Old 12-08-2006, 06:26 PM   #6
towel401
Member
 
Registered: Apr 2005
Location: Ireland
Distribution: Debian
Posts: 39

Rep: Reputation: 15
maybe GNU eject. there are loads of them I cant think of right now
 
Old 12-09-2006, 05:46 PM   #7
kiruxa
LQ Newbie
 
Registered: Nov 2006
Posts: 10

Original Poster
Rep: Reputation: 0
Well i did some research but my C knowlege is kind of weak

From my understanding all devices are nodes in /proc filesystem in /dev

so my mouse is /dev/mouse0 - is the a way to remove this node therefore disabling the mouse and then to create it back so it is enabled?

also the ioctl system call - is it capable of talking to the devices?

I understand everything is a file philosophy - but how do i find out what commands can be issued to the /dev/mouse or /dev/hd1 etc?

all i am looking for is a system call or command to disable/enable said device in /dev

Thank you!
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the different btw raw devices and block devices yenonn Linux - General 2 02-10-2006 09:34 PM
USB devices freezing system tuneout Debian 3 11-29-2005 08:54 PM
Are these devices sufficient for my system? kornerr Linux - General 5 06-19-2005 10:51 AM
System freeze, input devices not responding? R00ts Debian 4 08-09-2004 09:57 AM
how to install 2 same pci devices in 1 linux system? maximurs Linux - Hardware 3 04-05-2004 04:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 04:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration