Matlab建立TCP/IP链接

参考:



MATLAB实现tcp连接 - 知乎 (zhihu.com)

MATLAB :【11】一文带你读懂serialport串口收发原理与实现_matlab serialport-CSDN博客

 Transition Your Code to serialport Interface - MATLAB & Simulink - MathWorks 中国

Transition Your Code to tcpclient Interface - MATLAB & Simulink - MathWorks 中国 

串行通信的动态输入缓冲区大小 - MATLAB Answers - MATLAB Central (mathworks.cn)

如何更改串口的收发缓存的大小 - MATLAB Answers - MATLAB Central

Which is the Buffer Size of a TCP/IP socket (tcpclient)? - MATLAB Answers - MATLAB Central (mathworks.cn)

版本更新:

因为TCP/IP函数即将被移除,之后请使用新的函数作为代替:

tcpip will be removed. Use tcpclient or tcpserver instead. For more information on updating your code, see Compatibility Considerations.

(To be removed) Create TCPIP object - MATLAB tcpip - MathWorks 中国

串行属性用于使用 serial 对象配置通信和配置读写行为,可以用来配置缓存区,

这个也将被删除,serial 配置缓冲区已经成为了历史。

        Removed Functionality The ValuesReceived and ValuesSent properties will be removed. You can calculate the number of values sent using the NumBytesAvailable property and the data type of the data available.

For example, if the NumBytesAvailable is 20 bytes of uint32 data, the number of values sent is five since each uint32 value is four bytes.
        The readasync and stopasync functions and the ReadAsyncMode and TransferStatus properties will be removed. The updated interface reads data asynchronously.
The BytesToOutput, InputBufferSize, and OutputBufferSize properties will be removed. Buffer sizes are automatically managed and sized as needed.
        The BreakInterruptFcn, OutputEmptyFcn, and PinStatusFcn properties will be removed. You can set callback functions using configureCallback in the updated interface, but not for these properties.
        The RecordDetail, RecordMode, RecordName, and RecordStatus properties will be removed.
        The TimerFcn and TimerPeriod properties will be removed. Use timer instead.
        The Name, Type, ObjectVisibility, Status, and Tag properties will be removed.

代码:

上半部分是用以前版本的函数写的,下半部分是新的;

简洁了很多。

clc;
clear all; 
close all; 
warning off;

% Config_list = ones(10,10,"uint8");
Config_list = zeros(10,10,"uint8");

% % set olden version
% Client_0 = tcpip("192.168.1.119",10000);
% 
% set(Client_0,'InputBufferSize',256*64);
% set(Client_0,'OutputBufferSize',256*64);
% 
% fopen(Client_0);
% % s is a serial object
% fwrite(Client_0,Config_list)

% set new version
Client_1 = tcpclient("192.168.1.119",10000,"Timeout",20,"ConnectTimeout",30);
% s is a serialport object
write(Client_1,Config_list)

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-06 06:04:04       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-06 06:04:04       101 阅读
  3. 在Django里面运行非项目文件

    2024-02-06 06:04:04       82 阅读
  4. Python语言-面向对象

    2024-02-06 06:04:04       91 阅读

热门阅读

  1. C语言-4

    C语言-4

    2024-02-06 06:04:04      43 阅读
  2. Days 22 ElfBoard 基于QT的智慧家庭控制中心

    2024-02-06 06:04:04       43 阅读
  3. 服务器托管有哪些好处?

    2024-02-06 06:04:04       45 阅读
  4. SpringBoot过滤器获取请求的参数

    2024-02-06 06:04:04       55 阅读
  5. Centos 7系统安装proftpd-1.3.8过程

    2024-02-06 06:04:04       48 阅读
  6. 【无标题】

    2024-02-06 06:04:04       48 阅读
  7. 关闭Ubuntu 默认开启的自动安全更新

    2024-02-06 06:04:04       50 阅读
  8. GPT-4是什么?如何使用GPT-4?

    2024-02-06 06:04:04       53 阅读
  9. C#面向对象程序设计

    2024-02-06 06:04:04       54 阅读
  10. Vue 实现动态路由

    2024-02-06 06:04:04       51 阅读
  11. 二进制可执行文件的常见后缀

    2024-02-06 06:04:04       45 阅读
  12. Days 20 ElfBoard 板 FFmpeg移植

    2024-02-06 06:04:04       53 阅读