Article View: borland.public.jbuilder.java.language
Article #340Serial Port Communication error
From: Magnus
Date: Tue, 06 Dec 2005 15:53
Date: Tue, 06 Dec 2005 15:53
50 lines
2698 bytes
2698 bytes
Hi,
I have one customer (out of ~100) that can't get his communication over
the Serial port to work and I don't know how to find why this fails. The
customer can use the serial port to transfer data to other programs.
Any ideas?
Maybe it can be checked/verified in WinXP?
Can I add more exceptions to catch the fault?
Magnus
--- code ---
public UploadCommunication(String pID) { // Constr
try {
Format formatter = new SimpleDateFormat("yyMMdd-HHmmss");
LOGFILE = "UploadLog"+formatter.format(new Date())+".txt";
TimeStamp = new java.util.Date().toString();
Logg.ULLog(TimeStamp, LOGFILE);
Enumeration a = CommPortIdentifier.getPortIdentifiers();
if (!a.hasMoreElements()) {
Logg.ULLog("No ports found!", LOGFILE);
boolean stopRead = true;
}
portID = CommPortIdentifier.getPortIdentifier(pID);
serialPort1 = (SerialPort) portID.open("UploadCommunication",
2000);
Logg.ULLog(portID.getName() + " opened for instrument
input",LOGFILE);
} catch (Exception ee) {
if (portID == null) {
Logg.ULLog("PortID is NULL for port: " + pID,LOGFILE);
} else {
Logg.ULLog("main catch portID: " + portID, LOGFILE);
}
Logg.ULLog("main catch ee: " + ee.toString(),LOGFILE);
boolean stopRead = true;
try {serialPort1.close();
} catch (Exception ce) {} //try to close the port
}
--- end code ---
--- I get the following in UploadLog ---
Mon Dec 5 14:45:09 GMT-05:00 2005
No ports found!
PortID is NULL for port: COM1
main catch ee: javax.comm.NoSuchPortException
Technical Details
Message-ID:
<4395b3a2$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!pd7cy2so!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: f74b3,acd888fe3a68cc1b,start X-Google-Attributes: gidf74b3,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Tue, 06 Dec 2005 10:53:04 -0500 From: Magnus <magnus_bjorkman@iwon.com> User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language Subject: Serial Port Communication error Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 69.34.163.158 Message-ID: <4395b3a2$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1133884322 69.34.163.158 (6 Dec 2005 07:52:02 -0700) Lines: 50 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!pd7cy2so!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail