【问题标题】:How to get bluetooth serial port status under linux?linux下如何获取蓝牙串口状态?
【发布时间】:2016-05-27 00:58:28
【问题描述】:

通过linux终端获取串口(ttyS*)的状态很简单:

sudo cat /proc/tty/driver/serial

然后它会显示serinfo,其中包含所有 uart 的列表以及有关状态和缓冲区的信息。当我打电话时

sudo cat /proc/tty/drivers

然后我可以看到 rfcomm 驱动程序可用:

rfcomm   /dev/rfcomm   216 0-255 serial

当然,读取来自配对蓝牙设备的数据也不成问题。

问题是:如何获取 rfcomm 串口的状态(例如蓝牙 SPP 设备)?此信息是否可以在 /proc 目录中的某个位置(例如 ttyS*)获得,或者我可以使用完全不同的方式吗?

【问题讨论】:

标签: linux bash bluetooth console rfcomm


【解决方案1】:

这取决于您要寻找的状态。 bluez 附带的“rfcomm”命令确实有一些状态信息。这取决于这是否适合您。

% rfcomm -h
RFCOMM configuration utility ver 4.101
Usage:
        rfcomm [options] <command> <dev>

Options:
        -i [hciX|bdaddr]      Local HCI device or BD Address
        -h, --help            Display help
        -r, --raw             Switch TTY into raw mode
        -A, --auth            Enable authentication
        -E, --encrypt         Enable encryption
        -S, --secure          Secure connection
        -M, --master          Become the master of a piconet
        -f, --config [file]   Specify alternate config file
        -a                    Show all devices (default)

Commands:
        bind     <dev> <bdaddr> [channel]       Bind device
        release  <dev>                          Release device
        show     <dev>                          Show device
        connect  <dev> <bdaddr> [channel]       Connect device
        listen   <dev> [channel [cmd]]          Listen
        watch    <dev> [channel [cmd]]          Watch

【讨论】:

  • 不幸的是rfcomm 显示非常微弱的信息,实际上仅关于连接状态(或缺少连接)。我想知道 rx/tx 缓冲区的状态和溢出错误。
猜你喜欢
  • 2019-06-07
  • 1970-01-01
  • 1970-01-01
  • 2016-02-21
  • 2022-01-14
  • 1970-01-01
  • 2020-03-25
  • 2015-12-25
  • 2012-11-26
相关资源
最近更新 更多