MATLAB中的最大波特率是多少? [英] What's the maximum baud rate in MATLAB?

查看:506
本文介绍了MATLAB中的最大波特率是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ubuntu 16.04& MATLAB R2017a.

Ubuntu 16.04 & MATLAB R2017a.

我正在尝试像这样设置串行端口:

I'm trying to set serial port like that:

s=serial_port('/dev/ttyUSB0','BaudRate',115200,'DataBits',8,'InputBufferSize',80000)

它工作正常,但是当我尝试更改波特率时,说1000000. 我收到此消息:

It's working fine, but when I try to change baud rate, say 1000000. I got this message:

Open failed: BaudRate could not be set to the specified value.

所以,我有2个问题:

1)是否可以设置不通用的波特率,例如2000000?

1) Is it possible to set not common baud rates, say 2000000?

2)我发现1500000和3000000为我工作. 有最大速度吗?

2) I found, that 1500000 and 3000000 is working for me. Is there maximum speed?

**更新**

就我而言,我知道如何更改OS中的波特率(Ubuntu 16.04) setserial无法正常工作,因此我正在使用sudo stty -F /dev/ttyUSB3 3500000(不允许所有速度)或通过asm/termios.h>-允许所有速度. 所以,我使用第二种方式.

I know how to change the baud rate in OS, in my case (Ubuntu 16.04) setserial is not working, so I'm using sudo stty -F /dev/ttyUSB3 3500000 (not all speed is allowed) or via asm/termios.h> -- all speed is allowed. So, I'm using second way.

之后,我可以轻松地像cu -l /dev/ttyUSB0这样监听端口 同时,我无法在matlab中设置速度.(上面的错误)

After that, I can easily listen the port like that cu -l /dev/ttyUSB0 And at the same time I cant set the speed in matlab.. (Error above)

推荐答案

尽管此链接应该为您提供有关如何在Matlab方面管理波特率的足够信息,正如@Cris Luengo在其命令中已经指出的那样,我想在问题的硬件方面进行一些阐述.

Although this link should provide you enough information about how to manage baud rates on Matlab side, as @Cris Luengo already stated in his command, I would like to elaborate a little bit on the hardware side of the problem.

使用以下命令:

stty -F /dev/ttyUSB0

您应该能够检索目标设备的当前波特率.另外,以下命令也可以检索该值:

you should be able to retrieve the current baud rate of the targeted device. Alternatively, the following command also retrieves that value:

 setserial -ag /dev/ttyUSB0

连同其他重要信息:

/dev/ttyUSB0,Line ...,UART:...,Port:...,IRQ:...

/dev/ttyUSB0, Line ..., UART: ..., Port: ..., IRQ: ...

Baud_base:... ,close_delay:...,除数:...

Baud_base: ..., close_delay: ..., divisor: ...

closing_wait:...,closeing_wait2:...

closing_wait: ..., closing_wait2: ...

标志:...

在OS端,您可以使用某些设备的波特率,但是如果要避免出现问题,则在建立连接时始终必须设置一致的值.一般而言,设备在波特率偏差方面对超速和低速具有容忍度(我认为不超过±5%)...因此,您可以尝试强制设置不同于当前波特率的任意波特率,但是您会不想离它太远.

OS side, you can play with the baud rate of some devices but if you want to avoid problems, you always have to set a coherent value when establishing a connection. Generally speaking, devices have a tolerance level (of, I think, no more than ±5%) on overspeed and underspeed concerning baud rate deviance... so you can try to force an arbitrary baud rate different from the current one, but you don't want to go too far from it.

这篇关于MATLAB中的最大波特率是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆