>>>> >>>>#define PP 0x320 >>>>#define NO1 14 >>>>#define NO2 350 >>>> >>>>#include <stdio.h> >>>>#include <conio.h> >>>>#include <dos.h> >>>>#include <io.h> >>>>#include <stdlib.h> >>>>#include <bios.h> >>>> >>>>void main() >>>>{ >>>> FILE *fop; >>>> int t; >>>> int i,j,k,l,i1,j1,l1,k1,zero,j2,l2,k2,last; >>>> unsigned char ch ,comno,scale_type,baud; >>>> >>>> textbackground(BLUE); >>>> window(1,1,80,25); >>>> clrscr(); >>>> gotoxy(30,2); >>>> printf("P A N D Industries Co."); >>>> >>>> gotoxy(20,5); >>>> printf("Enter COM Port No.:< 1:com1 , 2:com2 >"); >>>> do >>>> { >>>> comno = getch()-'1'; >>>> } while((comno != 0)&&(comno != 1)); >>>> putch(comno+'1'); >>>> >>>> gotoxy(20,10); >>>> printf("Enter Scale Type :< 1:Bascool , 2:Scale >"); >>>> do >>>> { >>>> scale_type= getch()-'0'; >>>> } while((scale_type!= 1)&&(scale_type!= 2)); >>>> putch(scale_type+'0'); >>>> >>>> gotoxy(20,15); >>>> printf("Enter Baud Rate :< 1:2400, 2:4800 bps >"); >>>> do >>>> { >>>> baud= getch()-'0'; >>>> } while((baud!= 1)&&(baud!= 2)); >>>> putch(baud+'0'); >>>>//.................................................................... >>>> if( baud==2) bioscom(0,0xc3,comno); >>>> else bioscom(0,0xa3,comno); >>>> >>>> clrscr(); >>>> >>>> gotoxy(30,5); >>>> printf("P A N D Industries Co."); >>>> gotoxy(20,8); >>>> printf("Test Program For Reading Weight From Serial Port"); >>>> gotoxy(20,10); >>>> if( scale_type==1) printf(" COM %d: %d bps Bascool",comno+1,baud*2400); >>>> else printf(" COM %d: %d bps Scale",comno+1,baud*2400); >>>> >>>> if( scale_type==1) // Bascool >>>> while(!kbhit()) >>>> { >>>> while ( ( bioscom(2,0,comno) & 0xff ) !=0xbb && !kbhit()) ; >>>> if(!kbhit()) >>>> { >>>> gotoxy(20,15); >>>> ch = bioscom(2,0,comno) & 0xff ; >>>> if (ch==0xe0 || ch==0xf0 ) >>>> ch = bioscom(2,0,comno) & 0xff ; >>>> if(ch) printf("total weight = %x",ch); >>>> else printf("total weight = "); >>>> ch = bioscom(2,0,comno) & 0xff ; >>>> printf("%x",ch>>4); >>>> printf("."); >>>> printf("%x",ch%16); >>>> ch = bioscom(2,0,comno) & 0xff ; >>>>// ch=ch>>4; >>>> printf("%02x ",ch ); >>>> } >>>> } >>>> else // Scale >>>> while(!kbhit()) >>>> { >>>> while ( (( bioscom(2,0,comno) & 0xff ) !=0xbb )&&!kbhit()) ; >>>> gotoxy(20,15); >>>> >>>> ch = bioscom(2,0,comno) & 0xff ; >>>> if (ch==0xe0 || ch==0xf0 ) >>>> ch = bioscom(2,0,comno) & 0xff ; >>>> if(ch) printf("total weight = %x",ch); >>>> else printf("total weight = "); >>>> //printf("total weight = %x.",ch); >>>> ch = bioscom(2,0,comno) & 0xff ; >>>> printf("%x",ch>>4); >>>> printf("."); >>>> printf("%x",ch%16); >>>> //printf("%02x",ch ); >>>> ch = bioscom(2,0,comno) & 0xff ; >>>> //ch=ch>>4; >>>> printf("%02x",ch ); >>>> printf(" "); >>>> } >>>> textbackground(BLACK); >>>> window(1,1,80,25); >>>> clrscr(); >>>> >>>>} >>>> >>>>