Solved

How do i detect a floppy disk change?

Posted on 1998-04-17
7
320 Views
Last Modified: 2006-11-17
Is there a way to check wheter the floppy a new floppy has been inserted in the diskdrive? I want my linuxbox to automaticly mount floppies. I can offcourse mount a microswitch on my diskdrive and read poll that via my joystickport or something like that. But if there is a software way to do it, thats much nicer. What i don't want is my drive motor to switch on. Is there a way to check these things?  What i found out is that my writeprotect-switch consists of 2 pins of which one gets pressed if write-protect and the other gets pressed when write enable. So OR-ing those switches means a disk detection. How can i read the state of these switches?

I hope that you can help me. Marc.
0
Comment
Question by:grmbl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 11

Expert Comment

by:alexo
ID: 1249352
Good ol' INT13 comes to the rescue:

-----------------------------------------------------------
 INT 13 - GET DISK TYPE (PC/AT ONLY)
     REG AH = 15H
         DL = DRIVE ID
     ON RETURN:
        REG AH = DISK TYPE
                 0 = DISK NOT THERE
                 1 = DISKETTE, NO CHANGE DETECTION PRESENT
                 2 = DISKETTE, CHANGE DETECTION PRESENT
                 3 = FIXED DISK
            CX,DX = NUMBER OF 512-BYTE SECTORS WHEN AH = 3
 -----------------------------------------------------------
 INT 13 - CHANGE OF DISK STATUS (PC/AT ONLY)
     REG AH = 16H
     ON RETURN:
        REG DL = DRIVE THAT HAD DISK CHANGE
            AH = DISK CHANGE STATUS
                 00 = NO DISK CHANGE
                 01 = DISK CHANGED
 -----------------------------------------------------------
 
0
 
LVL 11

Expert Comment

by:alexo
ID: 1249353
Also, you can access the change-detect line by port 0x3F7 (bit 7), but it only useful if the drive motor is on.  Normally you'd use interupt 13h, ah=16h but if the system is also accessing the drive you stand to miss the diskette change.
0
 

Author Comment

by:grmbl
ID: 1249354
I read that INT 13 specification too. But unfortunately i've never coded hardware interupts before. (I did a bit with asembly but not much). So can you please give me a clue where i can get info on how to program that sort of things under linux?

Do i have to place the code in the kernel? Or in a suid program? Or make a module? I haven't got any experience with that sort of coding so please consider me a newbie :-) I took a look at floppy.c but i couln't find something usefull there.

Marc
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:alexo
ID: 1249355
Sorry, not familiar with Linux.  Why don't you put a zero-point pointer to your question in the "Linux" and "Unix" areas?  Call it something like "Reference to detect a floppy disk change" and put the URL of this question (http://www.experts-exchange.com/Q.10048457) inside.
0
 
LVL 5

Expert Comment

by:laeuchli
ID: 1249356
I don't think the OS can tell if the floppy haas changed or not. What I would do is make a timer something keeps checking to see if the floppy is the same of differnt.
0
 

Author Comment

by:grmbl
ID: 1249357
Yes but i want to check that without switching on the drive motor. Grepped through the kernel sources and the headerfiles but im not experienced enough to know what registers to read from.
0
 
LVL 10

Accepted Solution

by:
rbr earned 200 total points
ID: 1249358
In Linux you have to watch the mount-damon since all floppies have to be mounted and unmounted. How to you access you floppy under Linux. With amd, manual mounting, ...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question