Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!usenet.ins.cwru.edu!pyrite.som.cwru.edu!crds From: crds@pyrite.som.cwru.edu (Glenn A. Emelko) Newsgroups: comp.sys.tandy Subject: PDD Information (1 of 2) Message-ID: <1990Jan8.070956.14284@usenet.ins.cwru.edu> Date: 8 Jan 90 07:09:56 GMT Sender: news@usenet.ins.cwru.edu Reply-To: crds@pyrite.som.cwru.edu (Glenn A. Emelko) Organization: WSOM CSG, CWRU, Cleve., OH Lines: 613 Also-Reply-To: crds@ncoast.uucp (Glenn A. Emelko) /* * This is the first of two postings; this contains the code that I used to * test the PDD. The second posting (to follow) contains some PD source * which I pulled from CI$, it's a basic program for the Model 100 to allow * you to do some basic I/O functions with it. I had to uuencode it because * of the long line lengths, otherwise there is no other coding on it, it's * a straight ASCII text file uuencoded. */ #include #include /* * This code is provided in an AS-IS form, no warranty expressed or implied * from the usage of this code, the correctness or completness of it or it's * writer, or anything else for that matter is given -- You are at your own * risk -- I recommend that this code be used to understand the basic I/O * format of the PDD, the method in which it sends and receives packets, and * how to properly structure those packets. Very little time went into the * writing and debugging process in this code; it was written in haste to * make a quick decision regarding use of this product as a low-cost data * logger. Results: we decided we didn't need a low cost data logger yet. * Have fun, happy hunting, feel free to contact me if you have any more * questions! * * Glenn A. Emelko * Performance Concepts, Inc. * 8250 Tyler Blvd. * Mentor, OH 44060 * (216) 974-9550 * */ /* * This is some C source code I used to talk to the PDD. Unfortunately I am * not able to provide the serial interface routines used because they are * proprietary to my company, however I believe they will be self explanitory * and you should have little trouble working with your own support code, and * I've seen a number of different interrupt driven RS232 sources out there. */ /* tchar1(&c1) - transmit character in c1 to RS232 device */ /* rchar1(&c1,&s1) - receive character in c1, status in s1, from RS232 */ /* #define HEXDUMP - if you wish to have HEX dump to file tt1.hex */ /* #define DUMPCOMMAND - if you wish to have commands dumped to display */ /* Define all of these so everyone can use them */ unsigned char buffer[4000]; unsigned char buff[500]; unsigned char fi[100]; unsigned char rss[200]; unsigned char qqs[10]; unsigned char qb[255]; int s,rs,rl,rp,rf,qp,qu,ck,qt; main() { int i,j,k,f; int c,stat; int address,data0,data1; int ic; unsigned char *bufp; address=0x3f8; data0=15; data1=3; /* COM1, 9600 baud 8,N,1 */ setup(&address,&data0,&data1); setdtr(); setrts(); data0=10; tout(&data0); c=0; while (c!=(int) '~') { bufp = buffer; f=0; gstat(&i); while ((i & 256)!=0) { rchar1(&c,&stat); *bufp++ = (unsigned char)c; gstat(&i); f=0; while (f++<1000 & (i & 256)==0) { gstat(&i); } } if (bufp!=buffer) { tputs(&buffer[0],(int) (bufp-buffer)); } c=0; if (kbhit()!=0) { c=(int)getch(); switch (c) { case (int)'[': { printf("dtr=0"); clrdtr(); break; } case (int)']': { printf("dtr=1"); setdtr(); break; } case (int)'7': { i=(int)c-48; c=(int)'Z'; tchar1(&c); c=(int)'Z'; tchar1(&c); c=i; tchar1(&c); c=0; tchar1(&c); c=255-i; tchar1(&c); c=0; tchar1(&c); c=13; tchar1(&c); break; } case (int)'~': break; case (int)'`': menu(); default: tchar1(&c); } } else c=0; } } tputs(b,l) unsigned char *b; int l; { unsigned char c; int i; FILE *f; i=l; #ifdef HEXDUMP f=fopen("tt1.hex","a+b"); #endif while (i-- >0) { c = *b++; if (c<32 || c>126) { if (c==13) printf("\n"); else printf("<%d>",(int) c); } else { printf("%c",c); } #ifdef HEXDUMP fprintf(f,"%c",c); #endif } #ifdef HEXDUMP fclose(f); #endif } menu() { unsigned char c; printf("A = Append to File\n"); /* 160 */ printf("C = Close File\n"); /* 190 */ printf("D = Directory\n"); /* 125 */ printf("F = Format Disk\n"); /* 220 */ printf("G = Get Data\n"); /* 170 */ printf("I = Find First\n"); /* 130 */ printf("K = Kill File\n"); /* 210 */ printf("N = Next File\n"); /* 140 */ printf("P = Put Data\n"); /* 200 */ printf("R = Read from File\n"); /* 150 */ printf("S = Status of drive\n"); /* 110 */ printf("W = Write to File\n"); /* 180 */ c=0; while (c!='X') { c=getch(); s=0; switch (c) { case 'A': /* 160 */ GAppend(); break; case 'C': /* 190 */ GClose(); break; case 'D': /* 125 */ GDir(); break; case 'F': /* 220 */ GFormat(); break; case 'G': /* 170 */ GGet(); break; case 'I': /* 130 */ GFind_first(); break; case 'K': /* 210 */ GKill(); break; case 'N': /* 140 */ GFind_Next(); break; case 'P': /* 200 */ GPut(); break; case 'R': /* 150 */ GRead(); break; case 'S': /* 110 */ GStatus(); break; case 'W': /* 180 */ GWrite(); break; case 'X': break; default: break; } } } delay() { int i; for(i=0;i<100000;i++); return; } yesno() { unsigned char c; c=getch(); if (c=='y' || c=='Y') return(1); if (c=='n' || c=='N') return(0); return(yesno()); } Ggetstat() { int c1,c2,c3,c4; int s1; int tt; c1=tt=0; while (c1!=18 && tt++<5) rchar1(&c1,&s1); if (c1!=18) { rs=0; return; } rchar1(&c2,&s1); rchar1(&c3,&s1); rchar1(&c4,&s1); rs = c1; rp = c3; return; } Gstat_q() { s=1; GStatus(); if (rs==0 || rp!=0) s=0; return; } prep_f(bp) unsigned char *bp; { unsigned char tmpb[30]; unsigned char *t1; unsigned char *t2; t1=bp; t2=tmpb; while (*t1!=(unsigned char)0 && *t1!='.') { *t2++ = *t1++; } while ((int)(t2-tmpb)<6) *t2++ = ' '; while (*t1!=(unsigned char)0) *t2++ = *t1++; while ((int)(t2-tmpb)<24) *t2++ = ' '; *t2++ = 'F'; *t2++ = (unsigned char) qp; t2=tmpb; t1=bp; while ((int)(t2-tmpb)<26) *t1++ = *t2++; } chk_st1() { int c1,c2,s1; unsigned char *rssp; *rss=0; rchar1(&c1,&s1); rchar1(&c2,&s1); rs=c1; rl=c2; if (rs!=17 || rl!=28) { if (rs==18 && rl>0) { rchar1(&c1,&s1); rchar1(&c2,&s1); rp=c2; return; } return; } else { rssp=rss; while((rssp-rss)<28) { rchar1(&c2,&s1); *rssp++ = (unsigned char) c2; } rchar1(&c2,&s1); ck=c2; rf=(int) *rss; } } chk_stat() { Gstat_q(); if (s==0) return; *buff = 0; qu=0; prep_f(buff); command(buff,26); chk_st1(); if (rs!=17) { errorcode(); return; } if (rf==0) { printf("File not found\n"); return; } printf("%.10s %5d %3d\n",rss,(int) ((256* (int)*(rss+25))+(int)*(rss+26)), (int)*(rss+27)); return; } command(qs,qsl) unsigned char *qs; int qsl; { unsigned char *qp; unsigned char *ip; int i,ck; ip = qs; qp = qb; *qp++ = 'Z'; *qp++ = 'Z'; *qp++ = qu; *qp++ = (unsigned char) qsl; for(i=0;i"); gets(buff); if (strlen(buff)==0) { printf("\nClosing file..."); qu=2; command("",0); Ggetstat(); if (rs==18 && rp==0) { printf("File closed\n"); return; } errorcode(); return; } s=1; qu=4; command(buff,strlen(buff)); Ggetstat(); if (rs!=18 || rp!=0) { errorcode(); return; } } } GAppend() { qp=2; Gopen(); if (s==0) return; if (rf!=0 && rp==0) { printf("Ready to append to file\n"); GPut(); return; } errorcode(); return; }