文章目录

  • 串口
  • 驱动
  • 安装
  • 设备文件
  • 测试代码
  • 编译运行
  • 引用

串口

电平之类的就不说了,串口使用的一般包括rs232全双工,rs422四线全双工,rs485两线半双工,rs485四线全双工几种模式,其中232是点对点,422/485可以组网。232和485支持modbus协议。下面针对moxa串口卡编程进行自收发测试。

驱动

Moxa为其串口卡提供了不同版本linux的驱动源码,这里使用的CP-118U 8口串口卡,每通道可单独设置232/422/485模式,通过板上拨码开关设置。不知道其他串口卡是不是如此,见到的几种串口卡确实都是硬件跳线设置。
驱动下载见官网:https://www.moxa.com/en/products/industrial-edge-connectivity/multiport-serial-boards/pcie-upci-pci-serial-cards/cp-118u-138u-series#resources

安装

这里用的是Linux4.x的源码驱动,文件中有个readme详细介绍了驱动安装过程。这里将源码编译成.ko模块进行动态加载,截取相应的步骤如下:

1. IntroductionThe Smartio/Industio/UPCI family Linux driver supports following  the multiport boards.- 2 ports multiport board CP-102U, CP-102UL, CP-102UF, CP-102E, CP-102EL, CP-132U-I, CP-132UL,, CP-132EL, CP-132EL-I, CP-132, CP-132I, CP132S, CP-132IS,CP-112UL, CP-112UL-I,CI-132, CI-132I, CI-132IS,  (C102H, C102HI, C102HIS, C102P, CP-102, CP-102S) - 4 ports multiport board CP-104EL, CP-104EL-A,CP-104UL, CP-104JU,CP-134U, CP-134U-I, CP-134EL-A-I,C104H/PCI, C104HS/PCI,CP-114, CP-114I, CP-114S, CP-114IS, CP-114UL, CP-114EL, CP-114EL-I,C104H, C104HS,CI-104J, CI-104JS,CI-134, CI-134I, CI-134IS,  (C114HI, CT-114I, C104P)POS-104UL- 8 ports multiport board CP-118EL, CP-168EL,CP-118U, CP-118U-I,CP-118E-A-I, CP-138E-A-I, CP-116E-A,CP-118EL-A, CP-118E-I-A,CP-138U, CP-138U-ICP-168EL, CP-168U, CP-168EL-A, CP-168U,C168H/PCI,C168H, C168HS,(C168P)- 16 ports multiport boardCP-116E-AThis driver supports x86 and x64 hardware platform. In order to maintaincompatibility, this version has also been properly tested with severalLinux distribution (see version.txt). However, if compatibility problem occurs, please contact Moxa Inc. technical support. (support@moxa.com)In addition, for the device driver, useful utilities are also provided in this version. They are- msdiag    Diagnostic program for displaying installed Moxa Smartio/Industio boards.- msmon     Monitor program to observe data count and line status signals.- msterm    A simple terminal program which is useful in testing serialports.- muestty Device configuration tool for MUE series PCI Expressmultiport board(CP-102E, CP-102EL, CP-132EL, CP-132EL-I,CP-114EL, CP-114EL-I, CP-104EL-A, CP-168EL-A, CP-118EL-A,CP-118E-A-I, CP-138E-A, CP-134EL-A, CP-116E-A).The tool provides two  functions to set and get the interfaceand terminator resistor on the device.- io-irq.exe Configuration program to setup ISA boards. Please note thatthis program can only be executed under DOS.All the drivers and utilities are published in the form of source code under GNU General Public License in this version. Please refer to GNU General Public License announcement in each source code file for more detail.In Moxa's Web sites, you may always find the latest driver athttp://www.moxa.comThis version of driver can be installed as Loadable Module (Module driver)or built-in into the kernel (Static driver). You may refer to the followinginstallation procedure a for suitable one. Before you install the driver,please refer to hardware installation procedure in the User's Manual.We assume the user should be familiar with the following documents.- Serial-HOWTO- Kernel-HOWTONote: The MUE series includes CP-102E, CP-102EL, CP-132EL, CP-132EL-I,CP-114EL, CP-114EL-I, CP-104EL-A, CP-168EL-A, CP-118EL-A,CP-118E-A-I, CP-138E-A, CP-134EL-A, CP-116E-A, and supportslinux kernel 4.x.-----------------------------------------------------------------------------
2. System Requirement- Hardware platform: x86, x64- Kernel version: 4.x - gcc version 2.72 or later- Maximum 4 boards can be installed in combination- Kernel sourceNote: If you want to use this driver in VM, you MUST to enable VM-Compatible in physical computer with linux operating system.You can use muestty, the utility contained in this driver, to enableVM-Compatible feature. You can refer to the "4. Utilities" for more detail.-----------------------------------------------------------------------------
3. Installation3.1 Hardware installation3.2 Driver files   3.3 Device naming convention3.4 Module driver configuration   3.5 Static driver configuration3.6 Custom configuration3.7 Verify driver installation3.1 Hardware installationThere are several types of buses, ISA and PCI/PCIE, for Smartio/Industio family multiport board.ISA board---------You'll have to configure CAP address, I/O address, Interrupt Vectoras well as IRQ before installing this driver. Please refer to hardwareinstallation procedure in User's Manual before proceeding any further.Please make sure the JP1 is open after the ISA board is set properly.PCI/UPCI board--------------You may need to adjust IRQ usage in BIOS to avoid IRQ conflict with other ISA devices. Please refer to hardware installation procedure in User's Manual in advance.PCI IRQ Sharing-----------Each port within the same multiport board shares the same IRQ. Up to4 Moxa Smartio/Industio PCI Family multiport boards can be installed together on one system and they can share the same IRQ.3.2 Driver filesThe driver file could be obtained from the  website, under the product page.The first step is making a copy of the driver file "driv_linux_smart_[VERSION]_[BUILD].tgz" into the specified directory.e.g. /moxa.Please execute the following commands as below.# cd /moxa # tar -xzvf driv_linux_smart_vx.x_build_yymmddhh.tgzIn addition, you could find all driver files in /moxa/mxser. 3.3 Device naming conventionYou could find all drivers and utilities in /moxa/mxser.The installation procedures below are depended on the model you'd like to run the driver. If you prefer the module driver, please refer to 3.4. If the static driver is required, please refer to 3.5.Dial-in and callout port-----------------------This driver remains traditional serial device properties and only  dial-in ports will be created. The device name for each serial port is /dev/ttyMxx. The MUE series multiport board’s serial port name is  /dev/ttyMUExx.Device naming when more than 2 boards installed-----------------------------------------------Naming convention for each Smartio/Industio multiport board is pre-defined as below.Board Num.     Dial-in Port 1st board    ttyM0  - ttyM7 2nd board    ttyM8  - ttyM15 3rd board    ttyM16 - ttyM23 4th board    ttyM24 - ttyM31For MUE series:Board Num.     Dial-in Port 1st board    ttyMUE0  - ttyMUE7 2nd board    ttyMUE8  - ttyMUE15 3rd board    ttyMUE16 - ttyMUE23 4th board    ttyMUE24 - ttyMUE31 Board sequence--------------This driver will activate ISA boards Module according to the parameter set in the driver. After all specified ISA board activated, PCI board will be installed in the system automatically driven. Therefore the board number is sorted by the CAP address of ISA boards. For PCI boards, their sequence will be after ISA boards and C168H/PCI has higher priority than C104H/PCI boards.3.4 Module driver configurationModule driver is the easiest way to install. If you prefer the staticdriver installation, please skip this paragraph.------------- Prepare to use the MOXA driver--------------------  3.4.1 Create tty device with correct major numberBefore using MOXA driver, your system must have the tty devices which are created with the driver's major number. We offer one shell script "msmknod" to simplify the procedure.This step is only needed to be executed once. But you stillneed to do this procedure when:a. You change the driver's major number. Please refer to the "3.7" section.b. Your total installed MOXA boards number is changed. Maybe you add/delete one MOXA board.c. You want to change the tty name. This needs to modify the shell script "msmknod"The procedure is:# cd /moxa/mxser/driver# ./msmknodThis shell script will require the major number for dial-in device and callout device to create tty device. You also need to specify the total installed MOXA board number. Default major numbers for dial-in device and callout device are 30, 35. Ifyou need to change to other numbers, please refer section "3.7"for more detailed procedure.Msmknod will delete any special files occupying the same device naming.3.4.2 Build the MOXA driver and utilitiesBefore using the MOXA driver and utilities, you need to compile the all the source code. This step is only need to be executed once. But you still re-compile the source code if you modify thesource code. For example, if you change the driver's major number(see "3.7" section), then you need to do this step again.Find "Makefile" in /moxa/mxser, then run# make;!!!!!!!!!! NOTE !!!!!!!!!!!!!!!!!For Red Hat Enterprise Linux AS4/ES4/WS4:# make SP2For Red Hat Enterprise Linux 8:# make SP3!!!!!!!!!! NOTE !!!!!!!!!!!!!!!!! The driver files and utilities will be compiled respectively.3.4.3 Install the MOXA driver and utilitiesTo install the MOXA driver and utilities, you have to execute thecommand as below in /moxa/mxser directory. The driver and theutilities will be installed to the system directory respectively.# make install!!!!!!!!!! NOTE !!!!!!!!!!!!!!!!! For Red Hat Enterprise Linux AS4/ES4/WS4:# make installsp2For Red Hat Enterprise Linux 8# make installsp3!!!!!!!!!! NOTE !!!!!!!!!!!!!!!!! ------------- Load MOXA driver--------------------  3.4.4 Load the MOXA driver  # modprobe mxser <argument>or# modprobe mxupcie <option>will activate the module driver. You may run "lsmod" to checkif "mxser" (or "mxupcie") is activated. If the MOXA board isISA board, the <argument> is needed. Please refer to section"3.4.7" for more information.The "mxupcie" is for MUE series multiport board only.To simplify the processes above, we provide a single step to build, install and load the MOXA driver. You may execute the./mxinstall in /moxa/mxser/ to use the MOXA product.# ./mxinstall------------- Load MOXA driver on boot --------------------  3.4.5 For the above description, you may manually execute "modprobe mxser" (or "modprobe mxupcie") to activate thisdriver and run "rmmod mxser" (or "rmmod mxupcie") to remove it. However, it's better to have a boot time configuration to eliminate manual operation. Boot time configuration can be achieved by rc file. We offer one "rc.mxser" file to simplify the procedure under "moxa/mxser/driver". But if you use ISA board, please modify the "modprobe ..." command to add the argument (see "3.4.7" section). After modifying the rc.mxser, please try to execute "/moxa/mxser/driver/rc.mxser" manually to make sure the modification is ok. If any error encountered, please try to modify again. If the modification is completed, follow the below step.a. For Red HatRun the following command for setting rc files.# cd /moxa/mxser/driver# cp ./rc.mxser /etc/init.d/# cp ./mxser.service /etc/systemd/system/# systemctl enable mxser.service# systemctl start mxser.serviceReboot and check if mxser or mxupcie activated by "lsmod" command.b. For DebianRun the following command for setting rc files.# cd /moxa/mxser/driver# cp ./rc.mxser /etc/init.d/Reboot and check if mxser or mxupcie activated by "lsmod" command.If the Debian system boots without Multiport Serial Boards driver loaded, pleaseexecute the following command with root administration to resolve thisproblem:# update-rc.d rc.mxser defaultsStarting with Debian 6.0, the insserv command is used instead as below instruction.# insserv /etc/init.d/rc.mxserc. For SuSERun the following command for setting rc files.# cd /moxa/mxser/driver# cp ./rc.mxser /etc/rc.d/# cd /etc/rc.dCheck "boot.local" is existed or not. If "boot.local" doesn't exist, create it by vi, run "chmod 755 boot.local" to change the permission.Add "/etc/rc.d/rc.mxser" in last line, Reboot and check if mxser or mxupcie activated by "lsmod" command.3.4.6. Automatically modify the port settings on bootIn the rc files (see "3.4.5" section), it can modify the port settingsautomatically on the boot time by adding the configuration scripts intothe rc files.For example:To configure the interface as RS-485 2 wire and the 120ohm terminatorresistor for ttyMUE0 when system startup, the following scripts can bewritten into the rc files.muestty -i RS4852W /dev/ttyMUE0muestty -t 120TERM /dev/ttyMUE0To see the usage of muestty, please check Chapter 4.3.4.7. If you'd like to drive Smartio/Industio ISA boards in the system, you'll have to add parameter to specify CAP address of given board while activating "mxser.o". The format for parameters isas follows.Step 1: Unload the driver, if the driver is activating.Run "lsmod" to check if "mxser" is activated or not.#lsmod | grep mxserIf the driver is activating, unload it.#rmmod mxserStep 2: Activate the driver with parameters.#modprobe mxser ioaddr=0x???,0x???,0x???,0x???|     |     |     ||     |     |     +- 4th ISA board|     |     +------ 3rd ISA board|     +------------ 2nd ISA board+------------------- 1st ISA boardThe MUE series multiport board provides two options to setthe interface and terminator resistor while loading the driver.The two options are available while working in RS-422 andRS-485 mode. Option's value is applied to all ports on thedevices.Step 1: Unload the driver, if the driver is activating.Run "lsmod" to check if "mxupcie" is activated or not.#lsmod | grep mxupcieIf the driver is activating, unload it.#rmmod mxupcieStep 2: Activate the driver with parameters.#modprobe mxupcie interface=2 terminator=1|           ||           +- 120 ohm+-------------- RS-422The interface and terminator have values to set as the following.Option    Value   Commentinterface      1  RS-2322  RS-4224  RS-485 2 wire8  RS-485 4 wireterminator     0      0 ohm1    120 ohm Note: You should unload the MOXA driver, before using modprobecommand to activate it.3.4.8 Unload the MOXA driver# rmmod mxseror# rmmod mxupciewill deactivate the module driver. You may run "lsmod" to checkif "mxser" (or "mxupcie") is activated or not.3.4.9 Clean the MOXA driver and utilitiesClean the MOXA driver and utilities in /moxa/mxser, you haveto execute the command below to clean the files.# make clean3.4.10 Uninstall the MOXA driver and utilitiesThe MOXA driver and utilities will be removed from the systemrespectively after executing the command below in /moxa/mxser.# make uninstall

设备文件

驱动安装之后,可以看到相应的端口,ls -l /dev/tty*

8个通道串口,不知道为啥出来这么多ttyM,回头再研究吧。

测试代码

研究一番,linux下串口编程好像都一样,RS232,422/485也没啥区别。这里直接上代码,其中大部分是拷贝了参考博文里的代码

#include <stdio.h>
#include <termios.h>
#include <linux/ioctl.h>
#include <linux/serial.h>
#include <asm-generic/ioctls.h> /* TIOCGRS485 + TIOCSRS485 ioctl definitions */
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdlib.h>
#include <getopt.h>/*** @brief: set the properties of serial port* @Param: fd: file descriptor* @Param: nSpeed: Baud Rate* @Param: nBits: character size* @Param: nEvent: parity of serial port* @Param: nStop: stop bits*/typedef enum {DISABLE = 0, ENABLE} RS485_ENABLE_t;int set_port(int fd, int nSpeed, int nBits, char nEvent, int nStop)
{struct termios newtio, oldtio;memset(&oldtio, 0, sizeof(oldtio));/* save the old serial port configuration */if(tcgetattr(fd, &oldtio) != 0) {perror("set_port/tcgetattr");return -1;}memset(&newtio, 0, sizeof(newtio));/* ignore modem control lines and enable receiver */newtio.c_cflag = newtio.c_cflag |= CLOCAL | CREAD;newtio.c_cflag &= ~CSIZE;/* set character size */switch (nBits) {case 8:newtio.c_cflag |= CS8;break;case 7:newtio.c_cflag |= CS7;break;case 6:newtio.c_cflag |= CS6;break;case 5:newtio.c_cflag |= CS5;break;default:newtio.c_cflag |= CS8;break;}/* set the parity */switch (nEvent) {case 'o':case 'O':newtio.c_cflag |= PARENB;newtio.c_cflag |= PARODD;newtio.c_iflag |= (INPCK | ISTRIP);break;case 'e':case 'E':newtio.c_cflag |= PARENB;newtio.c_cflag &= ~PARODD;newtio.c_iflag |= (INPCK | ISTRIP);break;case 'n':case 'N':newtio.c_cflag &= ~PARENB;break;default:newtio.c_cflag &= ~PARENB;break;}/* set the stop bits */switch (nStop) {case 1:newtio.c_cflag &= ~CSTOPB;break;case 2:newtio.c_cflag |= CSTOPB;break;default:newtio.c_cflag &= ~CSTOPB;break;}/* set output and input baud rate */switch (nSpeed) {case 0:cfsetospeed(&newtio, B0);cfsetispeed(&newtio, B0);break;case 50:cfsetospeed(&newtio, B50);cfsetispeed(&newtio, B50);break;case 75:cfsetospeed(&newtio, B75);cfsetispeed(&newtio, B75);break;case 110:cfsetospeed(&newtio, B110);cfsetispeed(&newtio, B110);break;case 134:cfsetospeed(&newtio, B134);cfsetispeed(&newtio, B134);break;case 150:cfsetospeed(&newtio, B150);cfsetispeed(&newtio, B150);break;case 200:cfsetospeed(&newtio, B200);cfsetispeed(&newtio, B200);break;case 300:cfsetospeed(&newtio, B300);cfsetispeed(&newtio, B300);break;case 600:cfsetospeed(&newtio, B600);cfsetispeed(&newtio, B600);break;case 1200:cfsetospeed(&newtio, B1200);cfsetispeed(&newtio, B1200);break;case 1800:cfsetospeed(&newtio, B1800);cfsetispeed(&newtio, B1800);break;case 2400:cfsetospeed(&newtio, B2400);cfsetispeed(&newtio, B2400);break;case 4800:cfsetospeed(&newtio, B4800);cfsetispeed(&newtio, B4800);break;case 9600:cfsetospeed(&newtio, B9600);cfsetispeed(&newtio, B9600);break;case 19200:cfsetospeed(&newtio, B19200);cfsetispeed(&newtio, B19200);break;case 38400:cfsetospeed(&newtio, B38400);cfsetispeed(&newtio, B38400);break;case 57600:cfsetospeed(&newtio, B57600);cfsetispeed(&newtio, B57600);break;case 115200:cfsetospeed(&newtio, B115200);cfsetispeed(&newtio, B115200);break;case 230400:cfsetospeed(&newtio, B230400);cfsetispeed(&newtio, B230400);break;default:cfsetospeed(&newtio, B115200);cfsetispeed(&newtio, B115200);break;}/* set timeout in deciseconds for non-canonical read */newtio.c_cc[VTIME] = 0;/* set minimum number of characters for non-canonical read */newtio.c_cc[VMIN] = 0;/* flushes data received but not read */tcflush(fd, TCIFLUSH);/* set the parameters associated with the terminal fromthe termios structure and the change occurs immediately */if((tcsetattr(fd, TCSANOW, &newtio))!=0){perror("set_port/tcsetattr");return -1;}return 0;
}/*** @brief: open serial port* @Param: dir: serial device path*/
int open_port(char *dir)
{int fd ;fd = open(dir, O_RDWR);if(fd < 0) {perror("open_port");}return fd;
}/*** @brief: print usage message* @Param: stream: output device* @Param: exit_code: error code which want to exit*/
void print_usage (FILE *stream, int exit_code)
{fprintf(stream, "Usage: option [ dev... ] \n");fprintf(stream,"\t-h  --help     Display this usage information.\n""\t-d  --device   The device ttyS[0-3] or ttyM[0-7] for Moxa Sio\n""\t-b  --baudrate Set the baud rate you can select\n""\t               [230400, 115200, 57600, 38400, 19200, 9600, 4800, 2400, 1200, 300]\n""\t-s  --string   Write the device data\n""\t-e  --1 or 0 , Write 1 to enable rs485_mode(only at atmel)\n");exit(exit_code);
}/*** @brief: main function* @Param: argc: number of parameters* @Param: argv: parameters list*/int rs485_enable(const int fd, const RS485_ENABLE_t enable)
{struct serial_rs485 rs485conf;int res;/* Get configure from device */res = ioctl(fd, TIOCGRS485, &rs485conf);if (res < 0) {perror("Ioctl error on getting 485 configure:");close(fd);return res;}/* Set enable/disable to configure */if (enable) {   // Enable rs485 moders485conf.flags |= SER_RS485_ENABLED;} else {        // Disable rs485 moders485conf.flags &= ~(SER_RS485_ENABLED);}rs485conf.delay_rts_before_send = 0x00000004;/* Set configure to device */res = ioctl(fd, TIOCSRS485, &rs485conf);if (res < 0) {perror("Ioctl error on setting 485 configure:");close(fd);}return res;
}int main(int argc, char *argv[])
{char *write_buf = "0123456789abc";
//  unsigned char write_buf[10];unsigned char read_buf[20];int fd, i, len, nread,r;
//  pid_t pid;int next_option;extern struct termios oldtio;int speed ;char *device = "/dev/ttyM6";int spee_flag = 0, device_flag = 0;const char *const short_options = "hd:s:b:e:";const struct option long_options[] = {{ "help",   0, NULL, 'h'},{ "device", 1, NULL, 'd'},{ "string", 1, NULL, 's'},{ "baudrate", 1, NULL, 'b'},{ NULL,     0, NULL, 0  }};if (argc < 2) {print_usage (stdout, 0);exit(0);}while (1) {next_option = getopt_long (argc, argv, short_options, long_options, NULL);if (next_option < 0)break;switch (next_option) {case 'h':print_usage (stdout, 0);break;case 'd':device = optarg;device_flag = 1;break;case 'b':speed = atoi(optarg);spee_flag = 1;break;case 's':write_buf = optarg;break;case 'e':r = atoi(optarg);break;case '?':print_usage (stderr, 1);break;default:abort ();}}if ((!device_flag)||(!spee_flag)) {print_usage (stderr, 1);exit(0);}/* open serial port */fd = open_port(device);if (fd < 0) {perror("open failed");return -1;}elseprintf("open %s sucessfully!\n",device);// if(r)// {// rs485_enable(fd,ENABLE);// }/* set serial port *///speed = 9600;i = set_port(fd, speed, 8, 'N', 1);if (i < 0) {perror("set_port failed");return -1;}elseprintf("set_port sucessed!\n");int rdcnt;int wrcnt;while (1) {/* if new data is available on the serial port, read and print it out */nread = read(fd ,read_buf ,sizeof(read_buf));if (nread > 0) {printf("RECV[%2d]: ", nread);for(i = 0; i < nread; i++)printf("0x%02x ", read_buf[i]);printf("\n");}// for(i=0;i<10;i++)// {// write_buf[i]= (rdcnt%20)*10+i;// }/* write data */printf("the data length is %d\n",strlen(write_buf));wrcnt = write(fd, write_buf, strlen(write_buf));if(wrcnt!= -1)printf("the port send %d data!\n",wrcnt);elseprintf("Transmit failed!\n");rdcnt++;printf("the port read %d times!\n",rdcnt);usleep(100000);}/* restore the old configuration */tcsetattr(fd, TCSANOW, &oldtio);close(fd);return 0;
}

参考博文里使用了RS485模式,配置端口时需要485使能,但我在实际测试时,发现并不需要,难道是板子不一样?待研究

编译运行

编译很简单,运行时在命令后加入参数

引用

主要参考了 imx6ul】linux下rs485的使用,感谢!

Linux下串口编程相关推荐

  1. linux实验串行端口程序设计,Linux下串口编程心得(转)

    最近一段时间,需要完成项目中关于Linux下使用串口的一个部分,现在开帖记录过程点滴. 项目的要求是这样的,Qt应用程序主要完成数据采集和发送功能,一开始在google中海搜关键字"Qt串口 ...

  2. Linux 下串口编程(C++ 程序设计)

    串口通信是最简单的通信方式.即使在USB 非常流行的今天,依然保留了串行通信的方式.网络上已经有大量关于Linux下 C++ 串口编程的文章,但是我依然要写这篇博文.因为网络上的资料不是内容太多,就是 ...

  3. Linux下串口编程(C语言版本)

    Linux 系统下串口编程 1.准备工具 案例选择在Ubuntu下创建虚拟串口,作为收发使用,需要用到socat命令. 首先进行安装,本人已经安装好了,使用安装命令后,所以下面会提示一些信息,记得连网 ...

  4. 【Linux】Linux 下串口编程入门

    目录 串口简介 串口操作 打开串口 设置串口 读写串口 关闭串口 例子 相关主题 串口简介 串行口是计算机一种常用的接口,具有连接线少,通讯简单,得到广泛的使用.常用的串口是 RS-232-C 接口( ...

  5. 串口设置波特率linux函数接口,Linux下串口编程之一:基础设置函数

    1,串口操作需要的头文件 #include /* 标准输入输出定义 */ #include /* 标准函数库定义 */ #include /* Unix 标准函数定义 */ #include #inc ...

  6. Linux下串口编程入门

    1. 串口简介 串行口是计算机一种常用的接口,具有连接线少,通讯简单,得到广泛的使用.常用的串口是 RS-232-C 接口(又称 EIA RS-232-C)它是在 1970 年由美国电子工业协会(EI ...

  7. Linux下串口编程基础

    串口知识 串行接口 (SerialInterface) 是指数据一位一位地顺序传送,其特点是通信线路简单,只要一对传输线就可以实现双向通信(可以直接利用电话线作为传输线),从而大大降低了成本,特别适用 ...

  8. Linux下串口编程遇 接收数据错误问题及原因

    近日在调试串口的时候发现,另一设备向我ARM板的串口发送0x0d,我接收之后变成了0x0a,这是问题一:另外当对方向我发送一串数据,如果其中有0x11,那么我总是漏收此数,这是问题二. 由于问题莫名其 ...

  9. Linux下串口编程总结

    1.串口操作需要的头文件 #include <stdio.h> //标准输入输出定义 #include <stdlib.h> //标准函数库定义 #include <un ...

最新文章

  1. 201671010128 2017-12-17《Java程序设计》之并发
  2. Flutter GitHub Travis CI 搭建
  3. WINCE6.0+S3C2443下的activesync问题
  4. 中国充换电行业产销需求预测与转型升级战略分析报告2022-2028年版
  5. 物联网协议之CoAP协议开发学习笔记之术语解释
  6. 【数学基础】算法工程师必备的机器学习--线性模型(上)
  7. Linux:客户端的实现
  8. Java里什么是面向对象?
  9. 会不会导致内存泄漏_使用ThreadLocal不当可能会导致内存泄露
  10. java 置换_Java中的置换和组合
  11. svn合并分支到主干,工具操作
  12. oracle sql 查询全年日期,oracle下sql创建指定年份全年日期表(区分工作日)
  13. 医学激光成像仪行业研究及十四五规划分析报告
  14. 小米手机访问电脑共享文件_小米手机如何与电脑共享文件
  15. 《中国天气预报》城市编号一览表
  16. ThreadLocal介绍和源码解析
  17. C#——检测鼠标滑轮事件
  18. 警告: 检测到依赖关系环:_软件设计:依赖关系
  19. Android 自定义注解处理器详解
  20. 我的世界服务器货币充值系统,《我的世界》中国版正式开启了充值功能

热门文章

  1. PCB Layout软件分析对比(AD、Pads、Allegro)
  2. Origin: 类别图-多因子组柱状图-分组柱状图
  3. 【ZZULIOJ】1037:四则运算
  4. 华为mate30计算机删了怎么找回,华为mate30pro桌面天气删除了怎么恢复
  5. 分布式爬虫系统设计、实现与实战
  6. java实现从url路径中下载pdf文档到本地
  7. 三台linux虚拟机免密登录
  8. access 组合框模糊筛选
  9. ExtraCHM 1.5破解版和破解教程:
  10. ‍swf文件格式解析入门(tag解析)