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!
Moved: Device communication question.
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.
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.
Originally Posted by Kennedy
This was a long time ago. Modern disk drives probably can't be forced to do something quite so destructive.