?? depth.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 + -