1 /* This program sends an rk05 image out the serial port to the PDP8 restore
2 program. It will prompt for the file to send 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 The PDP8 end should be running before this program is started
8 On the PC ctrl-break will terminate the program
25 #define ARRAYSIZE(a) (sizeof(a) / sizeof(a[0]))
43 unsigned short temp
[2];
45 unsigned int chksum
= 0;
48 setup_config(&baud
,&two_stop
,serial_dev
);
51 strcpy(filename
,argv
[1]);
53 printf("Enter file name to send\n");
59 in
= fopen(filename
,"rb");
61 in
= fopen(filename
,"r");
64 fprintf(stderr
,"On file %s ",filename
);
65 perror("open failed");
70 /* For testing write to file, only works in unix version */
71 fd
= open("dat",O_RDWR
| O_CREAT
| O_TRUNC
,0666);
73 perror("Open failed on dat");
77 fd
= init_comm(serial_dev
,baud
,two_stop
);
83 if ((rc
= fread(temp
,2,2,in
)) < 2) {
86 perror("\nfile read failed\n");
89 /* Must be at start of block when data done */
90 if (count
!= 256 || rc
!= 0) {
91 printf("\nEarly end of file %d, %d\n",count
,rc
);
94 /* Send end of data flag and checksum */
98 buf
[2] = (chksum
& 0xfff) >> 8;
99 ser_write(fd
,(char *)buf
,3);
102 /* If start of new block send block flag */
106 ser_write(fd
,(char *)buf
,1);
108 if (sect
% 32 == 0) {
109 printf("Cyl %d\r",sect
/ 32);
113 chksum
+= temp
[0] + temp
[1];
115 buf
[1] = (temp
[0] >> 8) | (temp
[1] << 4);
116 buf
[2] = (temp
[1] >> 4);
117 ser_write(fd
,(char *)buf
,3);