Total Pageviews

Wednesday 8 August 2018

在mac上运行树莓派界面



当拿到手一个全新的树莓派,无鼠标键盘和显示器接入的情况下,如何配置系统,连接网络等?
有个思路就是用网线把macbook和树莓派直接连接起来,因为所有树莓派的mac地址都是以 b8:27:eb 开头的,通过网线连接时,可以发现请求dhcp信息
sudo tcpdump |egrep “b8:27:eb”
从上面grep的日志就可以看到树莓派获取的ip地址,如169.254.52.165。
然后再 ssh -X pi@169.254.52.165 打开ssh,并转发到x11显示界面。登陆到pi后,再运行命令 lxsession 或 /etc/X11/Xsession
如果想让pi通过mac共享网络上网,在mac的系统设置 – 共享,打开互联网共享,这样pi就能拿到与mac一个网段的ip地址。
要让mac支持x11,需要下载并安装xquartz: http://www.xquartz.org/
卸载xquartz方法:
1
2
3
4
5
6
launchctl unload /Library/LaunchAgents/org.macosforge.xquartz.startx.plist
sudo launchctl unload /Library/LaunchDaemons/org.macosforge.xquartz.privileged_startx.plist
sudo rm -rf /opt/X11* /Library/Launch*/org.macosforge.xquartz.* /Applications/Utilities/XQuartz.app /etc/*paths.d/*XQuartz
sudo pkgutil --forget org.macosforge.xquartz.pkg
# Log out and log in
来源 https://gist.github.com/tonymtz/714e73ccb79e21c4fc9c
另一个思路,就是当ssh进去之后,再安装 vnc 软件,通过vnc方式显示pi系统的图形界面。vnc方面的资料网上很多,就不多说了。
sudo apt-get install tightvncserver
tightvncserver
service lightdm stop
vncserver :1 -geometry 1920×1080 -depth 24
来源: https://www.raspberrypi.org/documentation/remote-access/vnc/
------------

树莓派适配蓝牙,将声音输出到蓝牙音响

插入蓝牙。
###连接蓝牙设备
add nao to group plugdev
> usermod -a -G plugdev nao
sudo hciconfig hci0 up 这一步会报错:
Can’t init device hci0: Operation not possible due to RF-kill (132)
然后可以通过 rfkill list 看soft block状态:
0: hci0: Bluetooth
Soft blocked: yes
Hard blocked: no
1: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no
可以看到 Bluetooth是处于 soft blocked 的状态,可是通过 rfkill unblock all 或 rfkill unblock bluetooth 都没效果。
查资料可能是由于内核模块 acer-wmi 冲突造成的,解决办法:
sudo modprobe -r acer-wmi
cd /etc/modprobe.d
sudo nano blacklist.conf
来自:http://askubuntu.com/questions/62730/cannot-change-soft-block-setting-to-no-for-ar9287-wireless-network
然后naoqi系统里面不存在 acer-wmi模块。
后来发现是 connman 造成的,解决办法:
root@osmc:~$ cat /var/lib/connman/settings
[global]
OfflineMode=false
[Wired]
Enable=true
Tethering=false
[Bluetooth]
Enable=false
Tethering=false
Setting Enabled=true under the Bluetooth tag fixed the soft block。
或直接用命令 connman enable bluetooth
来自:https://discourse.osmc.tv/t/enabling-bluetooth/711
修改后需要重启系统。
之后再 ,hciconfig hci0 up
其中 hci0 是通过 hciconfig -a 拿到的。
再通过命令扫描周围的蓝牙:
hcitool scan
扫描结果可能是:
Scanning …
CLLSPKPCARG
找到目标的 hadware_id后再运行:
simple-agent hci0 或有的命令为 bluez-simple-agent
再运行
hcitool cc && hcitool auth
查看已经认证过的蓝牙列表:
bluez-test-device list
编辑配置文件 /etc/asound.conf ,加入
pcm.bluetooth {
type bluetooth
device
}
再编辑 vi /etc/bluetooth/audio.conf,加入:
Disable=Media
Enable=Socket
重启 sudo /etc/init.d/bluetooth restart
然后测试一下:
mpg321 -a bluetooth -g 15 02 Magic.mp3
aplay -D bluetooth bluetooth-music.wav
###修改系统的默认输出设备
使用 pactl list 出现以下报错:
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
或使用pacmd 以下错:
No PulseAudio daemon running, or not running as session daemon.
解决办法: pulseaudio –kill && pulseaudio –start
如果 pactl list sinks short 命令没有出现蓝牙设备的sink,那么运行:pactl load-module module-alsa-sink device=bluetooth
参考:http://askubuntu.com/questions/145733/a2dp-connection-not-shown-in-pulseaudio
当蓝牙断开连接时,需要unload-module,参考 https://gist.github.com/joergschiller/1673341
再设置 pacmd set-default-sink 1
参考如何 动态切换audio输出 sink :
http://askubuntu.com/questions/71863/how-to-change-pulseaudio-sink-with-pacmd-set-default-sink-during-playback
http://unix.stackexchange.com/questions/65246/change-pulseaudio-input-output-from-shell
设置后,naoqi系统需要重启才能生效。
参考 :http://blog.whatgeek.com.pt/2014/04/raspberry-pi-bluetooth-wireless-speaker/
NAO设置参考:https://community.aldebaran.com/en/forum/problem-about-bluetooth-earphone-configuration-nao-3875
参考NAO对接蓝牙视频:https://www.youtube.com/watch?v=57Z4vLBgynI
2 – Create a serial port over BlueTooth:
> bluez-test-serial 00:07:80:51:10:73
Connected /dev/rfcomm0 to 00:07:80:51:10:73
Press CTRL-C to disconnect
Note the serial port name: “/dev/rfcomm0”
13 – Open, read and write using that port, eg using python and pyserial.
We’ve made an example using choregraphe: the simple_serial.py
(the serial port can be changed clicking the small tools at the bottom left of the choregraphe box)

No comments:

Post a Comment