f24533b6262e860a32d12159943d8a1142b4f3c5
1 /* This program sends a file out the serial port to the PDP8. Use for
2 sending paper tape images.
3 It will prompt for the file to send or use first command
4 line argument. It needs a config file dumprest.cfg or $HOME/.dumprest.cfg
5 with the format defined in config.c
7 The PDP8 end should be running before this program is started
9 On the PC ctrl-break will terminate the program
26 #define ARRAYSIZE(a) (sizeof(a) / sizeof(a[0]))
43 unsigned char buf
[256];
47 setup_config(&baud
,&two_stop
,serial_dev
);
50 strcpy(filename
,argv
[1]);
52 printf("Enter file name to send\n");
58 in
= fopen(filename
,"rb");
60 in
= fopen(filename
,"r");
63 fprintf(stderr
,"On file %s ",filename
);
64 perror("open failed");
69 /* For testing write to file, only works in unix version */
70 fd
= open("dat",O_RDWR
| O_CREAT
| O_TRUNC
,0666);
72 perror("Open failed on dat");
76 fd
= init_comm(serial_dev
,baud
,two_stop
);
80 while(!terminate
&& !feof(in
)) {
81 if ((rc
= fread(buf
,1,sizeof(buf
),in
)) < 0) {
82 perror("\nfile read failed\n");
86 ser_write(fd
,(char *)buf
,rc
);
89 printf("Send aborted, %d bytes sent\n",count
);
91 printf("Done, sent %d bytes (waiting for buffer to flush)\n",count
);