/************************************************************************/
/* com_demo
有线口字符发送和接收示例
可以与PC机在38400波特率下进行通讯,掌上机可以发送和接收字符
(Take the communication of imput and output of the characters.)
Copyright (c) 2006 by Thinta Co.LTD
All rights reserved */
/************************************************************************/
#include "..\inc\Bio_Func.h"
#include "..\inc\key.h"
#include <STDIO.H>
#include <STRING.H>
#define TRUE 1
#define FALSE 0
#define BAND 38400 //波特率
#define CONTROL 0x01 //8位无校验,1位停止位
#define PORT 1 //有线口
void com_sendread(void)
{
U8 cRead ;
S16 cKey_in;
U8 title[] = " --通讯测试-- " ;
U8 port[] = "电缆口:38400\n" ;
_setcomport(PORT) ;
_com_init(1, BAND, CONTROL);
_gotoxy(0, 0) ;
_putstr(title) ;
_putstr(port) ;
while(1)
{
if(_bioskey(1) != 0)
{
cKey_in = _bioskey(0) ;
if(cKey_in == ESC)
{//按退出键返回
break ;
}else
{//按其他键,发送字符
_com_send(cKey_in) ;
}
}
if(!_com_read(&cRead))
{//接收到字符
if(isalnum(cRead))
{
_putch(cRead) ;
}
}
if(19 == _getx() && 9 == _gety())
{//显示到屏幕末尾
_clsn(2, 8) ;
_gotoxy(0, 2) ;
}
}
}
void main(void)
{
_sysinit() ;
com_sendread() ;
}