Click here to Skip to main content
Click here to Skip to main content

Write a UDF CDR

By , 22 Jul 2003
 

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)

About the Author

spotofleopard
Engineer
United States United States
Member
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

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionWhat's mean this error code? Pinmemberholysky10019 May '04 - 19:20 
GeneralDVD RAM Format PinsussAnonymous12 May '04 - 5:48 
GeneralCD writer is not detecting PinsussPrashant N12 Apr '04 - 20:39 
GeneralLast block information Pinmemberkiran_128 Apr '04 - 2:47 
Questionhow to write a directory Pinmembernicho9 Mar '04 - 22:00 
GeneralDisc manufacturer PinsussAnonymous13 Feb '04 - 12:39 
Generalsample code is not for ATAPI drive, suggested fixes Pinmemberfkking17 Jan '04 - 13:23 
GeneralWrite Error Pinmemberpigy30 Nov '03 - 21:22 
QuestionWhat mmc command not support ATAPI? PinsussAnonymous9 Nov '03 - 16:26 
GeneralFormat a CDR with DELPHI Pinmembermiximax19 Aug '03 - 4:14 
GeneralSector Write in CD Pinmembersamesky16 Aug '03 - 20:59 
Generalburning a CD-R disk using a packet-writing PinmemberRPMcoffee14 Jul '03 - 17:10 
Generalfound au dio cd burner source code PinsussAnonymous28 Mar '03 - 14:00 
Questionwhat is your OS? (null) PinsussAnonymous6 Feb '03 - 20:31 
GeneralCOMMAND SEQUENCE ERROR!! PinsussAnonymous6 Feb '03 - 15:26 
QuestionHow to read VAT ICB? PinsussAnonymous5 Feb '03 - 13:27 
QuestionWhy Can I Record CD? Pinmemberryushark27 Jan '03 - 14:36 
GeneralDemo Project File Problem -- no rc file PinsussAnonymous27 Jan '03 - 4:28 
GeneralATAPI PinmemberCodegg12349 Dec '02 - 8:19 
GeneralUDF file size limit PinsussMark Gargett10 Oct '02 - 22:10 
GeneralATAPI drive PinmemberHongfeng3 Oct '02 - 7:34 
Questionhow about ISO and CDA ? PinmemberMario M.3 Oct '02 - 0:29 
Questioncan not format disc PinsussAnonymous24 Sep '02 - 19:38 
GeneralProblem Pinmemberchen23 Sep '02 - 23:34 
GeneralNice to know how it works, but... PinsussKochise23 Sep '02 - 0:35 
GeneralLegality... PinmemberChristian Graus22 Sep '02 - 17:46 
QuestionA Little Dangerous....? PinmemberFred21 Sep '02 - 4:42 
GeneralGood~~ PinmemberLeaves21 Sep '02 - 4:17 

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

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 23 Jul 2003
Article Copyright 2002 by spotofleopard
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid