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

📄 depth.c

📁 国内外搜集的GPS程序代码
💻 C
字号:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include <graphics.h>
#include <math.h>
#include <string.h>
#include <process.h>
#define COM1 0x3F8
#define EOI  0x20
#define IER 1
#define IIR 2
#define LCR 3
#define MCR 4
#define LSR 5
#define MSR 6

unsigned char msgbuff[11];
void   init_serial_com1(int brdl)
  {   
    int tmp;
    disable();
    outportb(COM1 + IER,0x00);
    outportb(COM1 + LCR,0x80);
    outportb(COM1 ,brdl);
    outportb(COM1 + IER,0x00);
    outportb(COM1 + MCR,0x09); /*8*/
    outportb(COM1 + LCR,0x03);
    outportb(COM1 + IER,0x01);
    tmp = inportb(0x21);
    tmp &= 0xEF;
    outportb(0x21,tmp);
    enable();
  }

void main()
  {
    int i,k,want_exit;
    char  kch,Depth[5];
    int driver,mode,depth;
    driver=DETECT;
    mode=0;
    initgraph(&driver,&mode,"");
/*baud rate 9600 */
    init_serial_com1(12);
    cleardevice();
    want_exit = 0;
    kch = ' ';
    depth=0.0;

    do 
    {
     if (kbhit()) { kch = getch();kch=toupper(kch);if (kch=='X') want_exit=1;}
     strcpy(msgbuff,"DT  ");
     depth++;
     gcvt(depth,5,Depth);
     i=strlen(Depth);
     strncat(msgbuff,"00000",5-i);
     strncat(msgbuff,Depth,i);
     strcat(msgbuff,"\r");
     strcat(msgbuff,"\n");
     for(i=0;i<11;i++) {outportb(COM1,msgbuff[i]);delay(150);
     printf("%c",msgbuff[i]);}
    }
    while(!want_exit);
    restorecrtmode();
    gotoxy(1,23);
    printf("All done.\r\n");
  }







⌨️ 快捷键说明

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