Write a UDF CDR

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.

When trying to write in mode 4 at the start of the CloseSession function my CD-Writer green light goes flashing endlessly. However the error codes returned will be SS_COMP until somewhere trying to read again and then it tells 0x2, 0x4, 0x8 which I think means :

Logical unit not ready, long write in progress

The write is only 0x168 bytes long. How could it be long? I waited nearly 30 mins...

Seems it makes it crash i did tried with Nero Burning ROM which is installed on that PC and CD-Burning works fine.

I'm in the process of understanding UDF CDR code. I have seen many isues which make the code not usable.
- Cache MUST be flushed after a writepacket
- In writefiles function, all files data are loaded in RAM memory : If you write 10 files of 20MB, 200MB will be loaded in RAM. Not a realistic programming method.
- function writepacket sends data to the burner without check/retry algorythm. It may work with small amount of data but will NEVER work with big amount of data. It may work untill the burner cache is full. Then it will crash.
- Code needs more than few modifications. There are many issues that need to be corrected to make code usable to generate a true UDF compliant disc. Using "udf_test" tool from Philips helps a lot in this task.

Hello,
It is able to format the CD-R. But when i tried to write a file onto it,I got an error code "Out of memory".
In function SCSI2::WriteFiles , the flags of the icbTag i got by the function "SCSIRead" is equal to 0.

Can anyone suggest a way out to this problem?
I very much appreciate your responses.

well.. I don't know about DVD-writer
but I think it would work..
if the same problem still exist, look up the related document about DVD-writer or ATAPI document.
DVD-writer may differ from CD-writer in some commands.
Good luck to u.

I have downloaded this sample and tried executing it. It is able to detect the CD drive attached to my system. But when I tried to format it, it fails in the function SetWriteParameters() returning an error code
"SenseKey: 0X5,ASC = 0X24, ASCQ =0X0".

What does this error code indicate?
Can anyone please suggest a way out to this problem.

4. Needs to double check the write address and re-allocation buffer in the
write files routines. Note: The sync cache after write fixs the problem.
The next write address is then properly read.

--------------------------------------------
I can't understand what this words mean...
Can I get the explanation about this?
I need your help ...
It'll be very nice if you can help me..
--------------------------------------------
Answer:

To issue a SYNC_CACHE command after ATAPI write is to force the data in the buffer out to disc and update the track information. The read track information will then return the proper information, specially, the next available write address. Thus:

I modified your code to format a DVD-RAM (in Vista) However, vista is unable to read the disc afterwards. (It says its blank)

Here are my questions:

First: When you write the udf header you start at a location other than 0, why is that?
Second: How many blocks does the header take up?

My work around was somewhat interesting. I've used vista to format the DVD, then I opened the volume and copied the first 4096 blocks into a file on my hard drive. When I want a blank DVD, I simply copy the bytes back on to the volume. Do you see a major issue with this approach?

Hi,
This is Prashant from India. I have down load your sample application from codeproject.com. When I run this application, it is not detecting CD writer connected there to my system. On system I am using has WindowsXp OS, and Adaptec Drivers
1. aspi32.sys (ver. 4.71.2)
2. wowpost.exe (ver. 4.6(1021))
3. winaspi.dll (ver. 4.6(1021))
4. wnaspi32.dll (ver. 4.71.2)

Please let me know what shoud I do so using Adaptec driver this application will detect IDE CD Writer (IDE Sony CD writer.)