Click here to Skip to main content
15,867,568 members
Articles / Desktop Programming / MFC

Write a UDF CDR

Rate me:
Please Sign up or sign in to vote.
4.82/5 (12 votes)
22 Jul 2003CPOL1 min read 252.2K   2.5K   39   91
How to write a CDR in UDF

Image 1

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)


Written By
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: Demo Project File Problem -- no rc file Pin
ryushark27-Jan-03 14:28
ryushark27-Jan-03 14:28 
GeneralATAPI Pin
Codegg12349-Dec-02 8:19
Codegg12349-Dec-02 8:19 
GeneralRe: ATAPI Pin
Kochise16-Dec-02 23:56
Kochise16-Dec-02 23:56 
GeneralRe: ATAPI Pin
Lailornd21-Dec-02 0:53
Lailornd21-Dec-02 0:53 
GeneralRe: ATAPI Pin
spotofleopard31-Dec-02 11:29
spotofleopard31-Dec-02 11:29 
GeneralRe: ATAPI Pin
Kochise2-Jan-03 0:17
Kochise2-Jan-03 0:17 
GeneralRe: ATAPI Pin
Tuan Hung26-Apr-05 18:39
Tuan Hung26-Apr-05 18:39 
GeneralUDF file size limit Pin
snodgrass10-Oct-02 22:10
snodgrass10-Oct-02 22:10 
GeneralRe: UDF file size limit Pin
mgargett14-Oct-02 5:46
mgargett14-Oct-02 5:46 
GeneralRe: UDF file size limit Pin
spotofleopard14-Oct-02 11:16
spotofleopard14-Oct-02 11:16 
GeneralATAPI drive Pin
spotofleopard3-Oct-02 7:34
spotofleopard3-Oct-02 7:34 
GeneralRe: ATAPI drive Pin
chisoft8-Oct-02 22:40
chisoft8-Oct-02 22:40 
Questionhow about ISO and CDA ? Pin
Mario M.3-Oct-02 0:29
Mario M.3-Oct-02 0:29 
AnswerRe: how about ISO and CDA ? Pin
spotofleopard3-Oct-02 3:43
spotofleopard3-Oct-02 3:43 
GeneralRe: how about ISO and CDA ? Pin
Mario M.3-Oct-02 12:22
Mario M.3-Oct-02 12:22 
GeneralRe: how about ISO and CDA ? Pin
tootall9-Feb-03 4:16
tootall9-Feb-03 4:16 
GeneralRe: how about ISO and CDA ? Pin
fengrxr3-Jun-03 16:31
fengrxr3-Jun-03 16:31 
Questioncan not format disc Pin
Anonymous24-Sep-02 19:38
Anonymous24-Sep-02 19:38 
AnswerRe: can not format disc Pin
spotofleopard25-Sep-02 3:41
spotofleopard25-Sep-02 3:41 
GeneralProblem Pin
chen23-Sep-02 23:34
chen23-Sep-02 23:34 
GeneralRe: Problem Pin
spotofleopard24-Sep-02 5:52
spotofleopard24-Sep-02 5:52 
GeneralRe: Problem Pin
chen2-Oct-02 20:08
chen2-Oct-02 20:08 
GeneralRe: Problem Pin
Anonymous9-Oct-02 3:58
Anonymous9-Oct-02 3:58 
GeneralRe: Problem Pin
chen9-Oct-02 5:13
chen9-Oct-02 5:13 
GeneralRe: Problem Pin
spotofleopard9-Oct-02 5:46
spotofleopard9-Oct-02 5:46 

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

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