farewell-farewell

准备工作:

  1. 安装wiringPi

  2. 修改config.txt

sudo nano /boot/config.txt
在文件的末尾添加:
dtoverlay=pi3-miniuart-bt

  3. 修改cmdline.txt

sudo nano /boot/cmdline.txt
删除其中红色部分:
dwc_otg.lpm_enable=0 console=serial10,115200  console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 
elevator=deadline fsck.repair=yes rootwait

编写程序的注意事项:

  1. char* 、const char*、字符串之间的转换导致编译错误

       解决方案:

char *  str = (char*) "/dev/ttyUSB0";

  2. C++编译报错

 undefined reference to `std::basic_ostream<char, std::char_traits<char>

      解决方案:

编译时添加 -lstdc++

编译程序:

gcc -o test test.cpp -lwiringPi -lstdc++

 

分类:

技术点:

相关文章:

  • 2021-04-28
  • 2021-07-11
  • 2022-02-02
  • 2021-12-10
  • 2021-11-19
  • 2021-11-19
  • 2021-11-19
  • 2022-02-09
猜你喜欢
  • 2021-12-14
  • 2022-02-08
  • 2021-11-19
  • 2021-11-19
  • 2021-11-19
  • 2021-11-19
  • 2021-12-24
相关资源
相似解决方案