Click here to Skip to main content
Click here to Skip to main content
Go to top

Write a UDF CDR

, 22 Jul 2003
Rate this:
Please Sign up or sign in to vote.
How to write a CDR in UDF

Introduction

Some electronic devices need to use CDR as storage media, and you have to append several files each time before the space is used out. In this case, UDF is a good solution, since for each writing, only 7 logic blocks of overhead are used. (Multisession CDs use several minutes for each session's leadout)

How to use the demo

(You need WNASPI32.dll to run the demo, which could be downloaded from Ahead.)
  • Select the CDR drive you want to write to.
  • Insert a blank disc, "Format" it.
  • Browse to select files, and write to the disc. (Now you can view the files using DirectCD).
  • You can list the content of the CDR, and restore files to hard disk
  • Close Session, now any CD drive can read it..

How to use the source code

//Create a variable for your drive
SCSI2 m_drive;
//m_HA:HostAdpaterNumber,m_ID:SCSI ID,m_LUN:LogicUnitNumber
m_drive.SCSISelectDevice(m_HA,m_ID,m_LUN);
//For a blank CDR, you need to format it 
m_drive.FormatDisc("VOL1");
//Then you can write files onto it
m_drive.WriteFiles("Test1.bmp");
//Append more files here...
//
//After you have writen ALL the files, close the session
m_drive.CloseSession();
//Now it's readable by regular CDROM drive.

Some useful functions

SCSIRead()      //Read data from CDR
WritePacket()      //Write packets to CDR
ReadTrackInfo()      //Read track info, like next writable address
ReadDiskInfo()      //Read disc info, like capacity
TestUnitReady()      //See if the drive is ready
LoadUnload()      //Eject/Close the tray
SetWriteParameters()    //Set write mode
SCSISetSpeed()      //Set read/write speed
ListFiles()      //List files on the CDR
SaveFileAs()      //Save file on CDR to hard disk

If you want to know more inside stuff

Things you need to have:
  • SCSI command block structure (ANSI X3.131-1994)
  • SCSI multimedia commands-2 (ANSI NCITS 333-2000)
  • OSTA specs: ECMA-167, Universal Disk Format Specification, ECMA-119
Things you need to know:
  • SCSI2 block command structure
  • Use of ASPI
  • Concepts about CDR: track, session, logical blocks, PMA, ATIP, TOC, write modes...
  • UDF(Volume structure, file system)

More info at my website.

Revision History

  • Ver 1.01
    • More comments, some code clean up
    • New function: ListFiles()
    • New function: SaveFileAs()
  • Ver 1.02
    • Some changes on the demo application

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

spotofleopard
Engineer
United States United States
Wheels I reinvented on various embedded systems
 
*License Plate Reader
*TCP/IP stack
*Web Server
*HTTP/FTP/SMTP client
*Ethernet/SCSI/USB drivers
*FAT32/UDF file system
*JPEG/MJPEG encoder

Comments and Discussions

 
GeneralRe: How to read VAT ICB? PinsussAnonymous21-Oct-03 16:16 
QuestionWhy Can I Record CD? Pinmemberryushark27-Jan-03 14:36 
AnswerRe: Why Can I Record CD? PinmemberChristian Graus27-Jan-03 14:48 
GeneralRe: Why Can I Record CD? PinmemberMike Nordell27-Jan-03 15:48 
Christian Graus wrote:
> ATAPI DRIVE IS NOT SUPPORTED IN CURRENT VERSION
 
In other words, when this was first posted, it contained software which the author did not have the right to distribute, and he removed it when this was pointed out to him.

 
Is that a fact?
 
From what I read from the article, he made just one (fatal) mistake, and that was using only the ASPI API. Had he used any of the the published ASPI <-> SPTI (and make no mistake, SPTI is what is used even for ATAPI devices on NT kernel based operating systems) I believe this would have worked like a charm for almost any ATAPI CD-R/W drive.
 
I've got some GPL'd source to use ASPI calls with very little source code change to instead access SPTI. I'm not interested in hosting it myself, but should anyone else want it, you know how to reach me.
 
It works like a charm - I've used it for CDRecord/cdrtools for several years now. Hell, I've even got a full CD-buring/reading incl. MP3 encoding and decoding suite on one single floppy disk. With enough room to spare to put some MP3'd heavy metal on it! Smile | :)
 
I have never tried it for packet writing since I 1) never had the need, and 2) haven't bothered to look into how UDF works (which I must give a lot of credit to the author of this article, to have displayed the stamina to research it, put it in source and write an - albeit short - article about it), but I see no reason whatsoever it shouldn't work.
 

GeneralDemo Project File Problem -- no rc file PinsussAnonymous27-Jan-03 4:28 
GeneralRe: Demo Project File Problem -- no rc file Pinmemberryushark27-Jan-03 14:28 
GeneralATAPI PinmemberCodegg12349-Dec-02 8:19 
GeneralRe: ATAPI PinsussKochise16-Dec-02 23:56 
GeneralRe: ATAPI PinmemberLailornd21-Dec-02 0:53 
GeneralRe: ATAPI PinmemberHongfeng31-Dec-02 11:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 23 Jul 2003
Article Copyright 2002 by spotofleopard
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid