RLPark 1.0.0
Reinforcement Learning Framework in Java

SerialPorts.java

Go to the documentation of this file.
00001 package rlpark.plugin.irobot.internal.serial;
00002 
00003 import gnu.io.CommPortIdentifier;
00004 
00005 import java.util.ArrayList;
00006 import java.util.Collection;
00007 import java.util.Enumeration;
00008 import java.util.LinkedHashMap;
00009 import java.util.Map;
00010 
00011 
00012 public class SerialPorts {
00013   static Map<String, CommPortIdentifier> portIdentifiers = new LinkedHashMap<String, CommPortIdentifier>();
00014 
00015   @SuppressWarnings("unchecked")
00016   static public void refreshPortIdentifiers() {
00017     portIdentifiers.clear();
00018     Enumeration<CommPortIdentifier> portList = CommPortIdentifier.getPortIdentifiers();
00019     while (portList.hasMoreElements()) {
00020       CommPortIdentifier portId = portList.nextElement();
00021       if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL)
00022         portIdentifiers.put(portId.getName(), portId);
00023     }
00024   }
00025 
00026   public static CommPortIdentifier getPortIdentifier(String filename) {
00027     return portIdentifiers.get(filename);
00028   }
00029 
00030   static public Collection<String> getSerialPortsList() {
00031     refreshPortIdentifiers();
00032     return new ArrayList<String>(portIdentifiers.keySet());
00033   }
00034 }
 All Classes Namespaces Files Functions Variables Enumerations
Zephyr
RLPark