From aa29cd2518f01101c68560df9f612e61ebfb33ec Mon Sep 17 00:00:00 2001 From: Thomas Oster <thomas.oster@rwth-aachen.de> Date: Wed, 1 Aug 2012 17:48:56 +0200 Subject: [PATCH] Serial fix (still untested) --- .../liblasercut/drivers/Lasersaur.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/com/t_oster/liblasercut/drivers/Lasersaur.java b/src/com/t_oster/liblasercut/drivers/Lasersaur.java index ecc6366..1ceb673 100644 --- a/src/com/t_oster/liblasercut/drivers/Lasersaur.java +++ b/src/com/t_oster/liblasercut/drivers/Lasersaur.java @@ -25,12 +25,10 @@ import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.io.UnsupportedEncodingException; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; +import java.util.*; import purejavacomm.CommPort; import purejavacomm.CommPortIdentifier; +import purejavacomm.NoSuchPortException; import purejavacomm.SerialPort; /** @@ -389,7 +387,19 @@ public class Lasersaur extends LaserCutter { pl.taskChanged(this, "checking job"); checkJob(job); pl.taskChanged(this, "connecting"); - CommPortIdentifier cpi = CommPortIdentifier.getPortIdentifier(this.getComPort()); + CommPortIdentifier cpi = null; + //since the CommPortIdentifier.getPortIdentifier(String name) method + //is not working as expected, we have to manually find our port. + Enumeration en = CommPortIdentifier.getPortIdentifiers(); + while (en.hasMoreElements()) + { + Object o = en.nextElement(); + if (o instanceof CommPortIdentifier && ((CommPortIdentifier) o).getName().equals(this.getComPort())) + { + cpi = (CommPortIdentifier) o; + break; + } + } if (cpi == null) { throw new Exception("Error: No such COM-Port '"+this.getComPort()+"'"); -- GitLab