树莓派如何使用串口,树莓派连接pixhawk

参考链接:(写的非常详细,下述方法亲测有效)pi 3 - How do I make serial work on the Raspberry Pi3 (PiZeroW, Pi4 or later models) - Raspberry Pi Stack Exchange

please follow these 6 steps carefully.

Step 1 - Install Raspbian Jessie onto a SD card and boot the Pi when connected to a network Login via terminal or desktop and shell Configure the system with:

sudo raspi-config

Expand filesystem and enable serial on advanced page, exit and reboot.

Step 2 -this won't necessary if you have jessie new release Update the system with:

sudo apt-get update

sudo apt-get upgrade

Step 3 - Device Tree settings as below:

Add device tree to /boot/config.txt to disable the Raspberry Pi 3 bluetooth.

sudo nano /boot/config.txt

Add at the end of the file

*if you want to change the blutooth to miniuart port(bad)

dtoverlay=pi3-miniuart-bt

*if you want to disable the blutooth(good)

dtoverlay=pi3-disable-bt

Exit the editor saving your changes.

Step 4 - reboot the pi

sudo reboot

step 5 -

a)to disable the Serial Console edit the file using

sudo nano /boot/cmdline.txt

remove the word phase "console=serial0,115200" or "console=ttyAMA0,115200"

Exit and save your changes

b)to Enable the Serial Console edit the file using

sudo nano /boot/cmdline.txt

Change the file to the following:

dwc_otg.lpm_enable=0 console=tty1 console=serial0(or ttyAMA0),115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

Exit and save your changes

Step 6 - reboot the pi

sudo reboot

 补充:

tips:如果遇到了 报错 DeviceError:serial:open: Permission denied

改变一下串口权限即可 (serial0改为自己的串口设备)

sudo chmod a+rw /dev/serial0

可以用如下指令设置永久可操作:

sudo usermod -aG dialout liyf

 其中liyf为用户名,把此用户名加入dialout用户组(dialout是一个group,它主要负责对于串口的权限)。

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值