988f1652777101fa0d64abe150c2d2c143bffbd6
1 /* This program receives an rx01 image from the serial port from the PDP8 dump
2 program. It will prompt for the file to receive or use first command
3 line argument. It needs a config file dumprest.cfg or $HOME/.dumprest.cfg
4 with the format defined in config.c
6 This program should be running before the PDP8 end is started.
8 On the PC ctrl-break will terminate the program
25 #define ARRAYSIZE(a) (sizeof(a) / sizeof(a[0]))
42 unsigned char buf
[200];
49 setup_config(&baud
,&two_stop
,serial_dev
);
52 strcpy(filename
,argv
[1]);
54 printf("Enter file name to receive\n");
60 out
= fopen(filename
,"wb");
62 out
= fopen(filename
,"w");
65 fprintf(stderr
,"On file %s ",filename
);
66 perror("open failed");
71 /* For testing read from file, only works in unix version */
72 fd
= open("dat",O_RDONLY
,0666);
74 perror("Open failed on dat");
78 fd
= init_comm(serial_dev
,baud
,two_stop
);
85 c
= ser_read(fd
,(char *)buf
,sizeof(buf
));
87 perror("Serial read failed");
90 for (i
= 0; i
< c
; i
++) {
91 chksum
= chksum
+ buf
[i
];
93 /* - Checksum at end */
97 printf("Single density disk (RX01)\n");
101 printf("Double density disk (RX02)\n");
105 printf("Unknow or quad density, not able to dump %o\n",buf
[i
]);
113 if ((chksum
& 0xff) != 0) {
114 printf("\nChecksum bad %x\n",chksum
& 0xff);
120 /* Start of sector flag */
121 if (buf
[i
] == 0xff || buf
[i
] == 0xfd) {
127 /* How about checksum flag */
128 if (buf
[i
] == 0xfe) {
132 printf("\nMissing start of block flag\n");
146 printf("\nTrack %d sector %d bad\n", track
,buf
[i
]);
149 fseek(out
, ((long)track
*26 + buf
[i
] - 1) * sect_size
, SEEK_SET
);
154 fwrite(&buf
[i
],1,1,out
);
156 if (count
== sect_size
) {
159 if (scnt
% 26 == 0) {
160 printf("Track %d\r",scnt
/ 26);