我想创建一个包含串口列表的“列表框”(使用linux库):目标是创建一个独立的应用程序,使用处理来与Arduino Uno通信,独立于我要使用的操作系统(win,mac或controlP5 ),并选择(使用“列表框”)正确的串口与Arduino通信。有可能吗??
发布于 2012-10-06 13:28:44
ControlP5 cp5 = new ControlP5(this);
ListBox listBox = cp5.addListBox("serialPorts");
Serial serial;
String[] ports = Serial.list();
for (int i=0; i<ports.length; i++) {
listBox.addItem(ports[i]);
}
void controlEvent(ControlEvent theEvent) {
if(theEvent.isGroup() && theEvent.name().equals("myList")){
int val = (int)theEvent.group().value();
serial = new Serial(this, ports[val], 9600);
}
}未经测试,但这是最基本的想法...
https://stackoverflow.com/questions/12742503
复制相似问题