Announcement

Collapse
No announcement yet.

Need CDROM control ideas and samples

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need CDROM control ideas and samples

    Hello:
    I have PowerBASIC for DOS.
    I'm trying to write a couple routines to control a CDROM drive.
    1) A routine that polls the drive and returns a value
    when a disc is inserted
    2) A routine to eject the disc

    I have the ATAPI-5 Spec, which is handy, but at nearly 400 pages,
    it's a bit overwhelming.

    I'm hoping someone knows of some samples on this topic
    that I can learn from.

    Once solved, I will call the routines within a DOS Batch file.

    Thanks to all who respond!

    ------------------

  • #2
    Does your CD-ROM drive get a drive letter under DOS? Technically,
    you have several additional issues: (1) Is a disk inserted, (2)
    Is the disk formatted, and (3) What format does it have?

    DOS predates the development of CD-ROM drives, so a lot of those
    answers depend upon the driver software that you installed to
    access the drive, and any software that goes along with it. It
    might be best to search for forums and sites on the web where
    other players are addressing those issues.

    If DOS is giving you a drive letter, then you should be able to
    treat the CD-ROM drive as a removable hard drive. A read only
    drive or disk will indicate no free disk space. If no disk is
    installed, or it is unformatted, or using an incompatable format,
    you will probably get a Drive Not Ready or Drive Not Formatted
    error. But you probably won't see it, unless the device driver
    software thinks it is something you need to know.

    If you try to use a DIR$() command, possibly referencing a NUL
    file, and can detect the drive by its letter, then it is
    currently accessable to DOS and to your program. Whether you
    can write to it would again depend upon the drive, the CD
    disk, and now of course whether the driver permits format and
    write operations. If your program knows that the drive should
    be showing up, and it does not, then the program can take it on
    itself to communicate with the user to get the matter resolved.

    It's much more important to know what the device driver does for
    you than it is to concern yourself with hardware particulars and
    signals in and out of various ports - unless you intend to try
    and write your own driver. That's a very specialized area, and
    probably now where you intend to go. Again, some research on the
    web may help fill in the blanks.

    ------------------
    Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

    Comment


    • #3
      The BASIC routines should run in PC-DOS 7.1 with OAKCDROM.SYS and MSCDEX.EXE providing the DOS accessible drive letter. The fore mentioned files are dated 7-28-2000, and came from Norton Ghost 2001. The finished product may end up in a properly licensed DR-DOS 7.03 or 8.0.

      The disc to be inserted will be a known disc, meaning a known format with a known file on it to be read into flash memory. Once the file is in memory, the disc will be ejected.

      The drive is the Pioneer DVD-120S with “slot-in” loading. That means that I need not eject a tray first. Instead, a BASIC routine will be “monitoring” for a disc to be inserted, and upon insertion, copy the known file to flash, and eject the disc.

      That will conclude the routines I’ll put in the AUTOEXEC.BAT file, which will then pass control to the program that will interact with the data file in flash.

      Your response suggests that my ‘routines’ should interface with the driver, instead of directly to the IDE controller registers. That might explain why my efforts so far are ignored by the drive.

      I’ve found a COM file off the Internet that can do a disc eject, and I could probably search high and low and eventually locate a command line disc detect program as well, but then I learn nothing about the power and knowledge of controlling such hardware from a BASIC program. Additionally, I can’t always be sure about the EULA of something I download off the Internet. Although my task is at the hobby level now, it may be a part of something I license and sell later on.

      BTW: the DIR$() function sounds like a good suggestion. I will work with that and let you know. Thanks.


      ------------------

      Comment


      • #4
        Yes, the DIR$ function can be made to work:

        [TEST PROGRAM...]

        cls
        print "Waiting for disc..."
        10 filename$=dir$("D:")
        if len(filename$)=0 then 10
        print "Disc inserted !"

        [ACTUAL CODE COMPILED TO WAITDISC.EXE...]

        10 filename$=dir$("D:"):if len(filename$)=0 then 10

        Thanks for the tip!

        ------------------

        Comment


        • #5

          On 19 Jan 05, Steve Ranzinger wrote:

          Hello Steve,

          > 2) A routine to eject the disc
          >
          > I have the ATAPI-5 Spec, which is handy, but at nearly 400 pages,
          > it's a bit overwhelming.

          You can open/close your CDROM via the CDROM-driver (not MSCDEX) with
          IOCTL (function &h0D/&h0E).

          Regards,

          --------------
          / h o m a s
          ------------------
          email : [email protected] / mailto:[email protected][email protected]</A> (PGP-Key available)
          www : http://www.gohel.de / http://www.pbhq.de (PowerBASIC)
          chat : irc://irc.pbhq.de/#pbhq.cafe (Online-Chat for PB users only!)
          bbs : telnet://bbs.pbhq.de (historical access to the PBSOUND HQ BBS)
          ## CrossPoint/Agent R/C2478, via PBNEWS v0.49g (news.pbhq.de)
          http://www.gohel.de - http://www.gohel.net - http://www.pbhq.com

          Comment


          • #6
            You indicate you want essentially to have "low level" control of
            the CD-ROM drive. The problem is, that every implementation of
            new hardware requires new points of attachment to a computer, and
            since there are many different venders and products, each one has
            to incorporate a number of possible alternatives in case some other
            device got there first. To deal with the increasingly haphazard
            way that devices were being attached, Microsoft came up with Plug-
            N-Play, a specification that venders were to adopt and follow to
            guarantee that they would work under Windows.

            However, that sort of leaves DOS users in the dark and having to
            figure it out on their own. Now the DOS device drivers for any
            device are programmed in advance to search out for specific ports
            that a given device might plug into, and to provide a common
            interface that DOS can rely on that will make the given device
            seem of a certain type. Because DOS was not initially developed
            to support Read Only devices, a common techique for handling
            CD-ROM is to report 0 bytes of free disk space, which precludes
            unsupported efforts to write to Read Only media or drives. This
            false reporting is handled by the driver,

            Again, the driver comes into play when you chose to eject a
            cartirdge or disk. This is part of the Removable Media support,
            but you will not the lone exception, which is that you cannot
            automatically eject floppy disks, since they were not designed
            in that manner. Ralph's Interrupt List has long been known as
            the ultimate resource to hardware particulars of the PC, and
            it even appears as a resource in the download section of the
            PowerBasic web site. Here is a link to the first part:
            http://www.powerbasic.com/files/pub/asm/INTER61.ZIP

            In addition, you can search the forums, or look at the sample
            code in the download section for examples of how to eject
            disks or cartridges, as memory serves to tell me that this has
            been approached before. Excuse me if I elect not to carry out
            that research for you. Just realize that often the question
            you might ask next may have in fact been asked and answered
            before, and once aware of that fact, you should be able to find
            what you want. Ain't the Internet wonderful?

            ------------------
            Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

            Comment

            Working...
            X