这几天弄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 \