Thanks, that helped a lot. Now I can see the error is in Java: sometimes "Write end
dead" and sometimes "Broken Pipe" as in traces below. I found some discussions at
Sun's site that suggested the problem may be in the fact that to two ends are in
different threads so I moved the write to a write method in the Jess runner thread as
below:
public void write(String data) throws IOException{
pwrt.write(data+"\n");
pwrt.flush();
// pwrt.close();
// pwrt = new PipedWriter();
// prdr.connect(pwrt);
// pwrt.connect(prdr);
}
As you can see I tried various combos of refreshng the writer, no luck. It does
appear to work a little better, going 3-5 transfers before it dies. The Sun links are
below and the traces follow. I am switching to an event driven approach where the
data will be asserted as new facts. This seems very reliable, but I must change a ton
of Jess code that works (from files) in the while loop version. The problem is when I
replace the file version with a stream of data from a serial port.
Once again, any help appreciated.
4130880
http://developer.java.sun.com/developer/bugParade/bugs/4130880.html
4131126
http://developer.java.sun.com/developer/bugParade/bugs/4131126.html
Jess reported an error in routine Tokenizer.nextChar
while executing (read ?inStream)
while executing (bind ?eventCode (read ?inStream))
while executing deffunction logicAgent
while executing (logicAgent).
Message: Error on input stream.
Program text: ( logicAgent ) at line 1.
at jess.Tokenizer.nextChar(Tokenizer.java:202)
at jess.Tokenizer.nextToken(Tokenizer.java:132)
at jess.Read.call(Funcall.java:599)
at jess.FunctionHolder.call(FunctionHolder.java:37)
at jess.Funcall.execute(Funcall.java:270)
at jess.FuncallValue.resolveValue(FuncallValue.java:33)
at jess.Bind.call(Funcall.java:773)
at jess.FunctionHolder.call(FunctionHolder.java:37)
at jess.Funcall.execute(Funcall.java:270)
at jess.FuncallValue.resolveValue(FuncallValue.java:33)
at jess.Deffunction.call(Deffunction.java:187)
at jess.FunctionHolder.call(FunctionHolder.java:37)
at jess.Funcall.execute(Funcall.java:270)
at jess.Jesp.parseAndExecuteFuncall(Jesp.java:1596)
at jess.Jesp.parseSexp(Jesp.java:183)
at jess.Jesp.parse(Jesp.java:62)
at jess.Rete.executeCommand(Rete.java:1205)
at com.globalinfotek.JessAgent$JessRunner.r
un(JessAgent.java:392)
at java.lang.Thread.run(Thread.java:536)
java.io.IOException: Write end dead
at java.io.PipedReader.ready(PipedReader.java:286)
at java.io.BufferedReader.ready(BufferedReader.java:436)
at java.io.FilterReader.ready(FilterReader.java:75)
at java.io.PushbackReader.ready(PushbackReader.java:188)
at jess.Tokenizer.nextChar(Tokenizer.java:190)
at jess.Tokenizer.nextToken(Tokenizer.java:132)
at jess.Read.call(Funcall.java:599)
at jess.FunctionHolder.call(FunctionHolder.java:37)
at jess.Funcall.execute(Funcall.java:270)
at jess.FuncallValue.resolveValue(FuncallValue.java:33)
at jess.Bind.call(Funcall.java:773)
at jess.FunctionHolder.call(FunctionHolder.java:37)
at jess.Funcall.execute(Funcall.java:270)
at jess.FuncallValue.resolveValue(FuncallValue.java:33)
at jess.Deffunction.call(Deffunction.java:187)
at jess.FunctionHolder.call(FunctionHolder.java:37)
at jess.Funcall.execute(Funcall.java:270)
at jess.Jesp.parseAndExecuteFuncall(Jesp.java:1596)
at jess.Jesp.parseSexp(Jesp.java:183)
at jess.Jesp.parse(Jesp.java:62)
at jess.Rete.executeCommand(Rete.java:1205)
at com.globalinfotek.JessAgent$JessRunner.r
un(JessAgent.java:392)
at java.lang.Thread.run(Thread.java:536)
Ready to send to Jess
Processed code: T27O
After data sent to Jess
Ready to send to Jess
Processed code: T24O
After data sent to Jess
Ready to send to Jess
Processed code: T01O
After data sent to Jess
Jess reported an error in routine Tokenizer.nextChar
while executing (read ?inStream)
while executing (bind ?eventCode (read ?inStream))
while executing (while (and (<> 0 (str-compare ?eventCode "EOF")) (<> 0
(str-compare ?eventCode "AEND"))) do (processEventCode ?logID ?outStream ?system
State ?eventCode) (printout t "Processed code: " ?eventCode crlf) (bind ?eventCo
de (read ?inStream)))
while executing deffunction logicAgent
while executing (logicAgent).
Message: Error on input stream.
Program text: ( logicAgent ) at line 1.
at jess.Tokenizer.nextChar(Tokenizer.java:202)
at jess.Tokenizer.nextToken(Tokenizer.java:69)
at jess.Read.call(Funcall.java:599)
at jess.FunctionHolder.call(FunctionHolder.java:37)
at jess.Funcall.execute(Funcall.java:270)
at jess.FuncallValue.resolveValue(FuncallValue.java:33)
at jess.Bind.call(Funcall.java:773)
at jess.FunctionHolder.call(FunctionHolder.java:37)
at jess.Funcall.execute(Funcall.java:270)
at jess.FuncallValue.resolveValue(FuncallValue.java:33)
at jess.While.call(Funcall.java:676)
at jess.FunctionHolder.call(FunctionHolder.java:37)
at jess.Funcall.execute(Funcall.java:270)
at jess.FuncallValue.resolveValue(FuncallValue.java:33)
at jess.Deffunction.call(Deffunction.java:187)
at jess.FunctionHolder.call(FunctionHolder.java:37)
at jess.Funcall.execute(Funcall.java:270)
at jess.Jesp.parseAndExecuteFuncall(Jesp.java:1596)
at jess.Jesp.parseSexp(Jesp.java:183)
at jess.Jesp.parse(Jesp.java:62)
at jess.Rete.executeCommand(Rete.java:1205)
at com.globalinfotek.JessAgent$JessRunner.r
un(JessAgent.java:385)
at java.lang.Thread.run(Thread.java:536)
java.io.IOException: Pipe broken
at java.io.PipedReader.read(PipedReader.java:197)
at java.io.FilterReader.read(FilterReader.java:48)
at java.io.PushbackReader.read(PushbackReader.java:73)
at jess.Tokenizer.nextChar(Tokenizer.java:187)
at jess.Tokenizer.nextToken(Tokenizer.java:69)
at jess.Read.call(Funcall.java:599)
at jess.FunctionHolder.call(FunctionHolder.java:37)
at jess.Funcall.execute(Funcall.java:270)
at jess.FuncallValue.resolveValue(FuncallValue.java:33)
at jess.Bind.call(Funcall.java:773)
at jess.FunctionHolder.call(FunctionHolder.java:37)
at jess.Funcall.execute(Funcall.java:270)
at jess.FuncallValue.resolveValue(FuncallValue.java:33)
at jess.While.call(Funcall.java:676)
at jess.FunctionHolder.call(FunctionHolder.java:37)
at jess.Funcall.execute(Funcall.java:270)
at jess.FuncallValue.resolveValue(FuncallValue.java:33)
at jess.Deffunction.call(Deffunction.java:187)
at jess.FunctionHolder.call(FunctionHolder.java:37)
at jess.Funcall.execute(Funcall.java:270)
at jess.Jesp.parseAndExecuteFuncall(Jesp.java:1596)
at jess.Jesp.parseSexp(Jesp.java:183)
at jess.Jesp.parse(Jesp.java:62)
at jess.Rete.executeCommand(Rete.java:1205)
at com.globalinfotek.JessAgent$JessRunner.r
un(JessAgent.java:385)
at java.lang.Thread.run(Thread.java:536)
Ready to send to Jess
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 25, 2003 9:19 PM
To: [EMAIL PROTECTED]
Subject: Re: JESS: Jess reported an error in routine Tokenizer.nextChar
I think Kelvin Rawls wrote:
> Jess reported an error in routine Tokenizer.nextChar
> while executing (read ?inStream)
> while executing (bind ?eventCode (read ?inStream))
> while executing (while (and (<> 0 (str-compare ?eventCode
> "EOF")) (<> 0 (str-compare ?eventCode "AEND"))) do (processEventCode
> ?logID ?outStream ?system State ?eventCode) (printout t "Processed
> code: " ?eventCode crlf) (bind ?eventCo de (read ?inStream)))
> while executing deffunction logicAgent
> while executing (logicAgent).
> Message: Error on input stream.
> ....
>
> Any help appreciated. I have tried with and without buffers on
> writer and reader. Different size buffers. AsConsole or not.
> readline, in all above combinations. Works better with ssmall
> buffers.
Look at section 4.1 of the Jess 6.1 manual, where it talks about
JessExceptions:
Another important tip: the JessException class has a method
getNextException which returns non-null when a particular
JessException is a wrapper for another kind of exception. For
example, if you use the Jess function call to call a function
that throws an exception, then call will throw a JessException,
and calling JessException.getNextException() will return the real
exception that was thrown. Your JessException handlers should
always check getNextException(); if your handler simply displays
a thrown exception, then it should display the return value of
getNextException(), too.
That's what's happening here: the stream is throwing an
IOException, and Jess is just passing it along. Fix your catch block
to report the nested exception and you'll find out what's going wrong.
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://herzberg.ca.sandia.gov
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------