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

📄 com_demo.c

📁 tp850掌机源码串口操作例子,C语言写的,可以
💻 C
字号:
/************************************************************************/
/* 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() ;
}




⌨️ 快捷键说明

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