我正在尝试在 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";
}
我可以使用 putty 与 /dev/rfcomm0 串行端口进行通信,并且效果很好。
但是,尽管进行了多次尝试,但我根本看不到如何在 Processing 中创建一个以任何方式工作的串行端口。
例如 :
println(Serial.list());
什么都不打印。
如果我执行:
String portName = "/dev/rfcomm0";
myPort = new Serial(this, portName, 9600);
println(myPort);
我在显示器上看到了这个:
processing.serial.Serial@1712651
但如果我再打电话:
myPort.write('9');
我得到一个例外:
java.lang.NullPointerException
at processing.serial.Serial.write(Serial.java:572)
...
我不明白为什么这会失败。我一直在遵循 Tom Igoe 的“让事情说话”中的所有指示,但这并不像他所说的那样工作......
任何帮助都会很棒!
谢谢,
鲍勃