| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 703 人关注过本帖
标题:[讨论]大家看看这段串口发送于接收代码,运行总是结果不对
只看楼主 加入收藏
mrainborn
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2006-12-30
收藏
 问题点数:0 回复次数:1 
[讨论]大家看看这段串口发送于接收代码,运行总是结果不对

串口0发送
#include<stdio.h>
#include<dos.h>
#include<string.h>
#include<bios.h>
send(int port,char cc);
main()
{
union
{
char ch[2];
int status;
}port_status;
char cc;
bioscom(0,0xEB,0);
port_status.status=bioscom(3,0,0);
if(port_status.status&0x100)
{
printf("error\n");
}
else
{
printf("jiuxu\n");
} /*************以上为初始化**********/
while(1)
{
send(0,0x0a);
}
}

send(int port,char cc)
{

union
{
char ch[2];
int status;
}port_status;
port_status.status=bioscom(1,cc,0);
if(port_status.status&128)
{
printf("error\n");
}

printf("OK\n");
}

串口1接收
#include<stdio.h>
#include<dos.h>
#include<string.h>
#include<bios.h>
receive(int port);
main()
{
union
{
char ch[2];
int status;
}port_status;

bioscom(0,0xEB,1);
port_status.status=bioscom(3,0,1);
if(port_status.status&0x100)
{
printf("error\n");
}
else
{
printf("jiuxu\n"); /***********以上为初始化************/
}
while(1)
{
receive(1);
}
}

receive(int port)
{
union
{
char ch[2];
int status;
}port_status;
port_status.status=bioscom(2,0,port);

printf("OK\n");

printf("%x\n",port_status.ch[0]);
}

搜索更多相关主题的帖子: 串口 代码 结果 运行 
2007-03-20 10:27
快速回复:[讨论]大家看看这段串口发送于接收代码,运行总是结果不对
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011558 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved