我正在尝试在Ubuntu 12.04和连接到Arduino的JY-MCU蓝牙串行模块之间进行串行通信.
我在/etc/bluetooth/rfcomm.conf中创建了这个配置
rfcomm0 {
# # Automatically bind the device at startup
bind yes;
#
# # Bluetooth address of the device
device 00:12:11:19:08:54
# # RFCOMM channel for the connection
channel 1;
# # Description of the connection
comment "Linvor Bluetooth Module";
}
Run Code Online (Sandbox Code Playgroud)
我可以使用putty与/ dev/rfcomm0串口进行通信,这非常有效.
然而,尽管经过多次尝试,我根本无法看到如何在Processing中创建一个以任何方式工作的串行端口.
例如 :
println(Serial.list());
Run Code Online (Sandbox Code Playgroud)
什么都不打印.
如果我执行:
String portName = "/dev/rfcomm0";
myPort = new Serial(this, portName, 9600);
println(myPort);
Run Code Online (Sandbox Code Playgroud)
我在显示器中看到了这个:
processing.serial.Serial@1712651
Run Code Online (Sandbox Code Playgroud)
但如果我再打电话:
myPort.write('9');
Run Code Online (Sandbox Code Playgroud)
我得到一个例外:
java.lang.NullPointerException
at processing.serial.Serial.write(Serial.java:572)
...
Run Code Online (Sandbox Code Playgroud)
我无法理解为什么会失败.我一直在遵循Tom Igoe的"Make Things Talk"中的所有指示,但这并不像他说的那样......
任何帮助都会很棒!
谢谢,
短发