Thread: Manipulating devices

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    3

    Smile Manipulating devices

    How is it possible to program a device, like a cd-rom drive, to do stuff?
    Ejecting for instance.
    Or how do i make a program that can manipulate my bluetooth device to send a file or some text to another computer?

    Are there special programming commands for every possible function for every piece of hardware?

    Hope somebody here knows!

    - Martin

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Moved: Device communication question.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Each device has a specific set of commands that it can recognize. Most devices "live" at a specific address. In the case of a CDROM drive, the address is an extension of another device (eg, IDE channel, SCSI channel, USB, etc). In Linux (and other Unix like OSs) these devices are available to you in the form of a file. After opening one of these files, you can send an ioctl() command to that file and have it preform some type of action.

    A good place to start is the Linux Kernel. I'd only focus in on one type device (for starters) as it is not an easy task to learn how to manipulate devices directly.

    WARNING: DIRECTLY INTERFACING A DEVICE FROM CODE CAN CAUSE DAMAGE TO THE DEVICE, YOU MUST BE VERY CAREFUL WHEN ATTEMPTING TO WRITE A DEVICE DRIVER.

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Kennedy View Post
    WARNING: DIRECTLY INTERFACING A DEVICE FROM CODE CAN CAUSE DAMAGE TO THE DEVICE, YOU MUST BE VERY CAREFUL WHEN ATTEMPTING TO WRITE A DEVICE DRIVER.
    I killed a hard drive once while trying to write a TSR to park the disk head after a certain period of time. The code which determined the timeout was broken, so the result was the disk head parked and then unparked extremely rapidly. This causes the head to go SLAM SLAM SLAM SLAM against the parking region, eventually destroying it.

    This was a long time ago. Modern disk drives probably can't be forced to do something quite so destructive.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Accessing USB devices
    By deviousdexter in forum C# Programming
    Replies: 1
    Last Post: 01-24-2009, 09:48 PM
  2. Lost devices in Direct3D
    By VirtualAce in forum Game Programming
    Replies: 10
    Last Post: 12-09-2006, 07:41 AM
  3. Palm Pilot devices
    By ventolin in forum Networking/Device Communication
    Replies: 0
    Last Post: 03-11-2004, 10:51 AM
  4. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 09:37 AM
  5. Manipulating Files
    By JoshuaNSW in forum C Programming
    Replies: 2
    Last Post: 01-24-2002, 02:01 AM