arm与51单片机之间串口通信实验

    这几天弄arm的串口通信,因为以前有点单片机的基础,于是 就选了块51单片机与其实验。实验内容是在linux下编写好串口通信程序,编译后下载到arm板上运行,验证其可行性。linux下串口程序是想51中写入一个数据,并接收起返回值。51中的程序是接受从arm发送过来的数据,并在数码管上显示,在把数据发送回arm。

linux下串口通信程序如下:

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <linux/if.h>
#include <netinet/in.h>
#include <unistd.h>
#include <sys/types.h>
//#include <moxadevice.h>
#include "mxser.h"
#define BLEN 1024
#define MAX_COUNT 9999
unsigned short btable[]={B9600};
int main()
{
pid_t pid;
int iflag1,iflag2;
struct termios opint1;
struct termios opint2;
int fd1,fd2;
char name[5];
int ilen1,ilen2;
char num;
char rxbuf1[10];
int i,j,k;
printf("This is two serias ports program \n");

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值