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

📄 dser1_bp.cpp

📁 its creates virtual multi tasking i DOS
💻 CPP
字号:
/*******************************************************
 *                                                     *
 *  Program : DSER1_BP     Language : Borland C++      *
 *                                                     *
 *  Modified : 20 nov 2003                             *
 *                                                     *
 *  Copyright (c) 1988,2003, ORITECH    V 5.1          *
 *  All rights reserved.                               *
 *                                                     *
 *******************************************************
 *                                                     *
 *  DSER1_BP.CPP     Demo EasyTask         DPMI16      *
 *                                                     *
 *******************************************************/


#include <stdlib.h>
#include <stdio.h>
#include <graphics.h>
#include <dos.h>
#include <conio.h>
#include <string.h>
#include <float.h> 
#include <math.h> 
#include <time.h>
#include <malloc.h>
#include "etlib.h"


PMultiTask t1,t2,t3; 
char so[128]; 

#define g1 3
#define g2 9

void drawwindow(int x1,int y1,int x2,int y2,char *titre)
{
  int n;
  
  window(x1,y1,x2,y2+1);
  clrscr();
  gotoxy(1,1);
  sprintf(so,"%c",201); 
  cprintf(so);
  for (n=x1+1;n<=x2-1;n++)
  {
    sprintf(so,"%c",205);
    cprintf(so);
  }
  sprintf(so,"%c",187);
  cprintf(so);
  for (n=2;n<=y2-y1;n++)
  {
    gotoxy(1,n); 
    sprintf(so,"%c",186);
    cprintf(so);
    gotoxy(x2-x1+1,n); 
    sprintf(so,"%c",186);
    cprintf(so);
  }
  gotoxy(1,y2-y1+1);
  sprintf(so,"%c",200);
  cprintf(so);
  for (n=x1+1;n<=x2-1;n++) 
  {
    sprintf(so,"%c",205);
    cprintf(so);
  }
  sprintf(so,"%c",188);
  cprintf(so);
  gotoxy(((x2-x1) / 2)-(strlen(titre) / 2),1);
  sprintf(so,"%s",titre);
  cprintf(so);
  window(x1+1,y1+1,x2-1,y2-1);
}
  
void receive1(pvoid, pvoid)
{
  int err;

  pausemode(MTT);
  drawwindow(1,8,80,13,"RECEIVE COM2");
  do
  {
    sprintf(so,"%c",getserial(g1,1,pause,0,err));
    cprintf(so);
    taskdelay(1);
  } while (TRUE);
}

void receive2(pvoid, pvoid)
{
  int err;

  pausemode(MTT);
  drawwindow(1,15,80,20,"RECEIVE COM3");
  do
  {
    sprintf(so,"%c",getserial(g2,1,pause,0,err));
    cprintf(so);
  } while (TRUE);
}

void emit(pvoid, pvoid)
{
  BOOL keyfunc,upper;
  char keychar;
  char s1[256],s2[256];
  int n;
  int err;
  
  pausemode(MTT);
  drawwindow(1,1,80,6,"EMIT COM2 + COM3");
  strcpy(s1,"Channel mode xon/xoff.ESC for exit.");
  strcpy(s2,"Enter emit chars with the keyboard.");
  for (n=1;n<=5;n++)
  {
    writeserial(g2,1,s1,pause,0,err);
    writeserial(g1,1,s2,pause,0,err);
    sprintf(so,"%s",s1);
    cprintf(so);
    pause();
  }
  upper = FALSE;
  do
  {
    areadkey(&keyfunc,&keychar,upper);
    if (keychar==27) killalltasks();
    else
    {
      putserial(g2,1,keychar,pause,0,err);
      putserial(g1,1,keychar,pause,0,err);
    }
    sprintf(so,"%c",keychar);
    cprintf(so);
    if (keychar==13)
    {
      sprintf(so,"%c",10);
      cprintf(so);
      putserial(g2,1,10,pause,0,err);
      putserial(g1,1,10,pause,0,err);
    }
  } while (TRUE);
}

void main(void)
{
  int err;

  etker_init();
  etser_init();
  clrscr();
  //
  openserial(g1,1,256,256,COM2,err);
  resetserial(g1,1,1200,7,1,MT_EVENPARITY,0,err);
  //
  openserial(g2,1,256,256,COM3,err);
  resetserial(g2,1,1200,7,1,MT_EVENPARITY,0,err);
  //
  t1 = newtask(receive1,8000,1,MT_CHILD,NULL,0,NULL);
  t2 = newtask(receive2,8000,1,MT_CHILD,NULL,0,NULL);
  t3 = newtask(emit,8000,1,MT_CHILD,NULL,0,NULL);
  waitnotask();
  //
  disposeserial();
}

⌨️ 快捷键说明

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