Path: utzoo!attcan!uunet!spool.mu.edu!sdd.hp.com!hp-pcd!hpfcso!hpfcdj!kinsell From: kinsell@hpfcdj.HP.COM (Dave Kinsell) Newsgroups: comp.sys.hp Subject: Re: cdrom questions Message-ID: <17330026@hpfcdj.HP.COM> Date: 31 Jan 91 02:28:37 GMT References: <1991Jan23.192953.28335@eye.com> Organization: Hewlett Packard -- Fort Collins, CO Lines: 195 >1. VERY IMPORTANT: Is it possible to play "normal" audio cd's with these > things? >Paul B. Booth (paul@eye.com) (...!hplabs!hpfcla!eye!paul) I realize you're asking about the HP-IB version of the player, but I'll post a program for the SCSI version in case other people would be interested. This *really* is unsupported software, and I regretfully am not in a position to dribble out information from the 120 page OEM manual. There has never been an intent to document the audio commands on this device. Regards Dave Kinsell ------------------------------------------------------------------------------ /* Program scsi_play, used for playing selected tracks from an audio CD-ROM on Hewlett-Packard Series 300 and 400 computers. Specify starting track number with -t option (default is 1). Specify number of tracks to play with -n option (default is 0). If 0 tracks are chosen, entire disc is played. Use -h to halt playing. Not all audio CDs start at track 1! Requires character device as a parameter. Requires root privilege to run. Works only with Toshiba XM-3201 SCSI CD-ROM player. Tested with S300/S400 HP-UX, rev 7.0 Supplied without warranty or support of any kind. */ #include #include struct scsi_cmd_parms track_search = { 10, 1, 500, 0xc0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80 }; struct scsi_cmd_parms play_audio = { 10, 1, 500, 0xc1, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80 }; struct scsi_cmd_parms read_disc_info = { 10, 1, 500, 0xc7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; struct scsi_cmd_parms stop = { 6, 1, 500, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00 }; struct scsi_cmd_parms status = { /* not used */ 10, 1, 500, 0xc6, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; main(argc,argv) int argc; char *argv[]; { int fd, c, ret, first_track= 1, last_track, halt=0, num_tracks=0; int first_avail, last_avail; unsigned char buf[256]; char *name, *begin = NULL, *num = NULL; extern int opterr, optind; extern char *optarg; opterr=0; while (( c = getopt(argc, argv, "Hht:T:n:N:")) != EOF) { switch (c) { case 'T': case 't': begin = optarg; sscanf(begin,"%d",&first_track); break; case 'N': case 'n': num = optarg; sscanf(num,"%d",&num_tracks); break; case 'H': case 'h': halt=1; break; default: usage(argv[0]); } } if ((name = argv[optind++])==NULL || argv[optind] != NULL) usage(argv[0]); if ((fd=open(name, 0))<0) { perror("play: error in open"); exit(1); } if(halt==1) { set_command(fd); ioctl(fd, SIOC_SET_CMD, &stop); /* stop playing */ ret = read(fd, buf, 0xff); close(fd); exit(0); } set_command(fd); ioctl(fd, SIOC_SET_CMD, &read_disc_info); /* find first,last */ ret = read(fd, buf, 0xff); clear_command(fd); ret = read(fd, buf, 0xff); first_avail = convy(buf[0]); /* comes out in bcd */ last_avail = convy(buf[1]); printf("first track available =%4i last track available = %4i\n", first_avail, last_avail); last_track = first_track + num_tracks-1; if(num_tracks == 0) last_track = last_avail; printf("first track selected =%4i last track selected = %4i\n",first_track,last_track); if(first_track < first_avail) { printf("Starting track out of range\n"); exit(1); } if(last_track > last_avail) { printf("Ending track out of range\n"); exit(1); } track_search.command[2] = (unsigned char)(convx(first_track) ); /* requires bcd */ play_audio.command[2] = (unsigned char)(convx(last_track+1) ); if(last_track == last_avail) play_audio.command[2] = 0 ; /* play to end */ set_command(fd); ioctl(fd, SIOC_SET_CMD, &track_search); /* seek to track */ ret = read(fd, buf, 0xff); ioctl(fd, SIOC_SET_CMD, &play_audio); /* and play */ ret = read(fd, buf, 0xff); close(fd); exit(0); } usage(name) char *name; { fprintf(stderr,"usage: %s [-h ] [-t ] [-n ] raw_device_file\n",name); exit(1); } int convx(number) /* do an integer to bcd conversion */ int number; { return (number+6*(number/10)) & 0xff ; } int convy(number) /* do a bcd to integer conversion */ int number; { return (number/16)*10 + number%16; } int set_command(fd) /* set command mode */ int fd; { int flag=1, ret; if((ret = ioctl(fd, SIOC_CMD_MODE, &flag))<0) { perror("error in ioctl setup CMD MODE"); exit(1); } } int clear_command(fd) /* clear command mode */ int fd; { int flag=0, ret; if((ret = ioctl(fd, SIOC_CMD_MODE, &flag))<0) { perror("error in ioctl setup CMD MODE"); exit(1); } }