Hi all, especially J�rg!
As there is no such thing as C2-scans for DVD at the moment, I added an
analyze funtion to readcd. It displays a variable count of read speeds
when using readcd. In the end it can be used to display a nice graph
using gnuplot. This is at least a better indication of the
DVD+-R(W) write quality than the overall write speed.
The information is printed to stdout as opposed to all other messages
from readcd so that the essential data for gnuplot can be redirected
to a file and a simple
readcd dev=1,1,0 f=/dev/null -noerror retries=0 analyze=800 > ~/Dokumente/readcd.dat
gnuplot> plot "/home/plail/Dokumente/readcd.dat" w l
displayed a nice graph with 800 measure points.
The feature is disabled by default of course.
Any comments are welcome.
regards
Markus
--- cdrtools-2.1/readcd/readcd.c Sat Nov 30 17:43:53 2002
+++ cdrtools-2.0_analyze/readcd/readcd.c Sun Jan 19 18:10:10 2003
@@ -153,6 +153,7 @@
/*#define MAX_RETRY 32*/
#define MAX_RETRY 128
+#define DEF_ANALYZE -1
int help;
int xdebug;
@@ -168,6 +169,7 @@
BOOL nocorr;
BOOL notrunc;
int retries = MAX_RETRY;
+int analyze = DEF_ANALYZE;
struct scsi_format_data fmt;
@@ -199,12 +201,13 @@
error("\t-notrunc do not truncate outputfile in read mode\n");
error("\tretries=# set retry count (default is %d)\n", retries);
error("\t-overhead meter SCSI command overhead times\n");
+ error("\tanalyze=# print read-speed at # locations (default is %d)\n", analyze);
error("\n");
error("sectors=0-0 will read nothing, sectors=0-1 will read one sector starting from 0\n");
exit(ret);
}
-char opts[] = "debug#,d+,kdebug#,kd#,timeout#,quiet,q,verbose+,v+,Verbose+,V+,x+,xd#,silent,s,help,h,version,dev*,sectors*,w,c2scan,fulltoc,clone,noerror,nocorr,notrunc,retries#,f*,speed#,overhead";
+char opts[] = "debug#,d+,kdebug#,kd#,timeout#,quiet,q,verbose+,v+,Verbose+,V+,x+,xd#,silent,s,help,h,version,dev*,sectors*,w,c2scan,fulltoc,clone,noerror,nocorr,notrunc,retries#,f*,speed#,overhead,analyze#";
EXPORT int
main(ac, av)
@@ -250,7 +253,7 @@
&fulltoc, &clone,
&noerror, &nocorr,
¬runc, &retries, &filename,
- &speed, &dooverhead) < 0) {
+ &speed, &dooverhead, &analyze) < 0) {
errmsgno(EX_BAD, "Bad flag: %s.\n", cav[0]);
usage(EX_BAD);
}
@@ -513,6 +516,33 @@
return (1000*sec + (usec / 1000));
}
+/*
+ * Return milliseconds since start time, but be silent this time.
+ */
+LOCAL int
+prstats_silent()
+{
+ int sec;
+ int usec;
+ int tmsec;
+
+ if (gettimeofday(&stoptime, (struct timezone *)0) < 0)
+ comerr("Cannot get time\n");
+
+ sec = stoptime.tv_sec - starttime.tv_sec;
+ usec = stoptime.tv_usec - starttime.tv_usec;
+ tmsec = sec*1000 + usec/1000;
+#ifdef lint
+ tmsec = tmsec; /* Bisz spaeter */
+#endif
+ if (usec < 0) {
+ sec--;
+ usec += 1000000;
+ }
+
+ return (1000*sec + (usec / 1000));
+}
+
LOCAL void
dorw(scgp, filename, sectors)
SCSI *scgp;
@@ -1033,12 +1063,15 @@
char filename[512];
char *defname = NULL;
FILE *f;
- long addr = 0L;
+ long old_addr = 0L, addr = 0L;
long num;
long end = 0L;
long start = 0L;
long cnt = 0L;
- int msec;
+ long next_measure = 0L;
+ long secs_per_measure = 0L;
+ double speed;
+ int old_msec = 0, msec;
int err = 0;
BOOL askrange = FALSE;
BOOL isrange = FALSE;
@@ -1121,6 +1154,13 @@
if (gettimeofday(&starttime, (struct timezone *)0) < 0)
comerr("Cannot get start time\n");
+ if (analyze != -1) {
+ if (end < analyze)
+ secs_per_measure = 1;
+ else
+ secs_per_measure = end / analyze;
+ }
+
for(;addr < end; addr += cnt) {
if (didintr)
comexit(exsig); /* XXX besseres Konzept?!*/
@@ -1128,7 +1168,24 @@
if ((addr + cnt) > end)
cnt = end - addr;
- error("addr: %8ld cnt: %ld\r", addr, cnt);
+ if (analyze != -1) {
+ if (addr > next_measure) {
+ msec = prstats_silent();
+ if ((msec - old_msec)== 0) /* Avoid division by zero */
+ msec = old_msec + 1;
+ speed = ((addr - old_addr)/(1024.0/secsize)) / (0.001*(msec - old_msec));
+
+ error("addr: %8ld cnt: %ld analyze:", addr, cnt);
+ printf("%7ld %7.1f\n", addr, speed);
+ error("\r");
+ next_measure += secs_per_measure;
+ old_addr = addr;
+ old_msec = msec;
+ }
+ error("addr: %8ld cnt: %ld\r", addr, cnt, speed);
+ } else {
+ error("addr: %8ld cnt: %ld\r", addr, cnt);
+ }
scgp->silent++;
if ((*rfunc)(scgp, rp, Sbuf, addr, cnt) < 0) {