1 /* This program receives an rk05 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];
47 setup_config(&baud
,&two_stop
,serial_dev
);
50 strcpy(filename
,argv
[1]);
52 printf("Enter file name to receive\n");
58 out
= fopen(filename
,"wb");
60 out
= fopen(filename
,"w");
63 fprintf(stderr
,"On file %s ",filename
);
64 perror("open failed");
69 /* For testing read from file, only works in unix version */
70 fd
= open("dat",O_RDONLY
,0666);
72 perror("Open failed on dat");
76 fd
= init_comm(serial_dev
,baud
,two_stop
);
82 c
= ser_read(fd
,(char *)buf
,sizeof(buf
));
84 perror("Serial read failed");
87 for (i
= 0; i
< c
; i
++) {
95 temp
= temp
| (buf
[i
] << 8);
96 if (((temp
+ chksum
) & 0xfff) != 0) {
97 printf("\nChecksum mismatch %x %x\n",temp
,chksum
);
104 if (buf
[i
] != 0xff && buf
[i
] != 0xfd) {
105 if (buf
[i
] == 0xfe) {
109 printf("\nMissing start of block flag\n");
115 printf("\nsector %d, cyl %d side %d sect %d bad\n",
116 sect
,sect
/ 32, (sect
& 16) >> 4, sect
% 16);
125 temp
= (temp
| (buf
[i
] << 8)) & 0xfff;
126 fwrite(&temp
,2,1,out
);
127 chksum
= chksum
+ temp
;
132 temp
= (temp
| (buf
[i
] << 4)) & 0xfff;
133 fwrite(&temp
,2,1,out
);
134 chksum
= chksum
+ temp
;
140 if (sect
% 32 == 0) {
141 printf("Cyl %d\r",sect
/ 32);