⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pakecho.c

📁 HT系列掌机部分功能测试程序(含源码)
💻 C
字号:
/*
  Project must include
          commplus.c            */

  #include "commplus.h"
  #include <stdio.h>

  int ESCorGopressed();
  int blkcmp(unsigned char far *srcblk,
             unsigned char far *desblk,
             unsigned int  size);

  int ESCorGopressed()
  {
   int result=0;
   asm {
     mov   ah, 1
     int   16h
     jz    Retit
     xor   ah, ah
     int   16h
     mov   result, 1
     cmp   ax, 011bh
     jz    Retit
     mov   result, 2
     cmp   al, 'g'
     jz    Retit
     cmp   al, 'G'
     jz    Retit
     mov   result, 3
   }
   Retit:
   return(result);
  }


  int blkcmp(unsigned char far *srcblk,
             unsigned char far *desblk,
             unsigned int  blksize)
  {
   int result=0;
   asm {
     push  ds
     push  es
     push  si
     push  di
     les   di, desblk
     lds   si, srcblk
     mov   cx, blksize
     cld
     repz  cmpsb
     pop   di
     pop   si
     pop   es
     pop   ds
     jz    __End
     not   result
   }
   __End:
   return(result);
  }

  main()
  {
   unsigned int i;
   int exitloop=0;
   unsigned char workmode, commport;
   unsigned int  baudrate;
   unsigned char pak[512];
   unsigned char rxbuff[520];
   int  result, sel;
   int  badtot=0;

   for (i=0; i<256; i++) {
     pak[i]=(unsigned char)i;
     pak[i+256]=(unsigned char)i^255;
   }

   GetCommMode(&workmode, &commport, &baudrate);
   SetCommMode(_PAK_MODE, commport, baudrate);
   EnableRx(0);

   do {
      if (!(result=TxPackage(pak, 512))) {
        do {
          exitloop=((sel=ESCorGopressed())==1);
          result=RxPackage(rxbuff);
          if (result < 0) {
            printf("%d CRC-Error-Pack(s) echoed!\n", -result);
            badtot++;
          }
        } while ((result<=0) && (!exitloop) && (badtot<7) && (sel!=2));
        if (!exitloop) {
          if (result!=0) {
            if (result==512)
              if (!blkcmp(pak, rxbuff, 512))
                printf("%d Pack-Echoing OK!\n", (int)pak[0]);
              else
                printf("%d Pack-Echoing error by not same!\n", (int)pak[0]);
            else
              printf("Pack-Echoing error by code %d\n", result);
          }
          for (i=0; i<512; i++)
            pak[i]=(pak[i]^255);
          badtot=0;
        }
      } else {
        printf("Pack-Sending error by code %d\n", result);
        exitloop=(ESCorGopressed()==1);
      }
   }
   while (!exitloop);

   DisableRx();
   return 0;
  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -