精华内容
下载资源
问答
  • include/linux/serial_core.h ... #define UART_XMIT_SIZE PAGE_SIZE ... include/generated/asm-offsets.h ... #define PAGE_SIZE 4096 ...

    一、方法1修改内核

    kernal/include/linux/serial_core.h

    ...
    #define UART_XMIT_SIZE 	PAGE_SIZE
    ...
    

    kernal/include/generated/asm-offsets.h

    ...
    #define PAGE_SIZE	4096
    ...
    

    注意:
    2.6的内核PAGE_SIZE的位置在kernal/include/asm/page.h

    二、方法2应用层修改
    使用:ioctl(fd, TIOCSSERIAL, &serial);

    #define FRAME_SIZE 10
    struct serial_struct serial; 
    ...
    serial.xmit_fifo_size = FIFO_SIZE; // what is "xmit" ?? 
    ioctl(fd, TIOCSSERIAL, &serial); 
    ...
    

    完整参考程序

    
    #include <asm-generic/ioctl.h>
    #include <termios.h>
    #include <linux/serial.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <sys/ioctl.h>
     
    int UartBuffSizeSet(char *dev_path,int size) {  
      int ret;
      int fd =  open(dev_path, O_RDWR | O_NOCTTY | O_NONBLOCK);
      if(fd < 0){
        return -1;
      }
      struct serial_struct serial;
      ret = ioctl(fd, TIOCGSERIAL, &serial);
      if (ret != 0) {
        close(fd);
        return -2;
      }+
      serial.xmit_fifo_size = 1024*1024; //1M
      ret = ioctl(fd, TIOCSSERIAL, &serial);
      if(ret != 0) {
        close(fd);
        return -3;
      }
      close(fd);
      return 0;
    }
    
    展开全文
  • 转自:...

    转自:http://stackoverflow.com/questions/10815811/linux-serial-port-reading-can-i-change-size-of-input-buffer

    You want to use the serial IOCTL TIOCSSERIAL which allows changing both receive buffer depth and send buffer depth (among other things). The maximums depend on your hardware, but if a 16550A is in play, the max buffer depth is 14.

    You can find code that does something similar to what you want to do here

    一下转自:http://e2e.ti.com/support/embedded/linux/f/354/t/164893.aspx

    Hello,

    I need to send a character (acknowledgement) after reception of a telegram

    within no more than 2ms. Before beginning the real application, I wrote a

    small test program, to measure the latency. Very strange: sometimes the

    latency is about 3ms, sometimes about some �s only, but never other values,

    than these 2.

    For testing, I send about 3 times per second the telegram "abcdefghij" from

    another system to my serial interface.

    Perhaps, I need some more information about the fifos: are there tx and rx

    fifos, where and how should I configure them?

    Here is my test-program with some more detailed questions:

    /* I tried 0, 1, 10 and 16, but it does not seem to change anything... */

    #define FIFO_SIZE 1

    /* This is needed, if not, we can get up to 10ms latency. */

    #define TEST_LOW_LATENCY 1

    /* If 1, than it seems, some transmissions get lost... */

    #define TEST_OUTPUT_FLUSH 0

    /* Perhaps only useful with heavy load... */

    #define TEST_SCHED 1

    #include

    #include

    #include

    #include

    #include

    #include

    #include

    #include

    #include

    #include

    #include

    #define _POSIX_SOURCE 1

    #define DEVICE "/dev/ttyS0"

    #define FRAME_SIZE 10 // "abcdefghij"

    int fd;

    void serial_init()

    {

    struct termios options;

    struct serial_struct serial;

    if((fd = open(DEVICE, O_RDWR | O_NOCTTY)) < 0){

    perror(DEVICE);

    exit(-1);

    }

    ioctl(fd, TIOCGSERIAL, &serial);

    #if TEST_LOW_LATENCY

    serial.flags |= ASYNC_LOW_LATENCY;

    #else

    serial.flags &= ~ASYNC_LOW_LATENCY;

    #endif

    serial.xmit_fifo_size = FIFO_SIZE; // what is "xmit" ??

    ioctl(fd, TIOCSSERIAL, &serial);

    tcgetattr(fd, &options);

    cfsetispeed(&options, B19200);

    cfsetospeed(&options, B19200);

    options.c_cflag &= ~(CSIZE | PARODD | CSTOPB | CRTSCTS);

    options.c_cflag |= CLOCAL | CREAD | CS8 | PARENB;

    options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);

    options.c_iflag |= INPCK | ISTRIP;

    options.c_oflag &= ~OPOST;

    options.c_cc[VTIME] = 1;

    options.c_cc[VMIN] = FRAME_SIZE;

    tcsetattr(fd, TCSANOW, &options);

    }

    int check_frame()

    {

    char buf[FRAME_SIZE + 1];

    while(!read(fd, buf, FRAME_SIZE));

    buf[FRAME_SIZE] = '\0';

    puts(buf);

    return buf[FRAME_SIZE - 1] == 'j';

    }

    void serial_ack()

    {

    write(fd, "a", 1);

    #if TEST_OUTPUT_FLUSH

    tcflush(fd, TCOFLUSH);

    #endif

    }

    int main()

    {

    #if TEST_SCHED

    struct sched_param sched;

    sched_getparam(0, &sched);

    sched.sched_priority = 50;

    sched_setscheduler(0, SCHED_RR, &sched);

    #endif

    serial_init();

    while(1)

    if(check_frame())

    serial_ack();

    else

    puts("Error");

    return 0;

    }

    I would be glad about any hint!

    Greetings, Peter

    展开全文
  • tcflush(int fd, int queue_selector) //对以写但未发出,或已接收但未读数据的flush.discards data written to the object referred to by fd but not transmitted, or data received but not read, depending on ...

    tcflush(int fd, int queue_selector)   //对以写但未发出,或已接收但未读数据的flush.discards data written to the object referred to by fd but not transmitted, or data received but not read, depending on the value of       queue_selector:

    TCIFLUSH              flushes data received but not read.

    TCOFLUSH              flushes data written but not transmitted.

    TCIOFLUSH              flushes both data received but not read, and data written but not transmitted.              tcgetattr(int fd, struct termios *termios_p)   //get串口termios结构gets the parameters associated with the object referred by fd and stores them in the termios structure referenced by termios_p. This function may be invoked from a background process; however, the terminal attributes may be subsequently changed by a foreground process.

    tcsetattr(int fd, int optional_actions, const struct termios *termios_p)   //设置串口termios结构sets the parameters associated with the terminal (unless support is required from the underlying hardware that is not available) from the termios structure referred to by termios_p.   optional_actions specifies when the changes take effect:TCSANOW   the change occurs immediately.

    TCSADRAIN   the change occurs after all output written to fd has been transmitted. This function should be used when changing parameters that affect output.

    TCSAFLUSH   the change occurs after all output written to the object referred by fd has been transmitted, and all input that has been received but not read will be discarded before the change is made.

    展开全文
  • 由于SoftwareSerial.h默认只接收64字节串行缓冲区,Arduino会将之后接收到的数据丢弃,不满足业务需求。 以下三种方法是笔者参考网上各种资料总结出来,对于WEMOS D1 R2,笔者只有方法一可行,其他两个方法仅供参考...

    由于SoftwareSerial.h默认只接收64字节串行缓冲区,Arduino会将之后接收到的数据丢弃,不满足业务需求。
    以下三种方法是笔者参考网上各种资料总结出来,对于WEMOS D1 R2,笔者只有方法一可行,其他两个方法仅供参考。

    方法一:修改缓冲区宏名(可行)

    此方法针对WEMOS D1 R2可行,因为集成esp8266模块,该模块自带SoftwareSerial,修改SoftwareSerial.h即可!

      //SoftwareSerial(int receivePin, int transmitPin, bool inverse_logic = false, unsigned int buffSize = 64);
      SoftwareSerial(int receivePin, int transmitPin, bool inverse_logic = false, unsigned int buffSize = 2048);

    目录(仅供参考):C:\Users\Administrator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\libraries\SoftwareSerial

    方法二:修改SoftwareSerial.h

    此方法是Arduino论坛评论看到的,理论上加到程序头即可,也可以在SoftwareSerial.h中修改。

    //#define _SS_MAX_RX_BUFF 64 // RX buffer size
    #define _SS_MAX_RX_BUFF 2048 // RX buffer size

    目录(仅供参考):C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src

    方法三:修改缓冲区宏名

    此方法是Arduino官方给出的方法,理论上加到程序头即可,也可以在HardwareSerial.h中修改。请注意如果你使用SoftwareSerial.h此方法一定不行

    #define SERIAL_RX_BUFFER_SIZE 2048 //修改串口发送缓冲区大小为2048
    #define SERIAL_TX_BUFFER_SIZE 2048 //修改串口接收缓冲区大小为2048
    展开全文
  • 串口缓存大小设置

    2021-08-11 11:44:33
    设置 串口 软 fifo int UartBuffSizeSet(char dev_path,int size) { int ret; int fd = open(dev_path, O_RDWR | O_NOCTTY | O_NONBLOCK); if(fd < 0){ return -1; } struct serial_struct serial; ret = ioctl...
  • C# socket通信 接收缓冲区大小,以及粘包问题的解决
  • micropython串口接收缓冲区的问题

    千次阅读 2020-03-08 02:16:56
    但根据下边的解释,这是缓冲区大小设置。抱着试试的心态,我开始各种研究这个buf(不是buff 哈哈): 经过各种暴力实验,得出结论,在UART初始化的时候如果不给这个参数,直接会被默认为64byte的大小,就像下边...
  • Arduino串口默认只接收64字节到缓冲区,之后接收到的数据直接丢弃,那么...对于硬件串口,可以通过宏定义的方式来增大串口读写缓冲区的空间,Arduino核心库中串口发送缓冲区宏名为SERIAL_TX_BUFFER_SIZE,串口接收缓...
  • #include/* 缓冲区大小 */#define SERIAL_BUFFER_SIZE 250/* 错误代码:取负值是为了与正常数值区别开来 */#define CODE_SUCCESS -1#define CODE_NO_OPERATE-2#define CODE_INVALID_ARG -11#define CODE_BUFFER_...
  • 使用qDebug()输出信息的时候,经常会因为输出内容的大小小于缓冲区而无法显示,此时可以通过把缓冲区大小置为0解决。 setvbuf(stdout, nullptr, _IONBF, 0); qDebug() << "hello,world" << endl;
  • 电脑串口延迟/缓冲设置方法

    千次阅读 2019-10-14 19:40:20
    注意:这里的因为有一个接收缓冲区和一个发送缓冲区,所以这个时间延迟应该除以二(虽然这样并不严谨),大概可以得到正确的时间延迟。 可以看出关闭fifo或者是将延迟(缓冲区)调整到最低,可以很明显的降低这个...
  • 满意答案Zc的爱丶很美2016.09.11采纳率:51%等级:9已帮助:515人一、程序设计的基础,例如:基本的编程语言基础,至少对数据类型、程序的结构及流程控制等最基本的内容要相当清楚!另外有不少同学都问到数据结构的...
  • STM32进阶之串口环形缓冲区实现

    万次阅读 多人点赞 2018-06-04 10:03:13
    如需转载请说明出处:STM32进阶之串口环形缓冲区实现 队列的概念 在此之前,我们来回顾一下队列的基本概念: 队列 (Queue):是一种先进先出(First In First Out ,简称 FIFO)的线性表,只允许在一端插入(入队),...
  • STM32串口数据接收 --环形缓冲区

    千次阅读 2021-02-01 11:35:57
    STM32串口数据接收 --环形缓冲区 环形缓冲区简介   在单片机中串口通信是我们使用最频繁的,使用串口通信就会用到串口的数据接收与发送,环形缓冲区方式接收数据可以更好的保证数据丢帧率第。   在通信程序中,...
  • tcp socket的发送缓冲区实际上是一个结构体struct sk_buff的队列,我们可以把它称为发送缓冲队列,由结构体struct sock的成员sk_write_queue(struct sk_buf_head)表示。sk_write_queue是一个结构体struct sk_buff_...
  • 我以前曾经看过这个有usb到串口的适配器,但现在我也在原生串口上看到它,频率更高.系统设置为运行自动化测试,并且首先执行一些任务,这些任务会导致从串行设备输出大量数据,而我没有打开端口.该设备也将自行重置.仅...
  • #define SERIAL_RX_BUFFER_SIZE 2048 //修改串口发送缓冲区大小为2048 但是由于arduino的编译器是先导入其他头文件,再编译用户区代码的,所以会提示已经被重定义。 那么我们就只能根据提示,去修改C:\Program ...
  • 之前看了一些人的程序,没有使用RTOS的,他们每次都是在中断中把数据压入缓冲区,我在想DMA能不能把数据压入缓冲区呢? 这样既可以不过多占用CPU系统资源的同时又能压入缓冲区,然后在其他线程进行处理。 希望能知道...
  • STM32串口通信(基于缓冲区

    千次阅读 2020-05-08 19:11:54
    在全双工的模式下,发送引脚需要设置为推挽复用输出,接收引脚则设置为浮空输入或带上拉的输入。因为一般不用同步和流量控制的方式,所以CK、RST、CTS引脚不作配置。当然啦,在使用STM32外设的时候不要忘记打开外设...
  • 串口缓冲区管理分析

    千次阅读 2017-10-19 18:16:22
    串口使用时一般包含两个缓冲区,即发送缓冲区和接收缓冲区。发送数据时,先将数据存在发送缓冲区,然后通过串口发送;接收数据时,先将接收的数据存在接收缓冲区,然后再进行读取。   合理恰当的使用缓冲区,...
  • 好像是在运行中更改可能不好实现,串口通信是经常使用到的功能,在STM32中UART具有DMA功能,并且收发都可以使用DMA,使用DMA发送基本上大家不会遇到什么问题,因为发送的时候会告知DMA发送的数据长度,DMA按照发送的...
  • 很多情况下,默认的套接字缓冲区大小... /usr/bin/env python# -*- coding: utf-8 -*-import socket# 设置发送缓冲域大小SEND_BUF_SIZE = 4096# 设置接收缓冲域大小RECV_BUF_SIZE = 4096def modify_buff_size():#...
  • 第一次接触串口,写点东西加深自己对串口的印象:通过参考一些网上的实例,我明白了串口怎么简单的进行通信交流,但是我所需要的还是图片等大文件在串口中的传输,串口传输是通过二进制位进行单位传输的,所以传输...
  • 串口环形缓冲区学习

    千次阅读 2019-05-27 12:08:34
    文章目录说明&感谢环形缓冲区作用编程步骤代码&分析实验现象源代码 说明&感谢 互联网是个开放的世界, 感谢...串口数据接收, 如果数据量过大, 很可能来不及处理这些数据, 因此需要把接收的数据存放到...
  • Python 获取串口通信缓存大小

    千次阅读 2020-08-14 14:49:36
    若想获取电脑端串口输入缓存以及输出缓存大小(bytes),可以通过该实例的 in_waiting (当前输入端缓存字节数) 和 out_waiting (当前输出端缓存字节数) 查看。 若一次性发送大量请求并收到相应的返回信息,尚未进行...
  • 主要是对很多出现,超时错误,溢出错误,以及帧不对错误的处理

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 9,854
精华内容 3,941
关键字:

串口接收缓冲区大小设置

友情链接: VerServ.rar